/*
 * Variant A — "Ledger". Tokens and component vocabulary lifted verbatim from
 * the approved mock (prototype/dashboard-mock.html, ?variant=A).
 *
 * Only what the empty shell needs is here. Later tickets add table, stat, bar,
 * pill and form rules as their screens arrive — extend this file, do not fork it.
 */

:root {
  --paper: #f5f7f3;
  --surface: #ffffff;
  --surface2: #edf1ec;
  --line: #d5dcd6;
  --line2: #e5eae5;
  --ink: #182320;
  --ink2: #46524d;
  --muted: #6c7772;
  --accent: #1e6b58;
  --accent-ink: #ffffff;
  --accent-soft: #ddeee7;
  --ok: #0f7f5e;
  --ok-soft: #d7efe4;
  --pending: #a8820f;
  --pending-soft: #f5ebc9;
  --bad: #b0433b;
  --bad-soft: #f6dedc;
  --sub: #b3521a;
  --sub-soft: #fbe7da;
  --logo-tile: #e4ece7;
  --shadow: 0 1px 2px rgba(24, 35, 32, 0.06), 0 8px 24px rgba(24, 35, 32, 0.08);
}

/* Defined twice, identically, so an explicit toggle wins in both directions. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111614;
    --surface: #181e1b;
    --surface2: #1f2622;
    --line: #2c3531;
    --line2: #242c28;
    --ink: #e4e9e5;
    --ink2: #b4bdb8;
    --muted: #8b958f;
    --accent: #3fae8b;
    --accent-ink: #0b120f;
    --accent-soft: #1b3a31;
    --ok: #2a9e78;
    --ok-soft: #173a2e;
    --pending: #cc9a2c;
    --pending-soft: #3a3116;
    --bad: #d4675f;
    --bad-soft: #3d1f1d;
    --sub: #e38a5a;
    --sub-soft: #3d2416;
    --logo-tile: #eef2ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --paper: #111614;
  --surface: #181e1b;
  --surface2: #1f2622;
  --line: #2c3531;
  --line2: #242c28;
  --ink: #e4e9e5;
  --ink2: #b4bdb8;
  --muted: #8b958f;
  --accent: #3fae8b;
  --accent-ink: #0b120f;
  --accent-soft: #1b3a31;
  --ok: #2a9e78;
  --ok-soft: #173a2e;
  --pending: #cc9a2c;
  --pending-soft: #3a3116;
  --bad: #d4675f;
  --bad-soft: #3d1f1d;
  --sub: #e38a5a;
  --sub-soft: #3d2416;
  --logo-tile: #eef2ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.45 "IBM Plex Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

:where(a, button, input, select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Shell ------------------------------------------------------------- */
/*
 * #59 (part of #52): the sidebar has two widths and the main column has none.
 * `<html data-sidebar="open|rail">` is written before first paint by the inline
 * script in src/ui/layout.ts, so the fold a browser remembers is already
 * decided when the first frame is drawn and nothing jumps.
 */

:root {
  --side-w: 220px;
}

:root[data-sidebar="rail"] {
  --side-w: 56px;
}

.vA {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}

.vA .side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/*
 * `min-width: 0` is the whole of the window fit. A grid track's default minimum
 * is the widest thing inside it, so one wide table used to push the column —
 * and the page — past the window, which is what a PM with tabs docked on the
 * side kept seeing. With a zero minimum the column is the window's width and
 * the table scrolls inside its own `.tablewrap`. No max-width either: a wide
 * monitor gets every pixel.
 */
.vA .main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 28px 90px;
  min-width: 0;
}

/* The logo sits above the name, so 220px of sidebar does not have to hold both. */
.brandmark {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  font-size: 15px;
  font-weight: 600;
}

.brandtop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

/*
 * The logo slot. A background image, not an <img>: until the PNG is dropped
 * into public/assets/ the request 404s, and a background that 404s paints
 * nothing while a broken <img> paints an icon. The tile is the placeholder
 * until then, and the light tile a transparent PNG needs in dark mode after.
 * `background-origin: content-box` is what makes the padding an inset border
 * around the artwork rather than nothing at all.
 */
.brandlogo {
  flex: none;
  width: 32px;
  height: 32px;
  padding: 3px;
  border-radius: 8px;
  background-color: var(--logo-tile);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-origin: content-box;
}

.brandname {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foldbtn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink2);
  cursor: pointer;
}

.foldbtn:hover {
  background: var(--surface2);
}

/* The chevron points the way the button goes: in to fold, out to unfold. */
:root[data-sidebar="rail"] .foldbtn svg {
  transform: rotate(180deg);
}

nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navgroup {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.navgroup .eyebrow {
  margin: 10px 6px 4px;
}

.navbtn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
}

.navbtn:hover {
  background: var(--surface2);
}

.navbtn.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

/* The icon is drawn in the row's own colour, so `.on` tints it with the label. */
.navicon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.navbtn.on .navicon,
.navbtn:hover .navicon {
  color: inherit;
}

