/* LyftV3 — design system. Portado do LyftV1 (report_theme._THEME_CSS), adaptado
   para tema claro + escuro via [data-theme]. As classes referenciam variáveis;
   só os valores das variáveis mudam entre os temas.
   Semântica de cor (diretiva do projeto): --accent = RideIntel (violeta, chrome/brand
   do produto); --color-lyft = lado-Lyft nos gráficos (magenta, fonte de dados/fee);
   --color-money = renda do motorista; --color-expense = despesa. */

/* ===== Tema escuro (default, := :root) ===== */
:root,
[data-theme="dark"] {
  --bg-deep: #0a0e13;
  --bg-surface: #131820;
  --bg-elevated: #1a2029;
  --bg-hover: #232b36;
  --border: #232b36;
  --border-strong: #2f3947;
  --text-primary: #e8e9ea;
  --text-secondary: #9aa3ad;
  --text-muted: #5c6370;
  --accent: #8b5cf6;            /* RideIntel violeta (chrome do produto) */
  --accent-soft: rgba(139, 92, 246, 0.14);
  --accent-hover: #7c3aed;
  --brand-a: #a855f7;           /* gradiente da marca: roxo -> índigo (sem rosa) */
  --brand-b: #6366f1;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
  --info: #60a5fa;
  --gold: #f59e0b;
  --chart-1: #8b5cf6;
  --chart-2: #60a5fa;
  --chart-3: #4ade80;
  --chart-4: #fbbf24;
  --chart-5: #a78bfa;
  --chart-6: #fb923c;
  --chart-7: #34d399;
  --chart-8: #f472b6;
  --color-lyft: #ff00bf;
  --color-lyft-soft: rgba(255, 0, 191, 0.55);
  --color-money: #f59e0b;
  --color-money-soft: rgba(245, 158, 11, 0.55);
  --color-expense: #ef4444;
  --color-expense-soft: rgba(239, 68, 68, 0.55);
  --body-grad-a: #0a0e13;
  --body-grad-b: #0d1219;
  --header-bg: rgba(10, 14, 19, 0.92);
}

