/*
 * Clear Exchange app (/app): agent console, operator and publisher views. Plain CSS, no
 * build step, no external assets (the CSP allows only 'self' and data: images).
 * Colours, type, spacing and radius come from tokens.css; buttons, badges, the wordmark
 * and the focus ring from base.css. Change the brand there, not here.
 *
 * Same editorial direction as the site: sections open with an ink rule rather than
 * sitting in shadowed cards, headings in the serif, numbers in tabular figures, status
 * shown in words with a small mark rather than coloured pills.
 */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: var(--container-app); margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-12); }
main:focus { box-shadow: none; }
h1 { font-family: var(--font-display); font-size: var(--text-4xl); line-height: var(--leading-tight); font-weight: var(--weight-medium); margin: 0 0 var(--space-3); letter-spacing: var(--tracking-tight); }
h2 { font-family: var(--font-display); font-size: var(--text-xl); line-height: 1.25; font-weight: var(--weight-medium); margin: 0; }
h3 { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin: var(--space-5) 0 var(--space-2); color: var(--foreground); }
p { margin: 0 0 10px; }
a { color: var(--foreground); }
code, pre { font-size: 0.857em; }

/* ---------- header: wordmark row, then view tabs ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--header); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: var(--container-app); margin: 0 auto; padding: 0 var(--space-6); display: flex; align-items: center; gap: var(--space-4); height: 56px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.topbar-link { color: var(--muted-foreground); }
.topbar-link:hover:not(:disabled) { color: var(--foreground); }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-inner { max-width: var(--container-app); margin: 0 auto; padding: 0 var(--space-4); display: flex; gap: var(--space-1); }
.tab { position: relative; display: inline-flex; align-items: center; height: 44px; padding: 0 var(--space-3); color: var(--muted-foreground); text-decoration: none; font-weight: var(--weight-medium); font-size: var(--text-sm); white-space: nowrap; transition: color var(--duration); }
.tab:hover { color: var(--foreground); }
.tab::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 2px; background: transparent; }
.tab.active { color: var(--foreground); }
.tab.active::after { background: var(--foreground); }
.tab:focus-visible { box-shadow: inset 0 0 0 2px var(--ring); }

/* ---------- intro and flow ---------- */
.intro { margin-bottom: 24px; max-width: 900px; }
.intro p { color: var(--muted-foreground); font-size: 0.9375rem; max-width: 46rem; }
.intro p strong { color: var(--foreground); font-weight: 600; }
.intro-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; max-width: none; }
/* Progress through the four steps: plain numbered words on a rule, the current one underlined. */
.flow { list-style: none; display: flex; gap: var(--space-6); padding: 0; margin: var(--space-5) 0 0; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.flow li { display: flex; align-items: baseline; gap: 6px; padding-bottom: var(--space-2); margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted-foreground); font-size: 0.8125rem; }
.flow li span { font-family: var(--font-display); font-style: italic; font-size: var(--text-base); }
.flow li.active { border-bottom-color: var(--foreground); color: var(--foreground); font-weight: 500; }
.flow li.active span { color: var(--brand); }
.flow li.done { color: var(--foreground); }

/* ---------- cards and layout ---------- */
.card { background: transparent; color: var(--card-foreground); border-top: 2px solid var(--rule-strong); padding: var(--space-5) 0 var(--space-10); margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.agent-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-12); align-items: start; }
.api-log { position: sticky; top: 116px; max-height: calc(100vh - 132px); overflow: auto; padding: var(--space-5) 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1100px) {
  .agent-grid { grid-template-columns: 1fr; }
  .api-log { position: static; max-height: none; }
}
@media (max-width: 720px) {
  h1 { font-size: var(--text-2xl); }
  .card { padding: var(--space-4) 0 var(--space-8); }
  .two-col { grid-template-columns: 1fr; gap: 8px; }
  .intro-row { flex-direction: column; align-items: flex-start; }
  .field-inline { flex-direction: column; align-items: stretch; }
}
@media (max-width: 520px) {
  .tab { padding: 0 var(--space-2); }
  .tab::after { left: var(--space-2); right: var(--space-2); }
}

