/* =========================================================================
   Dashboard Tráfego Pago — Espaço Restaurante — estilos
   Mesma paleta/tokens do Dashboard do Restaurante (dataviz/references/
   palette.md) e do painel de tráfego da Cúpula, para os painéis lerem
   como um sistema só.
   ========================================================================= */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --surface-2:      #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid-line:      #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --series-1: #2a78d6; /* azul    */
  --series-2: #eb6834; /* laranja */
  --series-3: #1baf7a; /* agua    */
  --series-4: #eda100; /* amarelo */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* verde   */
  --series-7: #4a3aa7; /* violeta */
  --series-8: #e34948; /* vermelho*/

  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --success-text: #006300;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11,11,11,0.06), 0 1px 8px rgba(11,11,11,0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid-line: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
    --series-7: #9085e9; --series-8: #e66767;

    --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #e66767;
    --success-text: #0ca30c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: 48px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.app-header h1 { font-size: 18px; font-weight: 600; margin: 0; white-space: nowrap; }
.app-header .subtitle { font-size: 12px; color: var(--text-muted); }

.header-controls { margin-left: auto; display: flex; align-items: center; gap: 10px; }

select {
  font: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 7px 10px;
}

.btn-atualizar {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: var(--series-1);
  color: white;
  border: 1px solid var(--series-1);
  font-weight: 600;
}
.btn-atualizar:hover { filter: brightness(1.08); }
.btn-atualizar:disabled { opacity: 0.6; cursor: wait; }

main { padding: 20px; max-width: 1360px; margin: 0 auto; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--series-1));
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat-tile .label { font-size: 12.5px; color: var(--text-secondary); }
.stat-tile .value { font-size: 26px; font-weight: 600; line-height: 1.15; }
.stat-tile .value.small { font-size: 19px; }
.stat-tile .sub { font-size: 12px; color: var(--text-muted); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 4px; }
.card .card-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
}

.mini-chart-card { display: flex; flex-direction: column; gap: 6px; }
.mini-chart-card .mini-title { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { fill: var(--text-secondary); font-size: 11px; }
svg.chart .muted { fill: var(--text-muted); }
svg.chart .grid { stroke: var(--grid-line); stroke-width: 1; }
svg.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
svg.chart .value-label { fill: var(--text-primary); font-size: 12px; font-weight: 600; }

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 6px;
  line-height: 1.4;
  z-index: 100;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .08s ease;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip b { font-weight: 600; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid-line);
}
table.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .02em;
}
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table.zebra tbody tr:nth-child(even) { background: var(--surface-2); }
table.data-table tbody tr:hover { background: color-mix(in srgb, var(--series-1) 12%, transparent); }
table.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--baseline);
  border-bottom: none;
}

.scroll-x { overflow-x: auto; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.warnings-box {
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 10%, var(--surface-1));
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
}
.warnings-box strong { color: var(--text-primary); }

footer.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px;
}
