:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #14161a; --muted: #6b7280; --line: #e5e7eb;
  --side: #0f1115; --side-ink: #c9cdd4; --side-active: #1c1f26;
  --accent: #ff5a1f; --accent-ink: #ffffff; --accent-soft: #fff1eb;
  --ok: #0f9d58; --ok-soft: #e7f6ee; --warn: #b7791f; --warn-soft: #fdf5e6; --bad: #d93025; --bad-soft: #fdecea;
  --info: #2563eb; --info-soft: #eaf1fe;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e12; --panel: #14171d; --ink: #eceef2; --muted: #9aa1ad; --line: #252a33;
    --side: #08090c; --side-active: #171a21; --accent-soft: #3a1c10;
    --ok-soft: #10301f; --warn-soft: #33260e; --bad-soft: #3a1512; --info-soft: #132446;
  }
}
* { 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(--ink); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand small { display: block; font-weight: 500; color: #8b919c; font-size: 11px; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.on { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; opacity: .85; }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: #8b919c; border-top: 1px solid #1d2028; }
.side .foot button { margin-top: 8px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards / grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.two { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 3%, transparent); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-active, .b-ready, .b-ok { background: var(--ok-soft); color: var(--ok); }
.b-pending, .b-processing, .b-uploaded, .b-draft, .b-prospect { background: var(--warn-soft); color: var(--warn); }
.b-paused, .b-ended { background: var(--line); color: var(--muted); }
.b-failed, .b-rejected { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-accent { background: var(--accent-soft); color: var(--accent); }

/* Forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; } .side .foot { display: none; } .main { padding: 16px; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink); margin: 0; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.group-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .04em; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(8,10,14,.55); display: grid; place-items: start center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal { width: min(820px, 100%); background: var(--panel); border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.x { background: none; border: 0; font-size: 22px; color: var(--muted); cursor: pointer; }

/* Creatives */
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.cr .thumb { aspect-ratio: 16/9; background: #111 center/cover no-repeat; display: grid; place-items: center; color: #aaa; font-size: 12px; }
.cr .thumb.audio { background: linear-gradient(135deg, #1d2130, #2d1a12); }
.cr .meta { padding: 12px; display: grid; gap: 6px; flex: 1; }
.cr .meta .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cr .foot { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }

/* Chart */
.chart { width: 100%; height: 220px; }
.chart .bar { fill: var(--accent); }
.chart .bar2 { fill: #7a2a0c; }
@media (prefers-color-scheme: dark) { .chart .bar2 { fill: #ffc2a8; } }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Misc */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.snippet { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--panel); padding: 12px 16px; border-radius: 10px; font-weight: 500; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 380px; }
.toast.err { background: var(--bad); color: #fff; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.login .card { width: min(400px, 100%); padding: 28px; }
.login .brand { color: var(--ink); padding: 0 0 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-color: var(--accent); }
.player { background: #000; border-radius: 10px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
.player video { width: 100%; height: 100%; display: block; }
.player .ad-label { position: absolute; left: 12px; top: 12px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.log { max-height: 260px; overflow: auto; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.log div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.legend i.lg2 { background: #7a2a0c; }
@media (prefers-color-scheme: dark) { .legend i.lg2 { background: #ffc2a8; } }
