:root {
  --surface-0: #f3f3f1;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --series-1: #2a78d6;
  --series-1-hover: #1d5fae;
  --critical: #d03b3b;
  --critical-bg: #fdeceb;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2c;
    --grid: #262624;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --series-1: #3987e5;
    --series-1-hover: #6aa6ee;
    --critical: #f07070;
    --critical-bg: #3a1d1c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--series-1); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 15px; }
.muted { color: var(--text-muted); font-size: 12px; }

/* Barra do topo */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.topbar .muted { display: block; margin-top: 2px; }
.user-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-menu .who { color: var(--text-secondary); margin-right: 4px; }
.user-menu .tag { font-size: 11px; font-weight: 600; color: var(--series-1); border: 1px solid var(--series-1); border-radius: 999px; padding: 0 7px; margin-left: 4px; }

/* Formulários e botões */
input, select, button {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 36px;
}
select { min-width: 200px; max-width: 100%; }
button { cursor: pointer; }
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
button.primary:hover { background: var(--series-1-hover); }
button.danger { color: var(--critical); }
button.link { border: 0; background: none; color: var(--series-1); padding: 4px 6px; min-height: 0; }
button:disabled { opacity: .5; cursor: default; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.field input:not([type=checkbox]):not([type=radio]), .field select { width: 100%; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding: 16px; margin-bottom: 16px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
}
.filters label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.filters #evento { min-width: 280px; }
.actions { display: flex; gap: 8px; margin-left: auto; }

/* Cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--text-muted); }
.tile.top { border-color: var(--series-1); box-shadow: inset 0 3px 0 var(--series-1); }
.tile .badge { float: right; font-size: 11px; font-weight: 600; color: var(--series-1); }
.tile .breakdown { font-size: 12px; color: var(--text-secondary); margin-top: 6px; font-variant-numeric: tabular-nums; }
.section-title { margin: 0 0 8px; font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }

.info {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 4px; vertical-align: -3px; border-radius: 50%;
  border: 1px solid var(--text-muted); color: var(--text-secondary);
  font: italic 600 11px/1 Georgia, serif; cursor: help;
}
.info-tip {
  display: none; position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); z-index: 10;
  width: 260px; padding: 8px 10px; border-radius: 6px; background: var(--text-primary); color: var(--surface-1);
  font: 12px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: left;
}
.info:hover .info-tip, .info:focus .info-tip { display: block; }

/* Gráficos */
.charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 820px) { .charts { grid-template-columns: 1fr; } .actions { margin-left: 0; } .filters #evento { min-width: 0; width: 100%; } }
.size-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 8px; margin-bottom: 10px; }
.size-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.size-track { height: 14px; }
.size-bar { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.size-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.daily { position: relative; }
.daily svg { display: block; width: 100%; height: 220px; overflow: visible; }
.daily .bar { fill: var(--series-1); }
.daily .bar.active { fill: var(--series-1-hover); }
.daily .axis { fill: var(--text-muted); font-size: 11px; }
.daily .gridline { stroke: var(--grid); }
.tooltip {
  position: absolute; pointer-events: none; padding: 6px 10px; border-radius: 6px; font-size: 12px;
  background: var(--text-primary); color: var(--surface-1); white-space: nowrap; transform: translate(-50%, -100%);
  display: none;
}

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap-text { white-space: normal; min-width: 220px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--series-1); font-weight: 600; font-size: 12px; }
.state { padding: 32px; text-align: center; color: var(--text-secondary); }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding-top: 12px; }
.pager select { min-width: 0; margin-left: 6px; }
.pager-buttons { display: flex; align-items: center; gap: 6px; margin-left: auto; font-variant-numeric: tabular-nums; }
.pager-buttons span { padding: 0 6px; color: var(--text-secondary); white-space: nowrap; }

.error { padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius); background: var(--critical-bg); color: var(--text-primary); border: 1px solid var(--critical); }
.error strong { color: var(--critical); }
.form-error { color: var(--critical); font-size: 13px; margin: 0 0 12px; }

/* Janelas (trocar senha, editar usuário) */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 20px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); color: var(--text-primary);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { font-size: 17px; margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); }
.login-card h1 { margin-bottom: 4px; }
.login-card p.muted { margin: 0 0 20px; font-size: 13px; }
.login-card button.primary { width: 100%; margin-top: 4px; }
.login-card .forgot { text-align: center; margin: 12px 0 0; }
.form-ok { color: var(--text-primary); background: var(--surface-0); border-left: 3px solid var(--series-1); padding: 8px 10px; font-size: 13px; margin: 0 0 12px; }
select.compact { min-width: 150px; }

/* Indicador "Ao vivo" */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--series-1); animation: pulse 2s ease-in-out infinite; }
.live.news #ao-vivo-texto::after { content: " · " attr(data-news); color: var(--series-1); font-weight: 600; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