/* ===== Tema claro (derivado; V1 não tinha) ===== */
[data-theme="light"] {
  --bg-deep: #f7f8fa;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f2f5;
  --bg-hover: #e9ecf1;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text-primary: #1a2029;
  --text-secondary: #4b545f;
  --text-muted: #8b929e;
  --accent: #7c3aed;            /* RideIntel violeta (tom p/ contraste em fundo claro) */
  --accent-soft: rgba(124, 58, 237, 0.10);
  --accent-hover: #6d28d9;
  --brand-a: #9333ea;           /* gradiente da marca: roxo -> índigo (sem rosa) */
  --brand-b: #4f46e5;
  --success: #16a34a;
  --warning: #b45309;
  --danger: #dc2626;
  --info: #2563eb;
  --gold: #b45309;
  --chart-1: #7c3aed;
  --chart-2: #2563eb;
  --chart-3: #16a34a;
  --chart-4: #d97706;
  --chart-5: #7c3aed;
  --chart-6: #ea580c;
  --chart-7: #0d9488;
  --chart-8: #db2777;
  --color-lyft: #d6009f;
  --color-lyft-soft: rgba(214, 0, 159, 0.45);
  --color-money: #b45309;
  --color-money-soft: rgba(180, 83, 9, 0.45);
  --color-expense: #dc2626;
  --color-expense-soft: rgba(220, 38, 38, 0.45);
  --body-grad-a: #f7f8fa;
  --body-grad-b: #eef1f5;
  --header-bg: rgba(255, 255, 255, 0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100%;
}
html { transition: background-color 0.15s ease, color 0.15s ease; }
body {
  background: linear-gradient(180deg, var(--body-grad-a) 0%, var(--body-grad-b) 100%);
  background-attachment: fixed;
}
a { color: var(--info); text-decoration: none; }
a:hover { color: var(--accent); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.success { color: var(--success); }
.warning { color: var(--warning); }
.danger { color: var(--danger); }
.up::before { content: "▲ "; color: var(--success); }
.down::before { content: "▼ "; color: var(--danger); }

.app-header {
  position: sticky; top: 0; z-index: 200;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
}
.app-header .brand {
  font-size: 18px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}
.app-header .brand .brand-mark { flex: none; }
.app-header .subtitle {
  color: var(--text-muted); font-size: 12px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
.app-header nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.app-header nav a {
  color: var(--text-secondary); padding: 8px 14px;
  border-radius: 6px; font-size: 13px; transition: all 0.15s;
}
.app-header nav a:hover { background: var(--bg-elevated); color: var(--text-primary); }
.app-header nav a.active { background: var(--accent-soft); color: var(--accent); }

.theme-toggle {
  margin-left: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 6px;
  padding: 7px 10px; font-size: 14px; cursor: pointer; line-height: 1;
  transition: all 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }
.section-title { font-size: 22px; font-weight: 600; margin: 16px 0 16px; letter-spacing: -0.01em; }
.section-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

.card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
}
.card:hover { border-color: var(--border-strong); }
.card .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600;
}
.card .value {
  font-size: 28px; font-weight: 700;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  margin-top: 6px; color: var(--text-primary); letter-spacing: -0.02em;
}
.card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.card .delta {
  font-size: 11px; margin-top: 6px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 600;
}

.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi-card .value { font-size: 32px; }
.kpi-card.featured {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border-color: var(--accent);
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated); position: sticky; top: 0;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: var(--bg-elevated); }
.table .num { font-family: ui-monospace, "SF Mono", Consolas, monospace; text-align: right; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 600; letter-spacing: 0.04em;
}
.badge.ok { background: rgba(74,222,128,0.15); color: var(--success); }
.badge.warn { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge.err { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge.info { background: rgba(96,165,250,0.15); color: var(--info); }
.badge.dim { background: var(--bg-elevated); color: var(--text-muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab {
  padding: 12px 18px; cursor: pointer; color: var(--text-secondary); font-size: 13px;
  font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; transition: all 0.15s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.app-footer {
  text-align: center; padding: 32px 24px; color: var(--text-muted);
  font-size: 12px; font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

.chart-container { position: relative; height: 320px; }
.chart-container-tall { position: relative; height: 420px; }

/* Seletor de ano (form GET) */
.year-filter {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 18px 0;
}
.year-filter .fb-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 700; color: var(--text-muted);
}
.year-filter select {
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 16px; padding: 6px 12px;
  font-size: 13px; cursor: pointer;
}
.year-filter select:hover { border-color: var(--accent); }

/* Grid do relatório ano-a-ano: 2 colunas, 1 no mobile */
.yoy-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .yoy-grid { grid-template-columns: 1fr; } }
.yoy-grid .card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.yoy-grid .summary { margin-top: 14px; }
.yoy-grid .summary table { font-size: 12px; }

/* Árvore drill-down (Explorar) — accordion nativo <details>/<summary> */
.tree details { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--bg-surface); }
.tree details details { border: none; border-top: 1px solid var(--border); border-radius: 0; margin-bottom: 0; background: transparent; }
.tree summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  cursor: pointer; padding: 10px 14px; list-style: none; font-size: 14px;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--text-muted); transition: transform 0.12s; }
.tree details[open] > summary::before { content: "▾"; }
.tree summary:hover { background: var(--bg-elevated); }
.tree summary .lbl { flex: 1 1 auto; }
.tree summary .amt {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--text-secondary); white-space: nowrap;
}
.tree summary .amt .cnt { color: var(--text-muted); font-size: 12px; margin-left: 8px; }
.tree .lvl-week > summary { padding-left: 30px; }
.tree .lvl-day  > summary { padding-left: 48px; }
.tree .rides { padding: 4px 14px 12px 48px; }
.tree .rides table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tree .rides td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.tree .rides td.num { font-family: ui-monospace, "SF Mono", Consolas, monospace; text-align: right; }

/* Heatmap circadiano (grid puro, sem lib) */
.heat { display: grid; grid-template-columns: 40px repeat(24, 1fr); gap: 2px; align-items: center; }
.heat .hlabel, .heat .dlabel {
  font-size: 10px; color: var(--text-muted);
  font-family: ui-monospace, "SF Mono", Consolas, monospace; text-align: center;
}
.heat .dlabel { text-align: right; padding-right: 6px; }
.heat .heat-cell {
  height: 18px; border-radius: 3px; background: var(--bg-elevated);
}
.heat .heat-cell .fill { width: 100%; height: 100%; border-radius: 3px; background: var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 11px; color: var(--text-muted); }
.heat-legend .swatch { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); }

/* Cartão de autenticação (login/signup) */
.auth-wrap { display: flex; justify-content: center; padding: 48px 24px; }
.auth-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 32px; width: 100%; max-width: 380px;
}
.auth-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.02em; }
.auth-card label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600; margin: 14px 0 6px;
}
.auth-card input {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-block; width: 100%; margin-top: 20px; cursor: pointer;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 11px 16px; font-size: 14px; font-weight: 600; transition: background 0.15s;
}
.btn:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.auth-card .alt { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mapa da corrida (#6/#3) ───────────────────────────────────────────────── */
.map-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.map-meta .chip {
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.map-card { padding: 0; overflow: hidden; }
.ride-map { width: 100%; height: 460px; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 16px;
  border-top: 1px solid var(--border); font-size: 13px; color: var(--text-secondary);
}
.map-legend .lg { display: inline-flex; align-items: center; gap: 8px; }
.map-legend .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.map-legend .dash {
  width: 22px; height: 0; border-top: 3px dashed var(--accent);
}
.map-static { margin-top: 18px; }
.static-map-img {
  display: block; max-width: 100%; height: auto; border-radius: 8px;
  border: 1px solid var(--border); margin-top: 8px;
}
