/* Jeepstats Dashboard — Professional Dark-Header Theme */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --blue-900: #1e3a8a;
  --blue-800: #1e40af;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;
  --amber:    #f59e0b;
  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;
  --green-500: #22c55e;
  --red-500:   #ef4444;

  --header-h: 48px;
  --toolbar-h: 44px;
  --radius:   6px;
  --radius-sm: 4px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--slate-100);
  color: var(--slate-900);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────── */

.header {
  height: var(--header-h);
  background: var(--slate-900);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--slate-800);
}

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

.brand-icon {
  width: 18px;
  height: 18px;
  color: var(--blue-400);
  flex-shrink: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .02em;
}

.brand-divider {
  width: 1px;
  height: 14px;
  background: var(--slate-700);
}

.brand-sub {
  font-size: 12px;
  color: var(--slate-400);
  font-weight: 400;
}

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

.last-updated {
  font-size: 11px;
  color: var(--slate-400);
}

/* ─── Toolbar ─────────────────────────────── */

.toolbar {
  height: var(--toolbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--slate-200);
}

/* Segmented control */
.seg-control {
  display: flex;
  background: var(--slate-100);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}

.seg-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 28px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.seg-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.seg-btn:hover {
  background: var(--white);
  color: var(--slate-900);
}

.seg-btn.seg-active {
  background: var(--white);
  color: var(--blue-600);
  box-shadow: var(--shadow);
}

/* Date range */
.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-icon {
  width: 14px;
  height: 14px;
  color: var(--slate-400);
  flex-shrink: 0;
}

.date-sep {
  color: var(--slate-400);
  font-size: 12px;
}

.date-input {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--slate-800);
  background: var(--white);
  outline: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.date-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}

/* ─── Buttons ─────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  overflow: visible;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
  border-color: var(--blue-600);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-800);
  border-color: var(--blue-800);
}

.btn-ghost {
  background: transparent;
  color: var(--blue-400);
  border-color: rgba(96, 165, 250, 0.35);
  font-size: 12px;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.1);
  color: var(--blue-300, #93c5fd);
  border-color: rgba(96, 165, 250, 0.6);
}

.btn-outline-sm {
  background: var(--white);
  color: var(--slate-600);
  border-color: var(--slate-200);
  font-size: 11px;
  height: 26px;
  padding: 0 10px;
}

.btn-outline-sm:hover {
  border-color: var(--blue-500);
  color: var(--blue-600);
}

/* ─── Toast ───────────────────────────────── */

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
}

.toast svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.toast-success {
  background: #f0fdf4;
  color: #15803d;
  border-bottom: 1px solid #bbf7d0;
}

.toast-error {
  background: #fef2f2;
  color: #b91c1c;
  border-bottom: 1px solid #fecaca;
}

/* ─── Sync error banner ───────────────────── */

.sync-error-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  border-top: 1px solid #fde68a;
}

.sync-error-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  max-width: 100%;
}

.sync-error-inner > svg {
  width: 15px;
  height: 15px;
  color: #d97706;
  flex-shrink: 0;
}

.sync-error-text {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.sync-error-title {
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  white-space: nowrap;
}

.sync-error-detail {
  font-size: 11px;
  color: #b45309;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-error-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-retry {
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
}

.btn-retry:hover:not(:disabled) {
  background: #fde68a;
  border-color: #f59e0b;
}

.btn-retry:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-dismiss {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: #b45309;
  cursor: pointer;
  transition: background .15s;
}

.btn-dismiss svg {
  width: 13px;
  height: 13px;
}

.btn-dismiss:hover {
  background: #fde68a;
}

.slide-down-enter-active,
.slide-down-leave-active {
  transition: all .2s ease;
  overflow: hidden;
}

.slide-down-enter-from,
.slide-down-leave-to {
  max-height: 0;
  opacity: 0;
}

.slide-down-enter-to,
.slide-down-leave-from {
  max-height: 60px;
  opacity: 1;
}

/* ─── Main content ────────────────────────── */

.main-content {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

/* ─── Cards ───────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--slate-100);
  min-height: 40px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.record-count {
  font-size: 11px;
  color: var(--slate-400);
}

/* ─── Metric legend ───────────────────────── */

.metric-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--slate-600);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Chart ───────────────────────────────── */

.chart-card { }

.chart-wrapper {
  position: relative;
  height: 280px;
  padding: 12px 16px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--slate-300);
}

