:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #15181e;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #eef2fe;
  --ok: #157f3b;  --ok-soft: #e7f6ec;
  --warn: #9a6400; --warn-soft: #fff5db;
  --bad: #b42318;  --bad-soft: #fdecea;
  --nav: #11141a; --nav-ink: #c9ced8;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #161a21; --ink: #e8eaee; --muted: #8b93a1; --line: #262c36;
    --accent: #6d8dff; --accent-soft: #1b2340; --nav: #0a0c10; --nav-ink: #aab1be;
    --ok: #4cc77b; --ok-soft: #12291c; --warn: #f0b84a; --warn-soft: #2d2410; --bad: #ff7a6e; --bad-soft: #321615;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.05rem; margin: 0 0 1rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; }

/* layout */
body.has-nav { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-ink); padding: 1.2rem .9rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.nav nav { display: flex; flex-direction: column; gap: 2px; margin-top: 1.4rem; flex: 1; }
.nav nav a { color: var(--nav-ink); padding: .5rem .7rem; border-radius: 7px; }
.nav nav a:hover { background: #ffffff10; text-decoration: none; color: #fff; }
.nav nav a.on { background: #ffffff18; color: #fff; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin: 1rem .7rem .3rem; }
.nav-foot { border-top: 1px solid #ffffff14; padding-top: .9rem; font-size: .85rem; }
.nav-foot .who { display: flex; flex-direction: column; margin-bottom: .4rem; }
.nav-foot .who span { color: #7d8594; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff; font-size: 1.05rem; padding: 0 .4rem; }
.brand:hover { text-decoration: none; }
.brand.big { color: var(--ink); font-size: 1.2rem; padding: 0; margin-bottom: 1.4rem; }
.mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .9rem; }
.main { padding: 1.8rem 2.2rem 4rem; max-width: 1280px; width: 100%; }
body.bare .main { max-width: none; padding: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; margin-bottom: .3rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.grid-2 > .card { margin-bottom: 0; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem 1.4rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow-x: auto; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pad { padding: 1.2rem 1.4rem 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; display: flex; flex-direction: column; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile span { color: var(--muted); font-size: .85rem; }
.tile strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.tile.accent { background: var(--accent-soft); border-color: transparent; }
.empty { text-align: center; padding: 3.5rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.center-card { max-width: 460px; margin: 12vh auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.card:not(.flush) .table th, .card:not(.flush) .table td { padding-left: 0; }

/* key-value */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; }
.kv .url { word-break: break-all; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }

/* badges */
.badge, .chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; vertical-align: middle; }
.chip { font-weight: 500; }
.s-active, .s-live, .s-approved, .s-completed { background: var(--ok-soft); color: var(--ok); }
.s-pending_review, .s-publishing, .s-queued, .s-dry_run { background: var(--accent-soft); color: var(--accent); }
.s-paused, .s-draft { background: var(--warn-soft); color: var(--warn); }
.s-rejected, .s-failed { background: var(--bad-soft); color: var(--bad); }

/* banners */
.banner { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--accent-soft); }
.banner.success { background: var(--ok-soft); color: var(--ok); }
.banner.error { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 500; margin-bottom: .9rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input.short { max-width: 110px; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > label { flex: 0 1 180px; }
.row > label.grow { flex: 1 1 260px; }
.stack { display: flex; flex-direction: column; }
.err { color: var(--bad); font-size: .82rem; font-weight: 500; }
ul.err { padding-left: 1.2rem; }
.form-grid { max-width: 920px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.check { flex-direction: row; align-items: flex-start; gap: .7rem; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; margin: 0; cursor: pointer; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { width: auto; margin-top: .2rem; }
.check span { display: flex; flex-direction: column; }
label.inline { flex-direction: row; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: .7rem; }
.money-input { display: flex; align-items: center; gap: .5rem; white-space: nowrap; color: var(--muted); }
.money-input input { width: 120px; text-align: right; }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 1rem; }
.filters { display: flex; gap: .5rem; }
.filters input { width: 220px; }
.filters select { width: 170px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .3rem .65rem; font-size: .8rem; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--nav-ink); cursor: pointer; font: inherit; text-decoration: underline; }
.link.danger { color: var(--bad); font-size: .8rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 1rem 0; justify-content: flex-end; border-top: 1px solid var(--line); }

/* creatives */
.creatives { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-bottom: .8rem; }
.creatives figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.creatives img, .creatives video { width: 100%; height: 130px; object-fit: contain; display: block; background: repeating-conic-gradient(#8881 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.creatives figcaption { font-size: .78rem; padding: .4rem .55rem; display: flex; justify-content: space-between; color: var(--muted); }

/* misc */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border: 0; }
details { border: 1px solid var(--line); border-radius: 8px; padding: .7rem 1rem; margin-bottom: .7rem; }
summary { cursor: pointer; display: flex; gap: .6rem; align-items: center; }
pre.code { background: var(--bg); padding: 1rem; border-radius: 8px; overflow: auto; max-height: 420px; font-size: .78rem; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; }
.auth-card h1 { margin-bottom: 1.2rem; }

@media (max-width: 860px) {
  body.has-nav { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; }
  .nav nav { flex-direction: row; flex-wrap: wrap; margin-top: .8rem; }
  .nav-label { display: none; }
  .main { padding: 1.2rem 1rem 3rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dd { margin-bottom: .5rem; }
}

/* ---------- reporting ---------- */
:root { --c1: #2f5bea; --c2: #c4cad6; }
@media (prefers-color-scheme: dark) { :root { --c1: #6d8dff; --c2: #48505e; } }
h2.section { margin: 1.6rem 0 .7rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tile small { margin-top: .1rem; }
.tile.neg strong, td.neg { color: var(--bad); }
.table.num td:not(:first-child), .table.num th:not(:first-child), .table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.chart svg { width: 100%; height: 220px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart rect.c1, .legend i.c1 { fill: var(--c1); background: var(--c1); }
.chart rect.c2, .legend i.c2 { fill: var(--c2); background: var(--c2); }
.chart rect:hover { opacity: .75; }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-bottom: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; }
.budget { display: grid; grid-template-columns: auto 1fr auto; gap: 1.2rem; align-items: center; }
.budget strong { display: block; font-size: 1.25rem; }
.budget-meter { width: 100%; height: 12px; }
.inline-form { display: flex; gap: .7rem; align-items: flex-end; margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.inline-form label { margin: 0; flex: 0 0 200px; }
pre.code.wrap { white-space: pre-wrap; word-break: break-all; max-height: none; }
@media (max-width: 860px) { .budget { grid-template-columns: 1fr; gap: .5rem; } }

.steps { padding-left: 1.2rem; margin: .4rem 0; }
.steps li { margin-bottom: .3rem; }

/* ---------- brand logo ---------- */
.brand.has-logo { padding: 0; }
.brand-logo { display: block; max-height: 34px; max-width: 180px; width: auto; height: auto; object-fit: contain; }
.nav .brand.has-logo { background: #fff; border-radius: 8px; padding: 7px 10px; align-self: flex-start; }
.brand.big .brand-logo { max-height: 48px; max-width: 240px; }
