:root {
  --bg-dark: #0f172a;
  --bg-surface: #f8fafc;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.08);
  --primary-border: rgba(2, 132, 199, 0.35);
  --accent: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --bottom-nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 24px);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   App Header
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background-color: var(--bg-dark);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-admin {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background-color: var(--primary);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: 36px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
  min-height: 32px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
  min-height: 26px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 16px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-outline {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  background: transparent;
  color: #ffffff;
}

.btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: var(--danger-hover);
}

.w-full {
  width: 100%;
}

/* ==========================================================================
   Main & Tab Panes
   ========================================================================== */
.app-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.pane-header {
  margin-bottom: 20px;
}

.pane-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.pane-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Toolbar & Search
   ========================================================================== */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.search-box {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  font-size: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.toolbar-stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Unassigned / Staging Media Tray
   ========================================================================== */
.unassigned-container {
  background-color: #fffbeb;
  border: 2px dashed #f59e0b;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.unassigned-container.drag-over {
  background-color: #fef3c7;
  border-color: #d97706;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.unassigned-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.unassigned-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unassigned-badge {
  font-weight: 700;
  font-size: 14px;
  color: #b45309;
}

.unassigned-counter {
  font-size: 12px;
  font-weight: 600;
  color: #d97706;
  background: rgba(245, 158, 11, 0.15);
  padding: 2px 8px;
  border-radius: 9999px;
}

.unassigned-hint {
  font-size: 12px;
  color: #92400e;
}

/* ==========================================================================
   Entry Media Card
   ========================================================================== */
.entry-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.entry-card.drag-over {
  border-color: var(--primary);
  background-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.entry-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(248, 250, 252, 0.8);
  gap: 10px;
}

.entry-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.entry-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.entry-date {
  font-weight: 500;
}

.entry-coords {
  font-family: monospace;
  font-size: 11px;
  background-color: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.entry-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.entry-media-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 3px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

/* ==========================================================================
   Media Grid & Thumbnails
   ========================================================================== */
.media-dropzone {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  min-height: 80px;
  transition: background-color 0.15s ease;
}

@media (min-width: 600px) {
  .media-dropzone {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 14px;
  }
}

@media (min-width: 800px) {
  .media-dropzone {
    grid-template-columns: repeat(6, 1fr);
  }
}

.media-dropzone.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border-color);
  margin: 10px;
  border-radius: var(--radius-sm);
  background-color: #fafafa;
}

.media-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: #e2e8f0;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.media-item:active {
  cursor: grabbing;
}

.media-item.dragging {
  opacity: 0.35;
  transform: scale(0.92);
}

.media-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.media-cover-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(2, 132, 199, 0.9);
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  backdrop-filter: blur(2px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.media-type-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  pointer-events: none;
}

.media-item-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  opacity: 0.9;
  transition: opacity 0.15s, transform 0.15s;
}

.media-item:hover .media-item-actions {
  opacity: 1;
  transform: scale(1.05);
}

/* ==========================================================================
   Bottom Mobile Navigation
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
  padding: 4px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* ==========================================================================
   Mobile Action Sheet / Tap-To-Move Bottom Sheet
   ========================================================================== */
.action-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.action-sheet-backdrop.hidden {
  display: none;
}

.action-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  background-color: #ffffff;
  border-radius: 20px 20px 0 0;
  padding: 16px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 40px;
  height: 5px;
  background-color: #cbd5e1;
  border-radius: 9999px;
  margin: 0 auto 4px;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sheet-thumb-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: #e2e8f0;
  flex-shrink: 0;
}

.sheet-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sheet-media-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
}

.sheet-meta {
  flex: 1;
  min-width: 0;
}

.sheet-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.sheet-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.sheet-action-btn:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.sheet-move-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-move-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-entries-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  background-color: #f8fafc;
}

.sheet-entry-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.sheet-entry-option:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

.sheet-entry-option.current {
  opacity: 0.5;
  background-color: #f1f5f9;
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
   Loading & Empty States
   ========================================================================== */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background-color: #0f172a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-10px);
  animation: toastIn 0.25s forwards, toastOut 0.25s forwards 2.75s;
}

.toast.success {
  background-color: #047857;
}