.chart-empty svg {
  width: 32px;
  height: 32px;
}

.chart-empty p {
  font-size: 12px;
  color: var(--slate-400);
}

/* ─── Table ───────────────────────────────── */

.table-card { }

.table-wrapper {
  overflow-x: auto;
  max-height: 380px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  background: var(--slate-50);
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--blue-50);
}

.col-date {
  text-align: left;
  color: var(--slate-500);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ─── Empty state ─────────────────────────── */

.empty-state {
  padding: 48px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--slate-300);
}

.empty-state svg {
  width: 28px;
  height: 28px;
}

.empty-state p {
  font-size: 12px;
  color: var(--slate-400);
}

/* ─── Animations ──────────────────────────── */

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

.spin {
  animation: spin .7s linear infinite;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity .2s;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* ─── Responsive ──────────────────────────── */

@media (max-width: 768px) {
  .toolbar {
    height: auto;
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-left {
    flex-wrap: wrap;
    gap: 8px;
  }

  .header {
    padding: 0 16px;
  }

  .main-content {
    padding: 12px 16px;
  }

  .chart-wrapper {
    height: 220px;
  }

  .metric-legend {
    display: none;
  }
}

/* ─── Modal ───────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--slate-200);
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-900);
}

.modal-close {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.modal-close svg { width: 14px; height: 14px; }

.modal-close:hover {
  background: var(--slate-100);
  color: var(--slate-700);
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--slate-100);
}

/* Guide */
.guide {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.guide-steps {
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guide-steps li {
  font-size: 12px;
  color: var(--slate-600);
  line-height: 1.6;
}

.guide-steps strong {
  color: var(--slate-800);
  font-weight: 600;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  font-family: monospace;
  background: var(--white);
  border: 1px solid var(--slate-300);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--slate-300);
  color: var(--slate-700);
}

.code-text {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--blue-600);
}

.guide-fields { display: flex; flex-direction: column; gap: 6px; }

.guide-fields-label {
  font-size: 11px;
  color: var(--slate-500);
}

.field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.field-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: monospace;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid;
  transition: all .15s;
}

.field-tag svg { width: 10px; height: 10px; }

.field-missing {
  color: var(--slate-400);
  border-color: var(--slate-200);
  background: var(--slate-50);
}

.field-found {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

/* Cookie input */
.cookie-input-wrap { display: flex; flex-direction: column; gap: 6px; }

.cookie-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-700);
}

.cookie-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--slate-700);
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}

.cookie-textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}

.cookie-textarea::placeholder { color: var(--slate-300); }

.cookie-parsed-hint {
  font-size: 11px;
  color: var(--slate-400);
}

.cookie-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #b91c1c;
}

.cookie-error svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* Ghost button for modal */
.btn-ghost-modal {
  background: transparent;
  color: var(--slate-600);
  border-color: var(--slate-200);
}

.btn-ghost-modal:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
}

/* Modal transition */
.modal-fade-enter-active,
.modal-fade-leave-active {
  transition: opacity .2s;
}

.modal-fade-enter-active .modal,
.modal-fade-leave-active .modal {
  transition: transform .2s;
}

.modal-fade-enter-from,
.modal-fade-leave-to {
  opacity: 0;
}

.modal-fade-enter-from .modal,
.modal-fade-leave-to .modal {
  transform: translateY(-8px) scale(.98);
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .fade-enter-active, .fade-leave-active { transition: none; }
}
