:root {
  --bg: #0a101c;
  --panel: #111a2b;
  --panel-2: #172236;
  --line: #24314a;
  --text: #f1e9da;
  --muted: #9aa6bd;
  --accent: #e8a33d;
  --accent-ink: #1b1204;
  --good: #5fcf8f;
  --hot: #ff7a59;
  --radius: 12px;
  --side: 248px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3a4a68; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.saved { border-color: var(--accent); color: var(--accent); }
.btn.danger { color: #ff9b8a; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  background: #0c1422; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; }
label { display: block; color: var(--muted); font-size: 12.5px; margin: 10px 0 4px; }
.field-row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 140px; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { margin: 14px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 14px; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 16px; padding: 10px; }
.error { color: #ff9b8a; margin-top: 10px; min-height: 1.2em; }

/* ---------- estrutura ---------- */
.layout { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: #0c1321;
  border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 16px; letter-spacing: .3px; }
.brand span { color: var(--accent); }
.nav-group { margin: 12px 8px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #cfd6e4;
}
.nav a:hover { background: var(--panel); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { font-size: 11.5px; color: var(--muted); }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.side-foot .who { font-size: 13px; }
.side-foot .who small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.side-foot .actions { display: flex; gap: 6px; margin-top: 8px; }

.main { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; background: rgba(10, 16, 28, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top form { display: flex; gap: 8px; margin-left: auto; width: min(460px, 60%); }
.menu-btn { display: none; }
.page { padding: 22px 24px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.2px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
h2 { font-size: 15px; margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .06em; color: #cfd6e4; }

/* ---------- blocos ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters > input, .filters > select { width: auto; min-width: 150px; }
.filters label { margin: 0; display: flex; gap: 6px; align-items: center; }
.accent-text { color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 12.5px;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #1e2a42; color: #cdd6e6; }
.tag.accent { background: rgba(232, 163, 61, .15); color: var(--accent); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); display: block; margin-bottom: 4px; }

/* vídeos */
.grid-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.video { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.video .thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.video .thumb img { width: 100%; height: 100%; object-fit: cover; }
.video .mult {
  position: absolute; left: 8px; top: 8px; background: var(--hot); color: #1c0700; font-weight: 800;
  border-radius: 6px; padding: 2px 7px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.video .mult.mid { background: var(--accent); color: var(--accent-ink); }
.video .mult.low { background: #2a3956; color: var(--text); }
.video .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.8); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.video .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.video .title { font-weight: 600; line-height: 1.3; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video .title:hover { color: var(--accent); }
.video .meta { color: var(--muted); font-size: 12.5px; }
.video .chan { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.video .chan img { width: 22px; height: 22px; border-radius: 50%; }
.video .chan button { background: none; border: 0; padding: 0; cursor: pointer; color: #cfd6e4; text-align: left; font-size: 12.5px; }
.video .chan button:hover { color: var(--accent); }

.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.hero .video .title { font-size: 18px; -webkit-line-clamp: 3; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; }
.list-item { display: grid; grid-template-columns: 22px 110px 1fr; gap: 10px; align-items: center; padding: 6px; border-radius: 8px; text-decoration: none; }
.list-item:hover { background: var(--panel-2); }
.list-item .pos { color: var(--muted); font-weight: 700; text-align: center; }
.list-item img { width: 110px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; }
.list-item .t { font-size: 13px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-item .m { font-size: 12px; color: var(--muted); }

/* canais */
.grid-channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.channel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.channel .head { display: flex; gap: 10px; align-items: center; }
.channel .head img { width: 44px; height: 44px; border-radius: 50%; background: #000; }
.channel .name { font-weight: 700; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; font-size: 15px; }
.channel .name:hover { color: var(--accent); }
.channel .sub { color: var(--muted); font-size: 12.5px; }
.channel .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.channel .nums div { background: #0d1525; border-radius: 8px; padding: 6px 8px; }
.channel .nums b { display: block; font-variant-numeric: tabular-nums; }
.channel .nums span { color: var(--muted); font-size: 11.5px; }
.channel .resumo { color: #cfd6e4; font-size: 13px; margin: 0; }
.channel .foot { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.channel .foot .btn { margin-left: auto; }
.rank { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: stretch; }
.rank-row .pos { font-size: 22px; font-weight: 800; color: var(--accent); display: grid; place-items: center; }

/* tabela */
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.num { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* gaveta de detalhes */
.drawer-back { position: fixed; inset: 0; background: rgba(2, 6, 14, .6); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg); border-left: 1px solid var(--line);
  z-index: 21; overflow-y: auto; padding: 20px 22px 60px;
}
.drawer .close { float: right; }
.drawer .ch-head { display: flex; gap: 14px; align-items: center; margin: 4px 0 14px; }
.drawer .ch-head img { width: 64px; height: 64px; border-radius: 50%; }
.drawer .ch-head h2 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 20px; color: var(--text); }
.spark { width: 100%; height: 70px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.box + .box { margin-top: 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.formula { padding: 14px 16px; }
.formula h3 { margin: 0 0 4px; font-size: 16px; color: var(--accent); }
.formula ul { margin: 8px 0 0; padding-left: 18px; color: #cfd6e4; }
.idea h3 { margin: 0 0 4px; font-size: 15px; }
.idea p { margin: 2px 0; color: #cfd6e4; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: #0c1422; border: 1px solid var(--accent); border-radius: 8px; padding: 10px; font-size: 16px; user-select: all; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #1d2a43; border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; display: none; max-width: 90vw;
}
#toast.show { display: block; }
#toast.err { border-color: #ff9b8a; }
.loading { color: var(--muted); padding: 30px 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; width: var(--side); transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .top { padding: 10px 14px; }
  .top form { width: auto; flex: 1; }
  .page { padding: 16px 14px 60px; }
  .hero { grid-template-columns: 1fr; }
}