.navlabel {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidefoot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/*
 * The theme toggle and Sign out carry the same icon + label pair a nav row
 * does. `button.footbtn` rather than `.footbtn` because `.btn` is declared
 * further down the file and would otherwise win back `display: inline-block`,
 * which swallows the gap between the icon and its label.
 */
button.footbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Sign out is a link-coloured button; its icon takes the same colour. */
.linkbtn .navicon {
  color: inherit;
}

.whoami {
  font-size: 12px;
}

.whoami .who {
  color: var(--ink);
  font-weight: 600;
}

.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  margin-top: 6px;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

/* --- Shell: the folded rail --------------------------------------------- */
/*
 * At 56px there is room for one 18px icon and nothing else, so every label in
 * the sidebar is clipped rather than removed: a screen reader still reads
 * "Master link sheet", and the `title` on each row is the tooltip a mouse gets.
 *
 * Every rule here is scoped to `.vA`, the shell's own grid. The pre-paint
 * script writes `data-sidebar` onto every document, gate pages included, and
 * the sign-in, pending, denied and error pages carry the same brand row with
 * no sidebar around it — unscoped, a remembered rail clipped the product name
 * off those pages and left the logo hanging over an empty line.
 */
:root[data-sidebar="rail"] .vA .side {
  padding: 18px 8px;
  align-items: center;
  gap: 14px;
}

:root[data-sidebar="rail"] .vA .brandmark {
  align-items: center;
  gap: 0;
}

:root[data-sidebar="rail"] .vA .brandtop {
  flex-direction: column;
  gap: 8px;
}

:root[data-sidebar="rail"] .vA .brandname,
:root[data-sidebar="rail"] .vA .navlabel,
:root[data-sidebar="rail"] .vA .whoami .muted,
:root[data-sidebar="rail"] .vA .whoami .who {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:root[data-sidebar="rail"] .vA nav,
:root[data-sidebar="rail"] .vA .navgroup,
:root[data-sidebar="rail"] .vA .sidefoot {
  align-self: stretch;
}

:root[data-sidebar="rail"] .vA .navbtn,
:root[data-sidebar="rail"] .vA .footbtn {
  justify-content: center;
  padding: 8px 0;
  gap: 0;
}

/* The group headings become the thin rules that keep the rail's three blocks apart. */
:root[data-sidebar="rail"] .vA .navgroup .eyebrow {
  height: 1px;
  margin: 10px 6px;
  border-radius: 1px;
  background: var(--line);
  font-size: 0;
  line-height: 0;
  color: transparent;
}

:root[data-sidebar="rail"] .vA .navgroup:first-child .eyebrow {
  margin-top: 0;
}

:root[data-sidebar="rail"] .vA .footbtn {
  width: 100%;
}

:root[data-sidebar="rail"] .vA .whoami {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

:root[data-sidebar="rail"] .vA .linkbtn {
  margin-top: 0;
}

.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

/*
 * Above phone width the title row never wraps: a long subtitle wraps under the
 * title instead, so the screen's own buttons (New link, Copy link, …) always
 * sit in the top right corner.
 */
@media (min-width: 641px) {
  .titlebar {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .titlebar > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }

  .titlebar > .titleactions {
    flex: none;
  }
}

/* A date, or a span of two, is never broken across lines in a subtitle. */
.sub .nowrap {
  white-space: nowrap;
}

/* --- Components -------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1.45 "IBM Plex Sans", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--ink2);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card .bd {
  padding: 12px 14px;
}

.card .bd.empty {
  color: var(--muted);
  font-style: italic;
  padding: 40px 14px;
  text-align: center;
}

.notice {
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--pending-soft);
  color: var(--ink);
}

.notice.bad {
  background: var(--bad-soft);
}

.notice.info {
  background: var(--accent-soft);
}

/* The Alpha notice at the top of every screen; closed via app.js, remembered per browser. */
.alpha-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.alpha-close {
  flex: none;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  color: var(--ink2);
}

:root[data-alpha-banner="closed"] .alpha-banner {
  display: none;
}

.card .hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line2);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.pill.pending {
  color: var(--pending);
  background: var(--pending-soft);
}

.pill.bad {
  color: var(--bad);
  background: var(--bad-soft);
}

.pill.neutral {
  color: var(--ink2);
  background: var(--surface2);
}

/* --- Tables ------------------------------------------------------------ */

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

th {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line2);
  vertical-align: middle;
}

.mono,
.num {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

th.num {
  text-align: right;
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

/*
 * A pop-up window (`<dialog>`, opened with showModal by app.js), such as Add
 * destination URL. It renders in the top layer but still inherits from where it
 * sits in the markup — a right-aligned, nowrap table cell — so alignment and
 * wrapping are reset here. Width is capped so the two-column form has room
 * without turning into a page.
 */
dialog.modal {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: left;
  white-space: normal;
}

dialog.modal::backdrop {
  background: rgba(24, 35, 32, 0.45);
}

.modal-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-hd h2 {
  margin: 0 0 2px;
  font-size: 16px;
}

dialog.modal .mono {
  overflow-wrap: anywhere;
}

td.empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 24px 10px;
}

.sub-line {
  font-size: 12px;
}

.tablewrap {
  overflow-x: auto;
}

/*
 * A table whose cells carry tooltips. A box that scrolls on one axis cannot be
 * `visible` on the other — CSS turns the other axis into `auto` too — so
 * anything absolutely positioned inside the table is clipped at the top and
 * bottom edges of the wrapper. This padding is the slack a tooltip on the
 * first or last row grows into; it is inside the scroll box, so nothing
 * overlaps the card around it.
 */
.tablewrap.tips {
  padding-block: 10px;
}

/* --- Settings ---------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.tab {
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
}

.tab.on {
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
}

.field label,
.field .label {
  color: var(--ink2);
  font-weight: 500;
}

/* `hidden` has to beat the flex above, or a field the script has put away is
   still on screen. */
.field[hidden] {
  display: none;
}

.field.actions-row {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: flex-end;
  gap: 8px;
}

input[type="text"],
input[type="search"],
select {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 400 13px/1.45 "IBM Plex Sans", system-ui, sans-serif;
  width: 100%;
}

form.inline {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

form.inline input[type="text"] {
  max-width: 280px;
}

.btn.small {
  font-size: 12px;
  padding: 4px 9px;
}

.footnote {
  font-size: 12px;
  margin: 10px 0 0;
}

/* Where a failed API call reports itself: above the tabs, or inside the open pop-up. */
.api-error {
  margin-bottom: 14px;
}

/* Links → Offers: the search box and the count, one row above the cards. */
.offers-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.offer-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 320px;
  max-width: 520px;
}

/* Visible to a screen reader, invisible on screen — the search box's label. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- People & access --------------------------------------------------- */

.card.waiting {
  border-color: var(--pending);
}

.person {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: var(--surface2);
}

.avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
}

/* One pending person: who they are, then the answer. */
.waiting-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line2);
}

