:root {
  --ground: #eff3f5;
  --surface: #fff;
  --surface-2: #f7fafb;
  --ink: #101820;
  --ink-soft: #566672;
  --ink-faint: #8496a1;
  --rule: #d6e0e5;
  --accent: #0e6e7d;
  --accent-ink: #fff;
  --accent-soft: #dceef1;
  --ok: #1f7a55;
  --ok-bg: #ddf0e7;
  --warn: #8a5a00;
  --warn-bg: #f6ebd5;
  --danger: #a3242b;
  --danger-bg: #f7e0e1;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c1216;
    --surface: #131c22;
    --surface-2: #18232a;
    --ink: #e6eef2;
    --ink-soft: #9db0ba;
    --ink-faint: #6e828e;
    --rule: #26343c;
    --accent: #3fb6c9;
    --accent-ink: #08181c;
    --accent-soft: #10323a;
    --ok: #55c795;
    --ok-bg: #10322a;
    --warn: #d6a343;
    --warn-bg: #33280f;
    --danger: #e88a8f;
    --danger-bg: #351a1c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

/* topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--rule); }
/* Header and page content share this width and must stay equal — a wider
   header overhangs the content below it and the brand stops lining up with the
   first column of the page. */
.bar {
  max-width: 1080px; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; gap: 26px; min-height: 72px; flex-wrap: wrap;
}
.brand { font-family: var(--mono); font-weight: 600; text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.bar nav { display: flex; gap: 20px; margin-right: auto; flex-wrap: wrap; }
/* Vertical padding is derived from the bar height, not picked independently:
   the nav link's own box is what the current-page underline sits on, so if it
   is shorter than the bar the underline floats mid-header instead of resting on
   the bottom edge. 25 + ~22 line box + 25 fills the 72px bar. */
.bar nav a {
  text-decoration: none; color: var(--ink-soft); font-size: 14px;
  padding: 25px 0; border-bottom: 2px solid transparent;
}
.bar nav a:hover { color: var(--ink); }
.bar nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.signout { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--ink-faint); }
.signout button {
  background: none; border: 1px solid var(--rule); color: var(--ink-soft);
  padding: 5px 11px; border-radius: 3px; font: inherit; font-size: 13px; cursor: pointer;
}
.signout button:hover { color: var(--ink); border-color: var(--ink-faint); }

/* layout */
main.app { max-width: 1080px; margin: 0 auto; padding: 34px 22px 80px; }
/* The sign-in / sign-up card stays narrow on purpose — a login form stretched
   across a wide monitor is harder to read, not easier. */
main.auth { max-width: 460px; margin: 0 auto; padding: 72px 22px 80px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
h1 { font-size: 25px; letter-spacing: -.02em; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin: 34px 0 12px; }
.sub { color: var(--ink-soft); margin: 0 0 22px; }
.hint { color: var(--ink-faint); font-size: 13px; margin: 8px 0 0; }
.dim { color: var(--ink-faint); }
.mono { font-family: var(--mono); font-size: 12.5px; }
td .mono { display: block; }

/* cards + forms */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; padding: 26px 26px 30px; }
.card.narrow h1 { margin-bottom: 6px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 5px; }
input, select {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: 3px;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
fieldset { border: 1px solid var(--rule); border-radius: 4px; padding: 4px 16px 16px; margin: 22px 0 0; }
legend { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); padding: 0 6px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 26px; }

button.primary, .btn.primary {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  padding: 9px 17px; border-radius: 3px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary { width: 100%; margin-top: 22px; }
.actions button.primary, .head .btn.primary { width: auto; margin-top: 0; }
.btn.ghost { color: var(--ink-soft); text-decoration: none; padding: 9px 14px; border: 1px solid var(--rule); border-radius: 3px; }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink-faint); }
.foot { margin: 20px 0 0; font-size: 14px; color: var(--ink-soft); }

/* The other way in. A plain inline link here reads as fine print and gets
   scanned past — this needs to look like an action, because for a first-time
   visitor it is the only one that matters. */
.alt-action {
  margin: 26px 0 0; padding-top: 22px; border-top: 1px solid var(--rule);
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: center;
}
.alt-action span { font-size: 14px; color: var(--ink-soft); }
.btn.ghost.block { display: block; text-align: center; font-weight: 600; color: var(--accent); border-color: var(--accent); }
.btn.ghost.block:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 26px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; padding: 16px 18px; display: flex; flex-direction: column; gap: 3px; }
.tile .n { font-family: var(--mono); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile .l { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }

/* tables */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 5px; }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 11px 15px; border-bottom: 1px solid var(--rule); font-size: 14px; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* chips */
.chip { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding: 3px 8px; border-radius: 3px; background: var(--surface-2); color: var(--ink-soft); }
.s-live { background: var(--ok-bg); color: var(--ok); }
.s-draft, .s-review { background: var(--warn-bg); color: var(--warn); }
.s-paused, .s-offline { background: var(--danger-bg); color: var(--danger); }