/* ---------- steps ---------- */
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.step-head h2 { flex: 1; min-width: 0; }
.step-num { font-family: var(--font-display); font-style: italic; font-size: var(--text-2xl); line-height: 1; color: var(--brand); flex: none; min-width: 1ch; }
.step.locked { border-top-width: 1px; border-top-color: var(--border-strong); }
.step.locked .step-num { color: var(--muted-foreground); }
.step.locked h2 { color: var(--muted-foreground); }
/* inline code, as in shadcn typography */
.route { font-size: 0.75rem; color: var(--muted-foreground); white-space: nowrap; }
.placeholder { color: var(--muted-foreground); margin: 0; }

/* ---------- forms ---------- */
.query-form { display: grid; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1 1 220px; }
.field-narrow { flex: 0 0 90px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; flex: 0 1 420px; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
/* Label */
.label { font-size: 0.875rem; font-weight: 500; line-height: 1; color: var(--foreground); }
.help { font-size: 0.8125rem; color: var(--muted-foreground); }
/* Input / Textarea / Select */
input, select, textarea { font: inherit; font-size: 0.875rem; color: inherit; background: var(--card); border: 1px solid var(--input); border-radius: var(--radius-md); padding: 4px 12px; min-width: 0; box-shadow: var(--shadow-xs); transition: border-color 0.15s, box-shadow 0.15s; }
input, select { height: 36px; }
textarea { resize: vertical; padding: 8px 12px; min-height: 64px; font-size: 1rem; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background: var(--chevron) no-repeat right 10px center / 16px 16px; cursor: pointer; }
select option { background: var(--background); color: var(--foreground); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--focus-ring); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-md); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="range"] { height: 20px; padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); background: none; }
input[type="range"]:focus-visible { box-shadow: none; outline: 2px solid var(--ring); outline-offset: 2px; }
/* Checkbox */
input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; width: 16px; height: 16px; padding: 0; margin: 0; border: 1px solid var(--primary); border-radius: var(--radius-sm); background: var(--card); cursor: pointer; display: inline-grid; place-content: center; }
input[type="checkbox"]:checked { background: var(--primary) var(--check) no-repeat center / 12px 12px; }
input[type="checkbox"]:focus-visible { box-shadow: var(--focus-ring); }
output { font-variant-numeric: tabular-nums; color: var(--muted-foreground); font-weight: 400; }
.money-input { display: flex; }
.money-input input { flex: 1; border-radius: var(--radius-md) 0 0 var(--radius-md); font-variant-numeric: tabular-nums; }
.money-input select { border-radius: 0 var(--radius-md) var(--radius-md) 0; border-left: 0; background-color: var(--muted); }
.samples { display: flex; flex-wrap: wrap; gap: 2px 0; }
.advanced summary { cursor: pointer; color: var(--muted-foreground); font-size: 0.875rem; font-weight: 500; width: fit-content; }
.advanced summary:hover { color: var(--foreground); }
.advanced[open] summary { margin-bottom: 12px; color: var(--foreground); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.query-form .actions { margin-top: 0; }
/* FormMessage */
.error { color: var(--destructive); margin: 0; font-size: 0.875rem; font-weight: 500; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 0.875rem; font-weight: 500; cursor: pointer; }

/* ---------- buttons: base.css; app-only variants ---------- */
.linkish { font: inherit; font-family: var(--font-mono); font-size: 0.75rem; background: none; border: 0; padding: 0; color: var(--foreground); cursor: pointer; text-decoration: underline; text-decoration-color: var(--ring); text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: currentColor; }
/* Badge (outline by default; secondary when clickable; default for the usage tier) */
.chip { display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 500; line-height: 1.33; padding: 2px 8px; border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border); color: var(--foreground); }
/* Sample questions read as links to try, not buttons. */
button.chip { cursor: pointer; font: inherit; font-size: 0.8125rem; font-weight: 400; background: none; border: 0; color: var(--muted-foreground); padding: 2px 0; margin-right: var(--space-3); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; transition: color 0.15s; }
button.chip:hover { color: var(--foreground); text-decoration-color: currentColor; }
.chip-usage { border-color: var(--foreground); color: var(--foreground); font-weight: 600; }