.waiting-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.access-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.access-form + .access-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line2);
}

.access-form select {
  max-width: 220px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.check input {
  accent-color: var(--accent);
}

/* The People card's header: the count, then the bell that opens Waiting for approval. */
.hdside { display: flex; align-items: center; gap: 12px; }
.hdside .sub-line { margin: 0; }
.bellbtn { display: inline-flex; align-items: center; gap: 6px; }
.bellbtn .navicon { display: inline-flex; }
.bellbtn .navicon svg { width: 15px; height: 15px; }
.bellbtn.has { border-color: var(--pending); }
.bellbtn .badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--pending); color: #fff; font-size: 11px; font-weight: 600;
}

dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
.pending-empty { margin: 0; }
.waiting-one { display: grid; gap: 14px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line2); }
.waiting-one:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

/* The channel table on the approve and Edit access pop-ups: one Income column (ADR-0019). */
.grantbox { display: grid; gap: 8px; }
.grants { font-size: 13px; }
.grants th, .grants td { padding: 5px 10px; }
.grants th.col, .grants td.col { width: 96px; text-align: center; }
.grants th.col label {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink2);
}
.grants th.col .colname { text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; color: var(--muted); }
.grants th.col .allbox { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.grants input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.grants tr.brandrow td {
  padding-top: 10px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line2); background: var(--surface2);
}
.grants tr.ch td:first-child { padding-left: 18px; }
.grants tr.ch:hover td { background: var(--surface2); }
.grants .chplatform { font-size: 12px; }
/* Under "all" every row is ticked but faded: the grant, not the boxes, is what holds. */
.grants td.col.all input { opacity: 0.55; }
.grants.off { opacity: 0.45; pointer-events: none; }
.grantwrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.grantbox .footnote { margin: 0; }
.grantsum {
  display: grid; gap: 2px; font-size: 12.5px; padding: 8px 10px;
  background: var(--surface2); border-radius: 6px;
}
.grantsum [hidden] { display: none; }
.grantsum b, .access-lines b { font-weight: 500; color: var(--ink2); }
.granthint { font-size: 12px; }
.access-lines { display: grid; gap: 2px; font-size: 13px; }
#card-people td.mono { white-space: nowrap; }

/* The People row a save just changed. */
.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

/* The Secrets Store binding checklist on a platform account. */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .waiting-row {
    grid-template-columns: 1fr;
  }
}

/* --- Sign-in / denial pages -------------------------------------------- */

