/*
 * 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;
  --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;
    --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;
  --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 ------------------------------------------------------------- */

.vA {
  display: grid;
  grid-template-columns: 220px 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;
}

.vA .main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 28px 90px;
  max-width: 1300px;
}

.brandmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}

.brandmark .mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
}

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;
  justify-content: space-between;
  align-items: center;
  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;
}

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

.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;
}

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

/* --- 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);
}

.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;
}

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

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

.tablewrap {
  overflow-x: auto;
}

/* --- 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 {
  color: var(--ink2);
  font-weight: 500;
}

.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. */
#settings-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 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;
}

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

  .vA .side {
    position: static;
    height: auto;
  }

  .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 draft placement borrows the sub-ID's orange: it is waiting, not broken. */
.pill.draft {
  color: var(--sub);
  background: var(--sub-soft);
}

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;
}

.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;
  }
}


/* --- Video-match inbox (#33) -------------------------------------------
 *
 * One card per thing that needs a person: an upload with no content item, or a
 * draft with no upload. The body is "what we know" beside "what you can do",
 * which is the mock's `1fr auto` — and the actions stack, because there are
 * three of them and they are all short.
 */

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

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

.inbox-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.inbox-body p {
  margin: 8px 0 0;
  font-size: 13px;
}

.inbox-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* The links the scan actually found, shown as links rather than as evidence. */
.found {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

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

  .inbox-actions {
    align-items: stretch;
  }
}

/* ---------------------------------------------------------------------------
 * 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);
}

/*
 * 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));
  }
}