/* ---------- ranking ---------- */
/* Alert */
.callout { border: 1px solid var(--border); background: var(--background); padding: 12px 16px; border-radius: var(--radius-lg); color: var(--muted-foreground); font-size: 0.875rem; margin: 20px 0 12px; }
.callout strong { color: var(--foreground); font-weight: 600; }
.callout-ok { border-color: var(--success-border); background: var(--success-soft); color: var(--foreground); margin: 16px 0 0; }
.funnel { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.75rem; }
.funnel li { display: flex; gap: 6px; align-items: center; padding: 3px 8px; border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border); color: var(--muted-foreground); font-weight: 500; }
.funnel li .n { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--foreground); }
.funnel li.drop .n { color: var(--muted-foreground); }
.funnel li.keep { border-color: var(--foreground); color: var(--foreground); }
.offers { list-style: none; padding: 0; margin: 0; display: grid; border-top: 1px solid var(--rule-strong); }
.offer { display: grid; grid-template-columns: 40px minmax(0, 1fr) 200px; gap: 16px; padding: var(--space-5) var(--space-3) var(--space-5) 0; border-bottom: 1px solid var(--border); background: transparent; }
.offer.accepted { background: var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand); padding-left: var(--space-3); }
.rank { font-family: var(--font-display); font-style: italic; font-size: var(--text-2xl); line-height: 1; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.offer-pub { font-size: 0.8125rem; color: var(--muted-foreground); }
.offer-pub strong { color: var(--foreground); font-weight: 500; }
.offer-title { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-medium); line-height: var(--leading-snug); margin: 2px 0 6px; color: var(--foreground); }
.snippet { color: var(--muted-foreground); font-size: 0.875rem; }
.terms { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.offer-ref { font-size: 0.75rem; color: var(--muted-foreground); font-family: var(--font-mono); overflow-wrap: anywhere; }
.offer-side { display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--border); padding-left: 16px; }
.metric { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: baseline; }
.metric-label { font-size: 0.75rem; color: var(--muted-foreground); font-weight: 500; }
.metric-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-sub { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted-foreground); }
/* Progress */
.meter { grid-column: 1 / -1; display: block; height: 3px; background: var(--border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--foreground); }
.meter-rel { height: 3px; }
@media (max-width: 720px) {
  .offer { grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px; }
  .offer-side { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
}
.countdown { font-variant-numeric: tabular-nums; }
.countdown.expired { color: var(--destructive); font-weight: 600; }
.empty { color: var(--muted-foreground); padding: var(--space-5) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* ---------- entitlement ---------- */
.ent-summary { display: flex; flex-wrap: wrap; gap: 12px 32px; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--muted); border: 1px solid var(--border); }
.kv { display: flex; flex-direction: column; gap: 6px; font-size: 0.875rem; }
.kv .label { font-size: 0.75rem; color: var(--muted-foreground); }
.kv code { font-size: 0.8125rem; }
.token-box { margin-top: 16px; }
.token-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.token { display: block; font-size: 0.75rem; line-height: 1.5; padding: 12px 14px; background: var(--code-bg); color: var(--code-fg); border: 0; border-top: 1px solid var(--rule-strong); overflow-wrap: anywhere; max-height: 7.75em; overflow: auto; user-select: all; }
.claims { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 0.875rem; }
.claims dt { color: var(--muted-foreground); font-family: var(--font-mono); font-size: 0.75rem; padding-top: 2px; }
.claims dd { margin: 0; overflow-wrap: anywhere; }
.json { background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; overflow: auto; margin: 6px 0 8px; white-space: pre; line-height: 1.5; }
.json.small { font-size: 0.75rem; max-height: 340px; }
/* Alert (success / destructive) */
.result-list { display: grid; gap: 8px; margin-top: 12px; }
.result { display: flex; gap: 10px; padding: 12px 16px; border-radius: var(--radius-lg); border: 1px solid; font-size: 0.875rem; background: var(--background); }
.result-ok { border-color: var(--success-border); background: var(--success-soft); }
.result-bad { border-color: var(--destructive-border); background: var(--destructive-soft); }
.result-icon { font-weight: 700; width: 16px; flex: none; }
.result-ok .result-icon { color: var(--success); }
.result-bad .result-icon { color: var(--destructive); }
.warn-text { color: var(--warning); font-weight: 500; }

/* ---------- content ---------- */
.content h3 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-medium); line-height: var(--leading-snug); color: var(--foreground); margin: 24px 0 4px; }
.content-meta { font-size: 0.75rem; color: var(--muted-foreground); margin-bottom: 16px; font-family: var(--font-mono); overflow-wrap: anywhere; }
blockquote { margin: 8px 0 0; padding: 2px 0 2px 16px; border-left: 2px solid var(--border); color: var(--foreground); font-style: italic; font-size: 0.875rem; }
.cut { color: var(--muted-foreground); font-style: italic; }
.content details { margin-top: 16px; }
.content summary, #tel-body summary { cursor: pointer; font-size: 0.875rem; color: var(--foreground); font-weight: 500; width: fit-content; }
.fulltext { white-space: pre-wrap; font-size: 0.875rem; color: var(--muted-foreground); max-height: 320px; overflow: auto; padding: 10px 0; }