.toast.error {
  background-color: #b91c1c;
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Touch drag ghost element */
.touch-drag-ghost {
  position: fixed;
  z-index: 1000;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0.85;
  transform: translate(-50%, -50%);
}

.touch-drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Settings and Telemetry Cards */
.settings-card, .gps-telemetry-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-info span {
  font-size: 12px;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Toolbar Enhancements
   ========================================================================== */
.toolbar-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.unassigned-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-header-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.btn-outline-dark {
  background-color: #ffffff;
  color: var(--text-primary);
  border: 1px solid #cbd5e1;
}

.btn-outline-dark:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.sheet-action-btn.primary-action {
  background-color: #f0f9ff;
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 700;
}

.sheet-action-btn.primary-action:hover {
  background-color: #e0f2fe;
}

/* ==========================================================================
   Mobile Entry Form Sheet & Location Picker
   ========================================================================== */
.entry-form-sheet {
  max-width: 640px;
  max-height: 90vh;
}

.new-entry-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.form-media-section {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.form-media-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.media-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.media-chip-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
}

.location-picker-group {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  gap: 10px;
}

.location-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-gps-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.picker-map-container {
  width: 100%;
  height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background-color: #e2e8f0;
  z-index: 10;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.picker-hint {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
}

.coords-row {
  display: flex;
  gap: 10px;
}

.coord-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.coord-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.coord-input {
  font-size: 13px;
  padding: 8px 10px;
}

.form-actions {
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

/* ==========================================================================
   Debug & Live Server Logs Terminal
   ========================================================================== */
.log-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: var(--text-secondary);
}

.log-status-badge.connected {
  background: #dcfce7;
  color: #166534;
}

.log-status-badge.paused {
  background: #fef3c7;
  color: #92400e;
}

.log-status-badge.disconnected {
  background: #fee2e2;
  color: #991b1b;
}

.debug-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.debug-search-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
  display: flex;
  align-items: center;
}

.debug-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  font-size: 13px;
  pointer-events: none;
  color: var(--text-muted);
}

.debug-search-wrap .search-input {
  width: 100%;
  padding-left: 32px;
}

.debug-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.debug-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.debug-toggle-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.terminal-container {
  display: flex;
  flex-direction: column;
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  height: calc(100vh - 240px);
  min-height: 400px;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  font-size: 11px;
  color: #94a3b8;
  user-select: none;
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.terminal-title {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 500;
  color: #cbd5e1;
}

.terminal-count {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.terminal-body {
  flex: 1;
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: auto;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #e2e8f0;
  background: #090d16;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 1px 0;
}

.terminal-line.hidden {
  display: none;
}

.terminal-line:hover {
  background: rgba(255, 255, 255, 0.04);
}

.terminal-ts {
  color: #64748b;
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}

.terminal-msg {
  flex: 1;
  color: #cbd5e1;
}

.terminal-msg.lvl-upload {
  color: #38bdf8;
  font-weight: 600;
}

.terminal-msg.lvl-error {
  color: #f87171;
  font-weight: 600;
}

.terminal-msg.lvl-warning {
  color: #fbbf24;
}

.terminal-msg.lvl-debug {
  color: #94a3b8;
}

.terminal-empty {
  color: #64748b;
  font-style: italic;
  padding: 20px 0;
  text-align: center;
}

/* ==========================================================================
   Visitor Analytics & Stats Tab
   ========================================================================== */
.analytics-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-select {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.form-select:focus {
  border-color: var(--primary);
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.analytics-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.analytics-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.analytics-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.dot-views {
  background: #0284c7;
}

.dot-uniques {
  background: #f59e0b;
}

.chart-wrapper {
  overflow-x: auto;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.bar-chart-container {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding-top: 24px;
  min-width: 100%;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.bar-group {
  flex: 1;
  min-width: 22px;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  cursor: pointer;
}

.bar-stack {
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 130px;
}

.bar-col {
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  width: 46%;
  transition: height 0.25s ease, opacity 0.2s ease;
}

.bar-col.bar-views {
  background: #0284c7;
}

.bar-col.bar-uniques {
  background: #f59e0b;
}

.bar-group:hover .bar-col {
  opacity: 0.85;
  filter: brightness(1.1);
}

.bar-date-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
}

.bar-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 20;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
}

.bar-group:hover .bar-tooltip {
  opacity: 1;
}

.analytics-two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .analytics-two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.analytics-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-size: 13px;
  overflow: hidden;
}

.analytics-row-bar {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(2, 132, 199, 0.12);
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: width 0.3s ease;
}

.analytics-row-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.analytics-row-title {
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 75%;
}

.analytics-row-count {
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.analytics-empty {
  text-align: center;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.analytics-loading {
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.analytics-subsections {
  display: flex;
  flex-direction: column;
}

.subsection-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  margin-top: 6px;
}

.mb-3 {
  margin-bottom: 16px;
}

