:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --border: #e3e5df;
  --text: #11151a;
  --text-2: #4f5761;
  --muted: #8a929b;
  --brand: #c6ff3d;
  --brand-ink: #0b0f14;
  --side: #0b0f14;
  --side-text: #c7ced6;
  --side-active: #1a222c;
  --primary: #1f6feb;
  --danger: #d1242f;
  --danger-bg: #fdecec;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --ok: #1a7f37;
  --ok-bg: #e6f6ea;
  --info-bg: #e8f0fe;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #eceee9;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 16px rgba(16, 24, 32, .04);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1116; --surface: #151b22; --surface-2: #1b222b; --border: #26303b; --text: #eef2f6; --text-2: #b4bec8; --muted: #7d8894;
    --side: #080b0f; --side-active: #18202a; --primary: #4c8df6; --danger: #f06b6b; --danger-bg: #3a1a1c; --warn: #f0a640; --warn-bg: #3a2a12;
    --ok: #4cc472; --ok-bg: #15301e; --info-bg: #182638; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #222b35;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1116; --surface: #151b22; --surface-2: #1b222b; --border: #26303b; --text: #eef2f6; --text-2: #b4bec8; --muted: #7d8894;
  --side: #080b0f; --side-active: #18202a; --primary: #4c8df6; --danger: #f06b6b; --danger-bg: #3a1a1c; --warn: #f0a640; --warn-bg: #3a2a12;
  --ok: #4cc472; --ok-bg: #15301e; --info-bg: #182638; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #222b35;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; padding: 4px 10px 18px; letter-spacing: .2px; }
.logo i { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.logo i::after { content: ""; border-left: 10px solid var(--brand-ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent; margin-left: 3px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 12px; border-radius: 8px; margin: 1px 0; font-weight: 500; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav .badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5f6b77; padding: 14px 12px 4px; }
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; border-top: 1px solid #1d252f; }
.side-foot b { color: #fff; display: block; }
.side-foot button { margin-top: 8px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .main { padding: 16px; }
  .menu-btn { display: inline-flex; }
}

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.kpi { padding: 14px 16px; }
.kpi .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.side .btn { background: transparent; color: var(--side-text); border-color: #26303b; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
label.f .help { font-weight: 400; color: var(--muted); font-size: 12px; }
label.chk { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.r, th.r { text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--primary); }
.pill.neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--text); }

.alert { border-radius: 10px; padding: 12px 14px; border: 1px solid var(--border); background: var(--surface-2); }
.alert.warn { background: var(--warn-bg); border-color: transparent; color: var(--text); }
.alert.bad { background: var(--danger-bg); border-color: transparent; }
.alert.info { background: var(--info-bg); border-color: transparent; }
.alert.ok { background: var(--ok-bg); border-color: transparent; }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; word-break: break-all; }

/* Vídeos */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.vcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.vcard .thumb { aspect-ratio: 9/16; background: #000 center/cover no-repeat; position: relative; cursor: pointer; }
.vcard .thumb .tag { position: absolute; left: 8px; top: 8px; }
.vcard .meta { padding: 8px 10px; font-size: 12px; }
.vcard .meta b { display: block; font-size: 13px; }
.vcard .acts { display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap; }

/* Denúncias */
.report { display: grid; grid-template-columns: 120px 1fr; gap: 14px; }
.report .prev { aspect-ratio: 9/16; background: #000 center/cover; border-radius: 10px; cursor: pointer; }
@media (max-width: 600px) { .report { grid-template-columns: 80px 1fr; } }

/* Modal e toast */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 8, 12, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; margin-bottom: 14px; gap: 10px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 10px; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; }
.toast.bad { background: var(--danger); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 16px; }
.login .card { width: min(380px, 100%); }
.login .logo { color: var(--text); padding: 0 0 18px; }

/* Gráficos */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); }
.chart .tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); border-radius: 8px; padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s; z-index: 2; }
.chart .tip b { font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 110px 1fr 54px; gap: 10px; align-items: center; margin: 7px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.funnel-step { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; margin: 8px 0; }
.funnel-step .bar { height: 26px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }

.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.qr-card .qr { display: grid; place-items: center; margin: 8px auto; min-height: 160px; }

@media print {
  .side, .page-head .btn, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* Cadastro da arena com prévia ao lado */
.arena-edit { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.arena-preview { position: sticky; top: 16px; }
@media (max-width: 1100px) { .arena-edit { grid-template-columns: 1fr; } .arena-preview { position: static; order: -1; } }