/* ---------- telemetry ---------- */
.trail { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 0; flex-wrap: wrap; }
.trail li { display: flex; align-items: center; gap: 6px; padding: 6px 14px 6px 0; font-size: 0.8125rem; color: var(--muted-foreground); }
.trail li + li::before { content: ""; width: 18px; height: 1px; background: var(--border); margin-right: 8px; }
.trail .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--input); background: var(--background); }
.trail li.done { color: var(--foreground); font-weight: 600; }
.trail li.done .dot { border-color: var(--primary); background: var(--primary); }
.trail .by { font-size: 0.75rem; color: var(--muted-foreground); font-weight: 400; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stage-opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); font-size: 0.8125rem; color: var(--muted-foreground); cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.stage-opt:hover { background: var(--accent); }
.stage-opt:has(input:checked) { border-color: var(--primary); }
.stage-opt input { margin-top: 2px; }
.stage-opt select { display: block; margin-top: 8px; height: 30px; padding: 2px 28px 2px 8px; font-size: 0.75rem; background-position: right 6px center; }
.stage-opt strong { color: var(--foreground); font-weight: 600; }

/* ---------- API log ---------- */
.api-log-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#api-log { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.call details { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); }
.call details[open] { background: var(--muted); }
.call summary { display: flex; gap: 8px; align-items: center; padding: 6px 8px; cursor: pointer; font-size: 0.75rem; font-family: var(--font-mono); }
.call summary:hover { background: var(--accent); border-radius: var(--radius-md); }
.call details[open] { padding-bottom: 6px; }
.call details > :not(summary) { margin-left: 8px; margin-right: 8px; }
.call details .json { background: var(--background); }
.call .m { font-weight: 600; width: 36px; flex: none; }
.call .p { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call .ms { color: var(--muted-foreground); }
.s { font-weight: 600; padding: 1px 6px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.s-ok { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.s-warn { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.s-bad { color: var(--destructive); background: var(--destructive-soft); border-color: var(--destructive-border); }

/* ---------- operator ---------- */
.refresh { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-bar { margin-bottom: 16px; }
.admin-form { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--background); font-size: 0.875rem; color: var(--muted-foreground); }
.admin-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.admin-controls input { height: 32px; padding: 4px 10px; width: 220px; max-width: 100%; }
[data-state="locked"] .admin-form, [data-state="bad"] .admin-form { border-color: var(--warning-border); background: var(--warning-soft); color: var(--foreground); }
[data-state="bad"] .admin-status { color: var(--destructive); font-weight: 600; }
[data-state="open"] .admin-form { border-style: dashed; }
/* Stat cards */
/* Figures: a row of numbers under one ink rule, separated by hairlines, no boxes. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; margin-bottom: var(--space-8); border-top: 2px solid var(--rule-strong); }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: var(--space-4) var(--space-5) var(--space-4) 0; border-bottom: 1px solid var(--border); }
.kpi + .kpi { padding-left: var(--space-5); border-left: 1px solid var(--border); }
.kpi-label { font-size: var(--text-2xs); color: var(--muted-foreground); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.kpi-value { font-size: var(--text-3xl); font-weight: var(--weight-normal); font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-tight); line-height: 1.2; }
.kpi-note { font-size: 0.75rem; color: var(--muted-foreground); }
/* Table */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; height: 36px; font-size: var(--text-2xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--muted-foreground); font-weight: var(--weight-semibold); padding: 0 8px; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); white-space: nowrap; vertical-align: middle; }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color 0.15s; }
.table tbody tr:hover td { background: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact td, .table.compact th { padding: 6px 8px; height: auto; font-size: 0.8125rem; }
.muted { color: var(--muted-foreground); }
.strong { font-weight: 600; }
.sub { font-size: 0.75rem; color: var(--muted-foreground); }
.sub-cell { font-size: 0.8125rem; color: var(--muted-foreground); }
.share { display: flex; align-items: center; gap: 8px; min-width: 140px; font-variant-numeric: tabular-nums; font-size: 0.8125rem; color: var(--muted-foreground); }
.share .meter { flex: 1; }
.filter-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row input { flex: 1; font-family: var(--font-mono); font-size: 0.8125rem; height: 32px; padding: 4px 10px; }
/* Badges for telemetry stage and adapter status */
.stage { display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 600; line-height: 1.33; padding: 2px 8px; border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.stage-retrieve { background: var(--primary); border-color: transparent; color: var(--primary-foreground); }
.supply { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.supply-item { display: flex; justify-content: space-between; gap: 10px; padding: var(--space-3) 0; border-top: 1px solid var(--rule-strong); }
.supply-item p { margin: 6px 0 0; font-size: 0.8125rem; color: var(--muted-foreground); }
/* Status: a word and a dot, coloured, without a pill. */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; height: fit-content; padding: 2px 0; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-live { color: var(--success); }
.status-stub { color: var(--muted-foreground); }
.status-warn { color: var(--warning); }
.status-down { color: var(--destructive); }
.supply-item .supply-health { font-size: 0.75rem; }
.chip-open { border-color: var(--success-border); color: var(--success); }
.chip-demo { border-color: var(--warning-border); background: var(--warning-soft); color: var(--warning); }
.callout-demo { border-color: var(--warning-border); background: var(--warning-soft); color: var(--foreground); }
.attribution p { margin: 4px 0 0; font-size: 0.8125rem; }

/* ---------- publishers ---------- */
.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); column-gap: var(--space-12); row-gap: 0; align-items: start; }
.pub { margin: 0; }
.pub-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pub-head h2 { font-size: var(--text-2xl); }
.pub-earn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.pub-earn { border-top: 1px solid var(--rule-strong); }
.pub-earn .kpi { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-bottom: 0; }
.pub-earn .kpi + .kpi { padding-left: var(--space-3); }
.pub-earn .kpi-label { font-size: 0.75rem; color: var(--muted-foreground); }
.pub-earn .kpi-value { font-size: 1.125rem; }
@media (max-width: 420px) { .pub-earn { grid-template-columns: 1fr 1fr; } }
.rules { margin: 0; padding-left: 20px; font-size: 0.875rem; color: var(--muted-foreground); }
.rules li { margin-bottom: 4px; }
.pub details { margin-top: 8px; }
.pub summary { cursor: pointer; font-size: 0.875rem; font-weight: 500; color: var(--foreground); width: fit-content; }


/* ---------- loading, error and empty states ---------- */
.state { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.state strong { color: var(--foreground); }
.state-error { border-color: var(--destructive-border); background: var(--destructive-soft); color: var(--foreground); }
.state-error strong { color: var(--destructive); }
.state .btn { margin-left: auto; }
.spinner { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin 0.7s linear infinite; }
[aria-busy="true"] > .kpis, [aria-busy="true"] .table-wrap, [aria-busy="true"].pub-grid { opacity: 0.6; transition: opacity var(--duration); }
.skeleton { display: block; height: 12px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--muted) 0%, var(--secondary-hover) 50%, var(--muted) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-card { min-height: 220px; display: grid; gap: var(--space-3); align-content: start; }
.skeleton-card .skeleton:first-child { width: 40%; height: 18px; }
.skeleton-card .skeleton:nth-child(2) { width: 70%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.table td.empty { border: 0; padding: var(--space-8) var(--space-4); text-align: center; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--background); }
.footer-inner { max-width: var(--container-app); margin: 0 auto; display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-5) var(--space-6); font-size: var(--text-xs); color: var(--muted-foreground); }
.footer code { font-size: var(--text-2xs); }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  main { padding: var(--space-5) var(--space-3) var(--space-10); }
  .topbar-inner { padding: 0 var(--space-3); gap: var(--space-2); }
  .tabs-inner { padding: 0 var(--space-1); }
  .topbar-link { display: none; }
  .footer-inner { padding: var(--space-5) var(--space-3); }
  .kpis { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .kpi, .kpi + .kpi { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-left: 0; }
  .kpi-value { font-size: var(--text-lg); }
  .kpi-note { display: none; }
  /* Wide tables become stacked rows: each cell shows its column name (data-label). */
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--space-3); padding: 3px 0; border: 0; text-align: left; white-space: normal; }
  .table-stack td.num { text-align: left; }
  .table-stack td::before { content: attr(data-label); color: var(--muted-foreground); font-size: var(--text-xs); font-weight: var(--weight-medium); padding-top: 2px; }
  .table-stack td.empty { display: block; }
  .table-stack td.empty::before { content: none; }
  .table-stack tbody tr:hover td { background: none; }
  .table-wrap:has(.table-stack) { margin: 0; padding: 0; }
}
@media (max-width: 400px) {
  .wordmark-tag { display: none; }
}