/* messages */
.alert { padding: 11px 15px; border-radius: 4px; margin-bottom: 20px; font-size: 14px; border: 1px solid; }
.alert.error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert.notice { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.empty-note { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 4px; padding: 14px 17px; margin-bottom: 24px; font-size: 14px; color: var(--ink); }
.empty-note strong { display: block; margin-bottom: 3px; }
.blank { background: var(--surface); border: 1px dashed var(--rule); border-radius: 5px; padding: 40px 24px; text-align: center; }
.blank p { margin: 0 0 14px; color: var(--ink-soft); }

/* ---- ops review tool ---- */

/* The staff header is visually distinct on purpose. This side shows every
   host's inventory, and it should never be mistaken for your own account. */
.topbar.ops { background: var(--ink); border-bottom-color: var(--ink); }
.topbar.ops .brand,
.topbar.ops nav a.on { color: var(--surface); }
.topbar.ops .brand span { color: var(--accent); }
.topbar.ops .brand em {
  font-style: normal; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ground); opacity: .65; margin-left: 4px;
}
.topbar.ops nav a { color: var(--ink-faint); }
.topbar.ops nav a:hover { color: var(--surface); }
.topbar.ops .who { color: var(--ink-faint); }
.topbar.ops .signout button { color: var(--ink-faint); border-color: var(--ink-soft); background: none; }
.topbar.ops .signout button:hover { color: var(--surface); border-color: var(--ground); }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px;
  background: var(--accent); color: var(--accent-ink); border-radius: 9px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; text-align: center;
}

.review {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 5px;
  padding: 18px 20px; margin-bottom: 14px;
}
.review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.review-title { font-size: 17px; margin: 0; text-transform: none; letter-spacing: -.01em; color: var(--ink); }
.review-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 18px; margin: 16px 0 0;
}
.facts div { margin: 0; }
.facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.facts dd { margin: 2px 0 0; font-size: 14px; }

.prior-note {
  margin: 14px 0 0; padding: 9px 12px; font-size: 13px;
  background: var(--warn-bg); color: var(--warn); border-radius: 3px;
}

.review-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule);
}
.review-actions input { flex: 1 1 260px; width: auto; }
.review-actions .btns { display: flex; gap: 8px; }
.review-actions button { margin-top: 0; width: auto; white-space: nowrap; }
button.danger {
  background: none; color: var(--danger); border: 1px solid var(--danger);
  padding: 9px 15px; border-radius: 3px; font: inherit; font-weight: 600; cursor: pointer;
}
button.danger:hover { background: var(--danger-bg); }

/* Host-side: the reviewer's note, shown verbatim to the host. */
.review-back {
  margin: 4px 0 0; padding: 8px 11px; font-size: 13px;
  background: var(--warn-bg); color: var(--warn); border-radius: 3px;
}

/* Advertiser header — the buy side. Distinct from the host portal's white and
   the staff tool's dark, so it is obvious which side of the marketplace you
   are looking at. */
.topbar.adv { background: var(--accent-soft); border-bottom-color: var(--accent); }
.topbar.adv .brand em {
  font-style: normal; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-left: 4px;
}
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.filters label { margin: 0 0 4px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters button { margin-top: 0; width: auto; }
.side-by-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.booknav { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-top: 16px; }
.booknav > div { flex: 1 1 130px; }
.booknav label { margin-top: 0; }
td input[type="checkbox"] { width: auto; }

/* The creative's URL. Shown as text plus a deliberate link rather than an
   embedded <img>/<video>: the URL is advertiser-supplied, and the review tool
   should not fetch arbitrary remote content the moment a reviewer opens the
   queue. A reviewer clicks through when they mean to. */
.media-link {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  margin: 14px 0 0; padding: 9px 12px; background: var(--surface-2);
  border-radius: 3px; word-break: break-all;
}
.media-link a { white-space: nowrap; }

/* The resolved loop. Ads and host slots are visually distinct so a reviewer can
   see at a glance whether the loop is an ad break or a spread. */
.loop { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.loop-slot {
  flex: 1 1 140px; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 4px; border: 1px solid var(--rule);
  background: var(--surface-2);
}
.loop-slot.ad { background: var(--accent-soft); border-color: var(--accent); }
.loop-slot .i { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.loop-slot .k { font-weight: 600; font-size: 13px; }
.loop-slot.ad .k { color: var(--accent); }
.loop-slot .d { font-size: 11.5px; color: var(--ink-soft); word-break: break-all; }

/* ---- screen map ---- */
.map {
  height: 340px; margin-bottom: 20px; border-radius: 5px;
  border: 1px solid var(--rule); background: var(--surface-2);
  /* Leaflet paints its own tiles; without this the container's own corners
     poke out past the rounded border. */
  overflow: hidden;
}
.map-empty {
  display: flex; align-items: center; justify-content: center;
  height: 120px; color: var(--ink-faint); font-size: 14px;
  border-style: dashed;
}
/* Leaflet's popup is a white card by default, which is unreadable on a dark
   ground. Take the page's own surface tokens instead. */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.leaflet-popup-content { font-family: var(--sans); font-size: 13px; line-height: 1.5; }
.leaflet-popup-content a { color: var(--accent); font-weight: 600; }
.leaflet-container { background: var(--surface-2); font-family: var(--sans); }
.leaflet-control-attribution { background: var(--surface) !important; color: var(--ink-faint); }
.leaflet-control-attribution a { color: var(--ink-soft); }

/* A row picked from the map, so the table agrees with the pins. */
tr.picked td { background: var(--accent-soft); }

/* Edit affordance on the screens list. Quiet until hovered — the status is the
   thing being scanned, the action is what you reach for once you've found the row. */
.edit-link { display: block; margin-top: 5px; font-size: 12px; color: var(--ink-faint); text-decoration: none; }
.edit-link:hover { color: var(--accent); text-decoration: underline; }

/* Retiring a screen is a POST, so it needs a form — but it sits in a row of
   links and should read as one, not as a button competing with them. */
.inline-form { display: inline; margin: 0; }
.link-button {
  display: block; margin-top: 5px; padding: 0;
  font: inherit; font-size: 12px;
  background: none; border: 0; cursor: pointer;
  color: var(--ink-faint); text-decoration: none;
}
.link-button:hover { color: var(--danger, #b3261e); text-decoration: underline; }
