:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --ink: #16171b;
  --muted: #6b6d75;
  --line: #e6e4dc;
  --accent: #4f35e8;
  --accent-soft: #eeebff;
  --good: #0c8a5f;
  --good-soft: #e3f5ed;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --bad: #c8312b;
  --bad-soft: #fde8e6;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* header */
.top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 20px 28px 12px; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.tag { margin: 0; color: var(--muted); font-size: 13px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 8px; }
.logo span { width: 5px; border-radius: 2px; background: #fff; }
.logo span:nth-child(1) { height: 8px; opacity: .55; }
.logo span:nth-child(2) { height: 13px; opacity: .8; }
.logo span:nth-child(3) { height: 19px; background: #a99cff; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.badge.live { background: var(--good-soft); color: var(--good); }
.day { font-weight: 700; padding: 0 6px; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 10px; font-weight: 600; }
.btn:hover { border-color: #c9c6bb; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2c2d33; }
.btn.ghost { background: transparent; }
.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.bad { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: progress; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 0 28px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.view { padding: 20px 28px 40px; max-width: 1320px; margin: 0 auto; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.meter { height: 6px; background: #eeece5; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
.meter.hot > i { background: var(--warn); }

/* layout */
.grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.card-h h2 { margin: 0; font-size: 15px; }
.hint { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 10px 0; font-size: 13px; }

/* queue */
.req { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.req:last-child { margin-bottom: 0; }
.req.held { border-color: #f3b8b3; background: var(--bad-soft); }
.req-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.req-title { font-weight: 650; }
.req-amt { font-weight: 700; white-space: nowrap; }
.req-why { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.req-flag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--bad); margin: 4px 0 2px; }
.req-actions { display: flex; gap: 6px; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.pill.payout { background: var(--accent-soft); color: var(--accent); }
.pill.shift, .pill.boost { background: #eef2f6; color: #3b4a5c; }
.pill.held { background: #fff; color: var(--bad); border: 1px solid #f3b8b3; }

/* SERV review */
.badge.serv { background: #e9f3ff; color: #1d5fbf; }
.serv-box { border: 1px solid #cfe0f7; background: #f4f8fe; border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; font-size: 12.5px; }
.serv-box.running { color: #1d5fbf; }
.serv-box.v-approve { border-color: #bfe5d3; background: #f1faf6; }
.serv-box.v-hold { border-color: #f3d7a8; background: #fef8ee; }
.serv-box.v-reject { border-color: #f3b8b3; background: #fdf1f0; }
.serv-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.serv-tag { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #1d5fbf; margin-right: 4px; }
.serv-conf { color: var(--muted); margin-left: auto; }
.serv-sum { margin-top: 6px; }
.serv-box ul { margin: 6px 0 0; padding-left: 18px; color: #3b3d44; }
.serv-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.serv-flags span { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; font-size: 11px; }
.serv-meta { color: var(--muted); font-size: 11px; margin-top: 6px; font-family: var(--mono); }
.actor-serv { background: #e9f3ff; color: #1d5fbf; }

/* campaigns */
.camp { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 72px 90px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.camp:first-child { border-top: 0; }
.camp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camp-plat { color: var(--muted); font-size: 12px; }
.bar { height: 8px; background: #eeece5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .4s; }
.camp-budget { font-size: 12px; color: var(--muted); margin-top: 4px; }
.roas { font-weight: 700; text-align: right; }
.roas.up { color: var(--good); }
.roas.down { color: var(--bad); }
.spark { width: 90px; height: 28px; }

/* policy */
.policy { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.policy label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.policy input { font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf7; font-variant-numeric: tabular-nums; }
.policy input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* demo */
.demo-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.demo-row:first-child { border-top: 0; }
.demo-row .who { font-weight: 600; }
.demo-row .who small { display: block; color: var(--muted); font-weight: 500; }
.demo-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* audit */
.log-card { position: sticky; top: 12px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.audit { list-style: none; margin: 0; padding: 0; max-height: 78vh; overflow: auto; }
.entry { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.actor { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 0; border-radius: 6px; text-align: center; height: fit-content; }
.actor-agent { background: var(--accent-soft); color: var(--accent); }
.actor-policy { background: var(--warn-soft); color: var(--warn); }
.actor-human { background: var(--good-soft); color: var(--good); }
.actor-system { background: #eef0f3; color: #59606b; }
.entry-title { font-weight: 600; }
.entry-detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-word; }
.entry-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.tx { font-family: var(--mono); background: #f1f0eb; padding: 1px 6px; border-radius: 5px; color: var(--ink); }
.undone { text-decoration: line-through; }

/* creator view */
.creator-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ccard { max-width: 760px; }
.c-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.c-head h2 { margin: 0; font-size: 20px; }
.c-head p { margin: 0; color: var(--muted); }
.earn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.progress-wrap { position: relative; margin: 26px 0 34px; }
.progress { height: 14px; background: #eeece5; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8f7dff); border-radius: 99px; transition: width .5s; }
.mark { position: absolute; top: -22px; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.mark::after { content: ""; position: absolute; left: 50%; top: 18px; width: 2px; height: 22px; background: #c9c6bb; }
.mark.hit { color: var(--accent); }
.tiers { width: 100%; border-collapse: collapse; }
.tiers td { padding: 10px 0; border-top: 1px solid var(--line); }
.tiers td:last-child { text-align: right; }
.status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.status.paid { background: var(--good-soft); color: var(--good); }
.status.pending { background: var(--accent-soft); color: var(--accent); }
.status.review { background: var(--bad-soft); color: var(--bad); }
.status.locked { background: #eeece5; color: var(--muted); }
.next-note { background: var(--accent-soft); color: #2e1fa3; border-radius: 12px; padding: 12px 14px; font-weight: 600; margin-bottom: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .log-card { position: static; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .top, .view { padding-left: 14px; padding-right: 14px; }
  .tabs { padding: 0 14px; }
  .camp { grid-template-columns: 1fr 70px; }
  .camp .bar-cell, .camp .spark { display: none; }
  .earn { grid-template-columns: 1fr; }
  .kpi .value { font-size: 22px; }
}