/* Routing panel, relevance band and selection: ruled, not boxed */
.routing { margin: 0 0 var(--space-4); border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--border); padding: var(--space-2) 0; }
.routing summary { cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--muted-foreground); width: fit-content; }
.routing summary:hover, .routing[open] summary { color: var(--foreground); }
.routing[open] summary { margin-bottom: var(--space-2); }
.routing .help { margin: var(--space-2) 0; }
.routing-table th { border-top: 0; }
.routing-table tr.muted td { color: var(--muted-foreground); }
/* Routing status reads as a word in the table, not a coloured pill. */
.chip-route-ok, .chip-route-warn, .chip-route-muted { border: 0; background: none; padding: 0; border-radius: 0; font-size: inherit; }
.chip-route-ok { color: var(--success); }
.chip-route-warn { color: var(--warning); font-weight: var(--weight-semibold); }
.chip-route-muted { color: var(--muted-foreground); }
.band-note { font-size: var(--text-sm); color: var(--muted-foreground); margin: 0 0 var(--space-3); padding-left: var(--space-3); border-left: 2px solid var(--border-strong); }
/* The selected offer is marked by a small-caps label and a rule, like the accent elsewhere. */
.chip-selected, .chip-band { border: 0; background: none; border-radius: 0; padding: 0 var(--space-3) 0 0; font-size: var(--text-2xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; font-weight: var(--weight-semibold); }
.chip-selected { color: var(--brand-ink); }
.chip-band { color: var(--muted-foreground); }
.offer.selected { box-shadow: inset 2px 0 0 var(--brand); padding-left: var(--space-3); }