body.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.gatebox {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.gatebox p {
  margin: 0;
}

/*
 * The sidebar used to stack above the content here. It no longer does (#59):
 * the rail stays beside the content at every width, and a window narrower than
 * about 1100px starts folded, so the space this rule was buying is already
 * bought. Roughly 900px is the supported floor; phones are out of scope.
 */
@media (max-width: 900px) {
  .vA .main {
    padding: 18px 16px 60px;
  }

  .grid.two,
  .form {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .navbtn {
    transition: background-color 0.12s ease, border-color 0.12s ease;
  }
}

/* --- Links: the public URL, the signature element ----------------------- */
/*
 * Three spans, one line, never wrapped: the hostname recedes, the advertiser
 * slug is ordinary ink, and the sub-ID gets the one colour reserved for it in
 * the whole palette. A PM should be able to read the sub-ID off any screen
 * without looking for it — it is the string the platform echoes back on a sale.
 */
.url {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.url .host {
  color: var(--muted);
}

.url .slug {
  color: var(--ink);
}

.subid {
  color: var(--sub);
  background: var(--sub-soft);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 500;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.urlbig .url {
  font-size: 20px;
}

a .url {
  text-decoration: none;
}

.break {
  word-break: break-all;
  white-space: normal;
}

/* --- Titlebar actions and breadcrumbs ----------------------------------- */

.titleactions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/*
 * The date range picker (CONTEXT.md "Date range"), on every money screen: one
 * button fixed at the bottom of the page, centred on the main column, so it
 * stays in view while the page scrolls. `.vA .main` already keeps 90px free
 * at the bottom, so the last row of a table is never underneath it. Opening it
 * unfolds a panel upwards: the quick picks on the left, the two date fields
 * and Apply on the right. Approved in prototype/range-picker-mock.html.
 */
.rangedock {
  position: fixed;
  bottom: 18px;
  left: calc(var(--side-w) + (100vw - var(--side-w)) / 2);
  transform: translateX(-50%);
  z-index: 40;
}

.rangetrigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.rangetrigger::-webkit-details-marker {
  display: none;
}

.rangetrigger svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.rangedock[open] .rangetrigger svg:last-child {
  transform: rotate(180deg);
}

.rangedays {
  color: var(--muted);
  font: 400 12px/1.45 "IBM Plex Mono", ui-monospace, monospace;
}

.rangepanel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 250px auto;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.rangepicks {
  display: grid;
  gap: 2px;
}

.rangepick {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

a.rangepick:hover {
  background: var(--line2);
}

.rangepick.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.rangepick small {
  color: var(--muted);
  font: 400 11px/1.6 "IBM Plex Mono", ui-monospace, monospace;
}

.rangeform {
  display: grid;
  align-content: start;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line2);
}

.rangefields {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rangefields.apart {
  justify-content: space-between;
}

.rangeform input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 400 12px/1.45 "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light dark;
}

.rangeform .zone {
  font-size: 11px;
  letter-spacing: 0.04em;
  cursor: help;
}

/* A phone: the panel stacks, the dates under the quick picks. */
@media (max-width: 640px) {
  .rangepanel {
    grid-template-columns: 1fr;
    width: calc(100vw - var(--side-w) - 32px);
  }

  .rangeform {
    padding: 10px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line2);
  }
}

.crumb {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.crumb b {
  color: var(--ink);
  font-weight: 500;
}

.sortlink {
  color: inherit;
  text-decoration: none;
}

.sortlink.on {
  color: var(--accent);
}

tr.clickable:hover td {
  background: var(--surface2);
  cursor: pointer;
}

tr.unpickable td {
  opacity: 0.5;
}

/* --- Create link: the three steps and the result ------------------------ */

.steps {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.step {
  background: var(--surface2);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
}

.step.on {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.step.done {
  color: var(--ink);
}

.field.wide {
  grid-column: 1 / -1;
}

.result {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result .actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Definition lists: the Placement page's facts ----------------------- */

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
}

/* The destination history is a drawer: open by default, foldable away. */
details.drawer > summary {
  cursor: pointer;
  list-style: none;
}

details.drawer > summary::-webkit-details-marker {
  display: none;
}

@media (max-width: 900px) {
  .kv {
    grid-template-columns: 1fr;
  }
}

/* System → Redirect service: a 2x2 of counts beside the domain table (#26). */
.statgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat .statlabel {
  font-size: 12px;
  color: var(--muted);
}

.stat .statvalue {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat .statnote {
  font-size: 12px;
}

@media (max-width: 900px) {
  .statgrid {
    grid-template-columns: 1fr;
  }
}


/* A section eyebrow: a small heading between cards. */

.eyebrow.section {
  margin: 18px 0 10px;
}

.eyebrow.section:first-child {
  margin-top: 0;
}

/* A section eyebrow with its filter beside it (#52, ticket #62). The row owns
 * the spacing, so the eyebrow inside it gives up its own margins. */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head .eyebrow.section {
  margin: 0;
}

/* ---------------------------------------------------------------------------
 * Income screens (ticket #27): the stat row and the stacked bar charts the
 * Overview and Unattributed screens are built from. Appended rather than woven
 * in, so the shell's own rules above stay untouched.
 * ------------------------------------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stats .card .bd {
  padding: 14px 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat .v {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-align: left;
}

.stat .d {
  font-size: 12px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.barlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar .track {
  display: flex;
  height: 14px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.seg {
  display: block;
  height: 100%;
}

.seg.c {
  background: var(--ok);
}

.seg.p {
  background: var(--pending);
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend i.c {
  background: var(--ok);
}

.legend i.p {
  background: var(--pending);
}

/* The range switcher marks the showing range without making it a link. */
.btn.on {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bar {
    grid-template-columns: 110px minmax(0, 1fr) 80px;
  }
}

/* ---------------------------------------------------------------------------
 * The drill screens (ticket #32): Channel, Video, and the Placement page's
 * income card. Appended on the same principle as the block above — the mock's
 * "wide table left, stacked charts right" row, plus the two colours SPEC §9
 * asks money to carry.
 * ------------------------------------------------------------------------ */

.grid.drill {
  grid-template-columns: 3fr 2fr;
  align-items: start;
}

/*
 * The Overview shows four statuses; a drill screen shows the same four beside
 * the clicks, and the Video page beside its views as well. One row each, so
 * "side by side" (SPEC §9) stays literally true rather than wrapping.
 */
.stats.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stats.six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats.five .stat .v,
.stats.six .stat .v {
  font-size: 20px;
}

.grid.stacked {
  grid-template-columns: minmax(0, 1fr);
}

/* Pending money is money that is not ours yet, and reads as such. */
td.pendingmoney {
  color: var(--pending);
}

/* A money cell the PM has no income access for (ADR-0017): muted, never a zero. */
.hiddenmoney {
  color: var(--muted);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-style: italic;
  font-size: 12px;
  font-weight: 400;
}

/*
 * Revenue per 1,000 views: drawn, greyed, and empty. SPEC §9 puts the metric
 * here; the arithmetic is post-MVP, so the slot has to look unfinished rather
 * than look like a figure worth quoting.
 */
.teaser {
  color: var(--muted);
  opacity: 0.55;
  font-style: italic;
}

.teaser .num {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-style: normal;
}

@media (max-width: 1180px) {
  .stats.five,
  .stats.six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .grid.drill {
    grid-template-columns: 1fr;
  }

  .stats.five,
  .stats.six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------------------------------------------------------------------------
 * The grouped Master link sheet (#45): the "Group by" control in the toolbar,
 * and one card per group with its subtotals in the header. Copied from the
 * approved prototype (#44, Variant B) — everything else on the screen is the
 * flat sheet's own markup.
 * ------------------------------------------------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.groupby {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink2);
  white-space: nowrap;
}

.seggroup {
  display: inline-flex;
  gap: 4px;
}

.card.group .hd {
  flex-wrap: wrap;
  align-items: center;
}

.card.group .hd h2 {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* The group's second name — a channel's brand, a video's channel. */
.card .hd h2 .muted {
  font-weight: 400;
}

/*
 * The header's subtotals. Figures are monospaced like every other number on
 * the sheet, so a header and the column under it line up to the eye.
 */
.groupstats {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink2);
  flex-wrap: wrap;
}

.groupstats b {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.groupstats .pendingmoney b {
  color: var(--pending);
}

/* Collapsed: the header and its numbers stay, the rows go (app.js). */
.card.group.collapsed .tablewrap {
  display: none;
}

/* --- Settings: description templates (#46) -------------------------------
 *
 * A rail of the caller's channels and their templates beside an editor whose
 * two columns are the text a PM writes and the same text as a PM reads it —
 * every {{advertiser-slug}} drawn as a chip, green when an advertiser has that
 * slug, red when none does. The prototype for issue #43 (variant B) is the
 * source of these rules; only the ones this screen uses are here.
 */

textarea {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 400 13px/1.5 "IBM Plex Mono", ui-monospace, Menlo, monospace;
  width: 100%;
  resize: vertical;
}

.btn.danger {
  color: var(--bad);
}

.actions-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* The template's name is edited in the card's header, where its title would be. */
.card .hd h2 input.namefield {
  width: auto;
  min-width: 260px;
  font-weight: 600;
  font-size: 15px;
}

.tpl-split {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* The editor card and its Delete button, which cannot live inside the form. */
.tpl-editor {
  display: grid;
  gap: 10px;
}

.editor2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.editor2 textarea {
  min-height: 360px;
}

.preview {
  background: var(--surface2);
  border-radius: 6px;
  padding: 12px 14px;
  font: 400 12.5px/1.7 "IBM Plex Mono", ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 360px;
}

.legend-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  margin-top: 8px;
}

/* The known slugs, listed under the text box; clicking one adds it. */
.slugs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.slugs code {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.slugs code:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* One placeholder, drawn inside the text. */
.ph {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  vertical-align: baseline;
  white-space: nowrap;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.ph .slug {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 400;
  opacity: 0.8;
}

.ph.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.ph.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

/* The other things a placeholder can be about to become (#49). */
.ph.pick {
  background: var(--pending-soft);
  color: var(--pending);
  border-color: var(--pending);
}

.ph.off {
  background: var(--surface2);
  color: var(--muted);
  text-decoration: line-through;
}

.ph.queued {
  background: var(--surface2);
  color: var(--muted);
}

.ph.making {
  background: var(--pending-soft);
  color: var(--pending);
}

.ph.skipped {
  background: var(--surface2);
  color: var(--ink2);
}

.ph.unknown {
  background: var(--bad-soft);
  color: var(--bad);
}

/* What an unknown placeholder becomes in a built description. */
mark.marker {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 500;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail .eyebrow {
  margin: 10px 8px 4px;
}

.rail .eyebrow:first-child {
  margin-top: 0;
}

.railitem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.railitem:hover {
  background: var(--surface2);
}

.railitem.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.railitem .t {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.railitem .s {
  grid-column: 1;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.railitem .k {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-size: 12px;
  text-align: right;
  color: var(--ink2);
  font-variant-numeric: tabular-nums;
}

.railitem.on .k,
.railitem.on .s {
  color: inherit;
  opacity: 0.85;
}

@media (max-width: 1000px) {
  .tpl-split,
  .editor2 {
    grid-template-columns: 1fr;
  }

  .editor2 textarea,
  .preview {
    min-height: 200px;
  }
}

/* --- Bulk create (#47, #49) --------------------------------------------- */
/*
 * Everything below comes from the approved prototype (#44, Variant B) and is
 * only what its two bulk-create screens need: a four-column Where card, the
 * list of rows the run will make, the placeholder chips inside the template
 * text, the run's progress bar, and the run table's outcome pill with its
 * sentence on hover or focus.
 */

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .form.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* One row of "Links this run will make": tick, what it is, what it will read. */
.rowlist {
  display: grid;
  gap: 0;
}

.rowline {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line2);
  font-size: 13px;
}

.rowline:last-child {
  border-bottom: 0;
}

/* A row that cannot be made, or one that is not ticked, reads quieter. */
.rowline.off {
  opacity: 0.55;
}

.rowline select {
  width: auto;
  max-width: 240px;
}

.rowline input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* Why an offer was proposed, under its dropdown. */
.why {
  font-size: 11.5px;
  color: var(--muted);
}

/* Why no link can be made for a row at all. */
.rowline .sub-line.reason {
  color: var(--muted);
  font-style: italic;
}

.rowhint {
  font-size: 12px;
}

/* The two buttons under the row list sit at either end. */
.actions-inline.spread {
  justify-content: space-between;
  margin-top: 12px;
}

/* How far the run has got: created, skipped and failed, in one bar. */
.progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress .track {
  display: flex;
  height: 10px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.seg.s {
  background: var(--line);
}

.seg.f {
  background: var(--bad);
}

.progress .words {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}

.failedcount {
  color: var(--bad);
}

/* A line that landed while the page was watching. */
tr.landed td {
  animation: land 0.6s ease;
}

@keyframes land {
  from {
    background: var(--accent-soft);
  }

  to {
    background: transparent;
  }
}

/*
 * The run table's outcome: the pill alone, and the sentence on hover or
 * keyboard focus. Inline, the sentences made every row four lines tall and the
 * table read as prose (#44). The tooltip is anchored to the *left* of the pill
 * and inside the table, because `.tablewrap` scrolls horizontally and clips
 * anything that leaves its box.
 */
.outcome {
  position: relative;
  display: inline-block;
}

.outcome .tip {
  display: none;
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  padding: 8px 10px;
  border-radius: 6px;
  z-index: 5;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  box-shadow: var(--shadow);
  font-weight: 400;
}

.outcome:hover .tip,
.outcome:focus-visible .tip {
  display: block;
}

/*
 * A tooltip centred on its pill leaves the table's box at the first and last
 * row, and the wrapper clips whatever leaves it. So the top row's tooltip
 * hangs downwards and the bottom row's upwards, and both grow into the padding
 * `.tablewrap.tips` keeps for them.
 */
tbody tr:first-child .outcome .tip {
  top: 0;
  bottom: auto;
  transform: none;
}

tbody tr:last-child .outcome .tip {
  top: auto;
  bottom: 0;
  transform: none;
}

td.outcome-cell {
  white-space: nowrap;
}

/* --- The video's built description (#48) ---------------------------------
 *
 * The Description card and "How the links landed" beside it, from the same
 * prototype (variant B). `mark.marker` and `.actions-inline` arrived with the
 * templates tab (#46) and are reused as they are; these are the rules that
 * screen did not need.
 */

/* The finished text, as a block a PM copies whole. */
pre.desc {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 6px;
  font: 400 12.5px/1.55 "IBM Plex Mono", ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}

/* A public URL inside it. */
pre.desc .u {
  color: var(--accent);
}

/* Not the finished thing: the description as it is going to read, or filling
 * in as the run's links land. Dashed, so it is never mistaken for the block a
 * PM copies. */
pre.desc.live {
  background: var(--surface);
  border: 1px dashed var(--line);
}

.legend-row .u {
  color: var(--accent);
}

/* The count of markers under the text: a warning, so it carries the colour. */
.footnote.markers {
  color: var(--bad);
}

/* One line per link: how the description treated it. */
.extras {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.extras li {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* A select in an inline form sizes to its options, not to the card. */
form.inline select {
  width: auto;
  max-width: 260px;
}

/* --- Search-and-suggest boxes (#60) ------------------------------------ */

/*
 * The box a long <select> became: a text field with the whole option list
 * under it as a <ul>, filtered by app.js. It sits inside the same
 * `.field` wrapper a select did, so nothing else on a form moves.
 */
.combo {
  position: relative;
}

/* Room for the chevron, which is decoration — clicks fall through to the box. */
.combo .combo-input {
  padding-right: 26px;
}

.combo::after {
  content: "▾";
  position: absolute;
  top: 50%;
  right: 9px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

/*
 * Text the list does not carry: the box says so before the form refuses. The
 * hook is an attribute app.js sets, never `:invalid` — a required box that has
 * not been answered yet is invalid from the first paint, and both Move-all-
 * links pickers would open already outlined in the error colour.
 */
.combo-input[data-combo-bad] {
  border-color: var(--bad);
}

.combo-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* `hidden` on a list item has to beat the display each rule below sets. */
.combo-list[hidden],
.combo-list li[hidden] {
  display: none;
}

.combo-opt {
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.combo-opt:hover,
.combo-opt.on {
  background: var(--accent-soft);
}

.combo-opt[aria-selected="true"] {
  font-weight: 600;
}

.combo-head {
  padding: 7px 8px 3px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.combo-empty {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--muted);
}

/* --- Destination URLs table (#61) -------------------------------------- */

/*
 * The advertiser's name is the boss's way into its Edit pop-up, so it is a
 * link. A column of 124 blue underlines is not a table, though, so it reads as
 * the name it is until the pointer is on it. A PM gets no link at all.
 */
.offers-table td a.advertiser {
  color: inherit;
  text-decoration: none;
}

.offers-table td a.advertiser:hover {
  color: var(--accent);
  text-decoration: underline;
}

/*
 * The Destination URLs table (#94). Its Edit / Pause pair is two controls in
 * one cell, and a label wide enough to wrap them onto two lines made the row
 * twice as tall for no reason.
 */
.urls-table td.actions {
  white-space: nowrap;
}

.urls-table td.actions form.inline {
  display: inline-flex;
}

/*
 * The Link column (#121): long affiliate URLs, cut short, the whole thing on
 * hover. And a read-only value in the Edit pop-up, set like an input would be.
 */
.urls-table td.link {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form .fixedval {
  padding: 7px 0 2px;
}

.form .fixedval.mono {
  font-size: 12px;
  overflow-wrap: anywhere;
}

/*
 * A section eyebrow inside a pop-up's field grid spans it, so "This URL" and
 * "Its offer" sit above their fields rather than in the first column of them.
 */
.form .eyebrow.section {
  grid-column: 1 / -1;
}

/*
 * Links made under no channel (ADR-0019, ticket #128; the prototype's `create`
 * and `sheet` screens).
 */

/* A warning pill: amber, because it is something to look at, not something broken. */
.pill.warn {
  color: var(--pending);
  background: var(--pending-soft);
}

/* The Unplaced section on top of the Master link sheet, marked with the sub-ID's orange. */
.card.group.unplaced {
  border-left: 3px solid var(--sub);
}
.card.group .hd h2 .muted {
  font-weight: 400;
  font-size: 12.5px;
}

/* The channel-link tick on Create link: a plain checkbox and its words. */
.field label.tick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.field label.tick input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

/* A refusal under a form. */
.formerr {
  margin: 0;
}

/*
 * Unplaced money and every scanned video on the income screens (ADR-0019,
 * ticket #136; the prototype's `overview` and `channel` screens).
 */

/* The boss's Unplaced row under By brand, By channel and By host: not a link, no page behind it. */
.bar.unplaced .barlabel {
  color: var(--muted);
  font-style: italic;
}

/* A video on the Channel screen with no link of ours: 0 links, 0 clicks, $0. */
tr.zero td,
tr.zero td a {
  color: var(--muted);
}
/* --- #133 Rescan videos pop-up (the mock's rescanDialog) --------------- */
.rescan-form { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.rescan-form input[type="text"] { flex: 1; min-width: 0; }
.rescan-note { font-size: 12px; margin-top: 6px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice li { margin: 2px 0; }

/*
 * Recent creations (ADR-0019, ticket #135; the prototype's `recent` screen):
 * one card per creation, newest first; the one just made flashes.
 */
.creations {
  display: grid;
  gap: 14px;
}
.card.creation .hd h2 {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.card.creation .hd h2 .pill,
.card.creation .hd h2 .muted {
  font-weight: 400;
}
.card.creation .links {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.card.creation .links li {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
/* A long title stops at one line with "…"; its title attribute holds the whole of it. */
.trunc { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.card.group .hd h2 .trunc { max-width: min(440px, 100%); }
.card.group .hd h2 { min-width: 0; }
.card.creation .links .trunc {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.card.creation .desc-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.card.creation .desc-hd .eyebrow {
  margin: 0;
}
.card.creation.newest {
  animation: flash 1.6s ease-out;
}

/* --- #134 Warnings (the mock's videoGroups, sheetRow, warningsDialog) ----- */
/* A video in an error state: red edge, red title; a reused link's row tinted. */
.card.group.haserror { border-left: 3px solid var(--bad); }
.card.group.haserror .hd h2, .card.group.haserror .hd h2 > a { color: var(--bad); }
tr.errrow td { background: var(--bad-soft); }
tr.errrow td a { color: var(--bad); }
.pillbtn { border: 0; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 400; }
.pillbtn:hover { filter: brightness(0.95); text-decoration: underline; }
.card.group .hd h2 .pillbtn { margin-left: 8px; }

/* The Warnings button and pop-up. */
.warnbtn { display: inline-flex; align-items: center; gap: 6px; }
.warnbtn.has { border-color: var(--bad); color: var(--bad); }
.warnbtn .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600; }
.warnlist { display: grid; gap: 12px; }
.warnitem { border: 1px solid var(--line); border-left: 3px solid var(--bad); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; font-size: 13px; }
.warnitem .what { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.warnitem p { margin: 0; }
.warnitem .todo { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.warnitem .todo form { flex: none; margin: 0; }
.warnitem .trunc, .reuse-notice .trunc { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* The placement page's reuse warning. */
.reuse-notice { margin-bottom: 14px; }
.reuse-notice .muted { margin-top: 4px; }

/* ======================================================================
 * Prototype only, added 2026-10-13 for ADR-0020.
 * ==================================================================== */

/* The Host to-dos button: amber, not red — it is work to do, not something wrong. */
.hostbtn { display: inline-flex; align-items: center; gap: 6px; }
.hostbtn.has { border-color: var(--pending); color: var(--pending); }
.hostbtn .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--pending); color: #fff; font-size: 11px; font-weight: 600; }

/* A host to-do item: the warnings' card shape with an amber edge. */
.todolist { display: grid; gap: 12px; }
.todoitem { border: 1px solid var(--line); border-left: 3px solid var(--pending); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; font-size: 13px; }
.todoitem.flash { animation: flash 1.6s ease-out; }
.todoitem p { margin: 0; }
.vtitle { font-weight: 500; }
.vtitle .ext { font-size: 11px; margin-left: 2px; }
.dashlink { font-size: 12px; margin-left: 6px; }
.suggest { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.confirmrow { display: flex; gap: 8px; align-items: center; }
.confirmrow select { max-width: 280px; }
.confirmrow .btn { flex: none; }

/* Warnings: the kind filter, the Ignore button, the full address, the ignored toggle. */
.kindfilter { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; font-size: 12.5px; }
.kindfilter .chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.kindfilter .chip.on { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.kindfilter .chip b { font-weight: 600; }
.warnitem .what { justify-content: space-between; }
.warnitem .what .lead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.warnitem .addr { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.warnitem .addr .scheme { color: var(--muted); }
.warnitem .todo .acts { display: flex; gap: 6px; flex: none; }
.warnitem.ignored { border-left-color: var(--line); opacity: 0.7; }
.ignoredtoggle { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line2); font-size: 12.5px; }
.ignoredtoggle .linkbtn { color: var(--accent); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.ignoredtoggle .linkbtn:hover { text-decoration: underline; }
.ignoredlist { display: grid; gap: 10px; margin-top: 10px; }
.pill.dim { color: var(--muted); background: var(--surface2); }

/* "No host recorded" in a breakdown: muted, like Unplaced. */
.bar.nohost .barlabel { color: var(--muted); font-style: italic; }

/* The video page's host line and the 403 page. */
.hostline { display: inline-flex; gap: 8px; align-items: center; }
.forbidden { max-width: 560px; }
.fieldnote { color: var(--pending); }
.titlebar .sub a, .titlebar .sub a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* --- performance pages (F) ---------------------------------------------
 * Overview, Channels, Channel and Video (spec #154): the prototype's
 * performance CSS (prototype/analysis-mock.html), cleaned of its
 * prototype-only pieces. Pages append their own under their slice comment.
 * ------------------------------------------------------------------------ */

:root { --b1: #1e6b58; --b2: #b3521a; --b3: #4b62b0; --up: #0f7f5e; --down: #b0433b; }
:root[data-theme="dark"] { --b1: #3fae8b; --b2: #e38a5a; --b3: #8a9cf0; --up: #2a9e78; --down: #d4675f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --b1: #3fae8b; --b2: #e38a5a; --b3: #8a9cf0; --up: #2a9e78; --down: #d4675f; } }

/* The line at the top of every page: whose dollars these are. */
.scopeline { display: block; line-height: 1.7; font-size: 12.5px; margin: 0 0 14px; padding: 8px 12px; border-radius: 8px; background: var(--surface2); color: var(--ink2); }
.scopeline b { font-weight: 600; color: var(--ink); }
.scopeline .pill { margin-right: 6px; }

/* Link trail separators (the shell's .crumb). */
.crumb .sep { color: var(--muted); }

/* Status row: Clicks and Views only, for a viewer without dollars. */
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Tables. */
table.perf th.sortable { white-space: nowrap; }
table.perf th.sorted, table.perf th.sorted .sortlink { color: var(--accent); }
table.perf td { white-space: nowrap; }
table.perf td.name { white-space: normal; min-width: 220px; max-width: 360px; }
table.perf td.name .nm { color: inherit; text-decoration: none; }
table.perf td.name a.nm:hover { text-decoration: underline; }
table.perf tr.sel td { background: var(--accent-soft); }
.name .sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
tr.unplaced td.name, tr.unplaced td.name .sub { font-style: italic; color: var(--muted); }
.delta { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; font-size: 12px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat, .delta.na { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.spark { display: block; }
.flag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--pending-soft); color: var(--pending); margin-left: 6px; white-space: nowrap; }
.flag.bad { background: var(--bad-soft); color: var(--bad); }

/* Tags after a figure: partial sum, change in clicks, views since a day. */
.part { font-size: 10px; color: var(--pending); margin-left: 4px; font-family: "IBM Plex Sans", system-ui, sans-serif; vertical-align: 1px; }
.part.basis, .part.since { color: var(--muted); }

/* Measure chips (links) and the row they sit in. */
.chiprow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chiprow .chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink2); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: none; }
.chiprow .chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.ctlrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; margin: 0 0 10px; }
.ctlrow label { color: var(--muted); }

/* Charts: server-drawn SVG. */
.chartwrap { display: grid; gap: 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 10.5px "IBM Plex Sans", system-ui, sans-serif; fill: var(--muted); }
.chart .grid line { stroke: var(--line2); }
.chart .axis { stroke: var(--line); }
.chart [hidden] { display: none; }
.legendrow { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); }
.legendrow svg { vertical-align: 1px; margin-right: 4px; }
.legendrow button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.legendrow button.off { opacity: 0.35; text-decoration: line-through; }
.legendrow a { color: inherit; text-decoration: none; }
.legendrow a:hover { text-decoration: underline; }
.scatterwrap { position: relative; }
.scatter circle { cursor: pointer; stroke: var(--surface); stroke-width: 1; }
.scatter circle.sel { stroke: var(--ink); stroke-width: 2.2; }
.scatter circle:hover { stroke: var(--ink); }

/* Worth a look. */
.lookgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.looklist { display: grid; gap: 0; font-size: 13px; }
.looklist .li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--line2); color: inherit; text-decoration: none; }
.looklist .li:hover { background: var(--surface2); }
.looklist .li:last-child { border-bottom: 0; }
.looklist .li .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.looklist .li .why { font-size: 11.5px; color: var(--muted); }
.card .hd .why { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Tabs with a count badge (the boss's Unattributed tab). */
.tab .count { display: inline-grid; place-items: center; min-width: 18px; height: 17px; padding: 0 5px; margin-left: 5px; border-radius: 999px; background: var(--bad-soft); color: var(--bad); font-size: 11px; font-weight: 600; }

/* Breakdown cards three across, and the "why" lists. */
.bars3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.whylist { margin: 0; display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.whylist dt { color: var(--muted); }
.whylist dd { margin: 0; }

@media (max-width: 1100px) { .lookgrid, .bars3 { grid-template-columns: 1fr; } }

/* --- CH --- Channel page (/channels/:id) -------------------------------- */
.chpage { display: grid; gap: 14px; }
.chpage > .scopeline { margin: 0; }
.chpage .lookhead { font-size: 15px; margin: 6px 0 0; }
.chpage .footnote { margin: 0; }
/* "Everything else on the channel": thin, dashed, muted (the prototype's linesChart). */
.chpage [data-series="rest"] path { stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; }

/* --- Direct placements (ADR-0023) ---------------------------------------- */
/* A direct placement's public URL is a long affiliate link: let it wrap. */
.url.direct { white-space: normal; word-break: break-all; }

/* --- Sub-affiliates (spec #177) ------------------------------------------ */
/* The prototype's own rules (prototype/sub-affiliates-mock.html), less its
 * role bar. The boss's pages and the sub-affiliate's page share them. */
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* `.sapage` wraps each of the three pages' main column, so these spacing rules
 * reach nothing else. */
.sapage .stats + .tabs { margin-top: 18px; }
.sapage .card + .card, .sapage .card + .section-head, .sapage .stats + .card { margin-top: 14px; }
.leads { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12.5px; overflow-wrap: anywhere; padding: 10px 12px; background: var(--surface2); border-radius: 8px; }
.cut { font-weight: 500; white-space: nowrap; }
.was { font-size: 12px; color: var(--muted); }
tr.off td { color: var(--muted); }
tr.off .url .slug { color: var(--muted); text-decoration: line-through; }
.copybtn { margin-left: 8px; }
.radiorow { display: flex; gap: 16px; align-items: center; height: 34px; }
.radiorow label { white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-weight: 400; }
.linkbox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface2); border-radius: 8px; }
.linkbox .url { font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
.offer-meta { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); margin-top: 12px; }
.offer-meta b { color: var(--ink); font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; }
.tagrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--ink2); }
.tagrow input { width: 150px; }
.card.ended { opacity: .7; }
.card.ended .url .slug { text-decoration: line-through; }
.yourcut { font-size: 13px; color: var(--ink2); }
.yourcut b { color: var(--accent); }
.tagchip { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; color: var(--sub); background: var(--sub-soft); border-radius: 3px; padding: 0 4px; margin-right: 4px; }
/* The sub-affiliate sign-in and set-password boxes: full-width fields. */
.gatebox .form { grid-template-columns: 1fr; }
.gatebox .field input[type="email"], .gatebox .field input[type="password"] { width: 100%; }
/* #186b: the tag rule turns red while the typed tag breaks it. */
.fieldnote[data-tag-rule].bad { color: var(--bad); }
