/* Agent Trust Gateway pages. World: the carbon-copy delivery docket (direction contract in .impeccable/surfaces/consoles.md).
   Light only: the pages are used in lit back offices, desks and demo halls. Class names are used by common.js,
   kitchen.js, valio.js and play.js; token names (--ink, --line, --ok ...) are shared with play.html. */
:root {
  --bg: #e9edf2;        /* carbon-grey ground */
  --card: #ffffff;      /* the sheet */
  --soft: #f3f5f8;      /* second neutral: table heads, tracks */
  --ink: #1b2a5e;       /* carbon-blue ink */
  --muted: #4d5a7c;     /* secondary ink, tinted from carbon (5.9:1 on white) */
  --line: #cdd4e1;      /* hairline rule */
  --brand: #1b2a5e; --brand-ink: #ffffff; --accent: #e8ecf6;
  --held: #fff4bf; --held-ink: #6b4f00;   /* yellow copy: waits for a person */
  --ok: #17734a; --ok-bg: #e1f2e8;        /* countersign green */
  --warn: #7a5600; --warn-bg: #fff4bf;
  --bad: #a3122f; --bad-bg: #fde4e8;      /* pink copy: refused */
  --lift: 0 1px 1px rgba(27,42,94,.06), 0 2px 6px rgba(27,42,94,.06);
  --focus: 0 0 0 3px rgba(27,42,94,.28);
  --r: 6px;
  color-scheme: light; accent-color: var(--ink);
}
* { box-sizing: border-box; }
html { scrollbar-color: #a9b3c8 var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); caret-color: var(--ink);
  font: 15px/1.5 "Archivo", system-ui, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
::selection { background: var(--held); color: var(--ink); }
a { color: var(--ink); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.top :focus-visible { outline-color: #fff; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--soft); padding: 1px 5px; border-radius: 4px; }
.i { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.17em; flex: none; }

/* shell band */
.top { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5;
  padding: 10px max(16px, calc((100% - 1120px) / 2)); background: var(--ink); color: #fff; }
.brand { display: flex; gap: 11px; align-items: center; margin-right: auto; }
.brand strong { font-size: 16px; font-weight: 700; font-stretch: 87%; letter-spacing: .01em; }
.brand small { display: block; color: #b9c3e0; font-size: 12px; }
.logo { width: 30px; height: 30px; border-radius: 5px; background: #fff; color: var(--ink); display: grid; place-items: center; font-weight: 800; }
.switch { display: flex; border: 1px solid rgba(255,255,255,.28); border-radius: var(--r); overflow: hidden; }
.switch a { color: #dfe5f5; text-decoration: none; font-size: 13px; font-weight: 500; padding: 5px 12px; }
.switch a + a { border-left: 1px solid rgba(255,255,255,.28); }
.switch a:hover { background: rgba(255,255,255,.1); color: #fff; }
.switch a[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 700; }
.status { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.top .pill { border-color: rgba(255,255,255,.3); color: #e7ebf7; }
.pill.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.pill.warn { color: var(--held-ink); background: var(--held); border-color: transparent; }
.pill.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.top .pill .link { color: inherit; }
.live { font-size: 12px; color: #b9c3e0; white-space: nowrap; }
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #6ee0a6; margin-right: 6px; vertical-align: 1px; }
.live.stale::before { background: #ffcf4a; }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }

/* tally strip: the counts on one ruled line, the first opens the queue */
.tally { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 18px; overflow: hidden; }
.cell { padding: 10px 14px; border: 0; background: none; font: inherit; color: inherit; text-align: left; }
.cell + .cell { border-left: 1px solid var(--line); }
.cell b { display: block; font-size: 26px; font-weight: 700; font-stretch: 87%; line-height: 1.15; }
.cell span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.cell.lead { cursor: pointer; }
.cell.lead span { color: var(--ink); font-weight: 600; }
.cell.lead:hover { background: var(--soft); }
.cell.lead.hot { background: var(--held); }
.cell.lead.hot span, .cell.lead.hot b { color: var(--held-ink); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); font-weight: 700; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 3px; }

/* sheets and dockets */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift); padding: 16px 18px; margin-bottom: 14px; }
.card h3 { margin: 0; font-size: 16px; font-weight: 700; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.amount { font-size: 22px; font-weight: 700; font-stretch: 87%; }
/* a held order is a yellow-copy docket: its first row is the docket head, ruled off from the body */
article.card[data-id] { padding-top: 0; }
article.card[data-id] > .row:first-child { margin: 0 -18px 12px; padding: 11px 18px 10px; background: var(--held); border-bottom: 1px dashed #d9c46a; border-radius: var(--r) var(--r) 0 0; }
article.card[data-id] > .row:first-child .muted { color: var(--held-ink); }
.card.held { background: var(--soft); box-shadow: none; }
.card.held p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* the countersign mark */
.sign { display: inline-flex; gap: 7px; align-items: flex-start; padding: 4px 9px 5px; border: 1.5px solid var(--ok); border-radius: 4px; color: var(--ok); font-size: 12.5px; line-height: 1.3; margin: 2px 0; }
.sign .i { margin-top: 1px; }
.sign time { display: block; font-size: 11.5px; opacity: .85; }
#detail-body > .sign { margin: 10px 0 0; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; font-stretch: 87%; background: var(--soft); border-bottom-color: var(--ink); }
td.num, th.num { text-align: right; }
.scroll { overflow-x: auto; }
.clickable { cursor: pointer; }
.clickable:hover td { background: var(--accent); }

/* policy checks */
.checks { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; }
.checks .ic { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-size: 12px; margin-top: 1px; }
.checks .ic .i { width: 14px; height: 14px; stroke-width: 2; }
.ic.pass { background: var(--ok-bg); color: var(--ok); }
.ic.human { background: var(--held); color: var(--held-ink); }
.ic.block { background: var(--bad-bg); color: var(--bad); }
.checks .rule { font-weight: 700; }
.checks.compact li.pass { display: none; }
.checks.compact li.pass.has-ev { display: grid; }  /* a pass resting on weak data still shows its evidence */
.checks .evidence { list-style: disc; margin: 4px 0 0 18px; padding: 0; font-size: 13px; display: grid; gap: 2px; }
.checks .evidence li { display: list-item; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.why { background: var(--accent); padding: 8px 12px; border-radius: 4px; margin: 10px 0; font-size: 14px; white-space: pre-wrap; }
.flag-warn { background: var(--held); color: var(--held-ink); padding: 8px 12px; border-radius: 4px; margin: -4px 0 10px; font-size: 13px; border: 1px solid #e3cf75; }
.card.flag-warn { margin: 0 0 14px; }
.why.det { background: var(--held); white-space: normal; border: 1px solid #e3cf75; }
.findings { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }

/* controls */
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.actions input { flex: 1 1 220px; }
.card .actions:first-child, form.actions { border-top: 0; padding-top: 0; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid #6f7b98; border-radius: 4px; background: var(--card); color: var(--ink); min-width: 0; }
input::placeholder { color: #6b7694; }
input:hover, select:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible { border-color: var(--ink); outline-offset: 0; }
button.primary, button.danger, button.ghost, a.btn { font: inherit; font-weight: 600; border-radius: 4px; padding: 8px 15px; cursor: pointer; border: 1px solid transparent; transition: background-color .15s, filter .15s; }
button.primary, a.btn.primary { background: var(--ok); color: #fff; }
button.primary:hover, a.btn.primary:hover { filter: brightness(1.1); }
button.primary:active { filter: brightness(.95); }
button.danger { background: var(--card); color: var(--bad); border-color: var(--bad); }
button.danger:hover { background: var(--bad-bg); }
button.ghost, a.btn.ghost { background: var(--card); color: var(--ink); border-color: #6f7b98; }
button.danger:active, button.ghost:active, a.btn.ghost:active { filter: brightness(.95); }
button.ghost:hover, a.btn.ghost:hover { background: var(--soft); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 4px 6px; min-height: 24px; font: inherit; font-size: 12.5px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
button.link:hover { color: var(--muted); }
button.link:active { color: var(--ink); }
.export { margin: 0 0 10px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* status tags */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 3px; font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted); }
.tag.placed, .tag.delivered, .tag.v-allow, .tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.pending_approval, .tag.sim, .tag.v-challenge { background: var(--held); color: var(--held-ink); }
.tag.blocked, .tag.rejected, .tag.v-block, .tag.unavailable { background: var(--bad-bg); color: var(--bad); }
.tag.cancelled { background: var(--line); color: var(--muted); }
.chip { display: inline-block; padding: 0 8px; border-radius: 3px; border: 1px solid var(--ink); font-size: 13px; font-weight: 600; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty b { display: block; font-size: 17px; color: var(--ink); margin-bottom: 4px; }

/* audit trail: the stack of copies */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 74px 26px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 13px; padding-top: 3px; white-space: nowrap; }
td:first-child { white-space: nowrap; }
.dot { width: 26px; height: 26px; border-radius: 4px; display: grid; place-items: center; background: var(--soft); color: var(--muted); }
.dot.human { background: var(--ok-bg); color: var(--ok); }
.dot.policy { background: var(--held); color: var(--held-ink); }
.dot.detection { background: var(--bad-bg); color: var(--bad); }
.hash { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 18px; margin-top: 14px; }
.grid2 label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
h3.sub { margin: 24px 0 10px; font-size: 15px; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: 8px; max-width: 820px; width: calc(100% - 24px); padding: 20px 22px; background: var(--card); color: var(--ink); box-shadow: 0 18px 50px rgba(27,42,94,.25); }
dialog::backdrop { background: rgba(20,30,66,.5); }
#detail > form { position: sticky; bottom: -20px; background: var(--card); padding: 12px 0 0; text-align: right; }
#signin { max-width: 440px; }
#signin h3 { margin-top: 0; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 8px); background: var(--ink); color: #fff; font-weight: 500;
  padding: 10px 16px; border-radius: var(--r); opacity: 0; transition: opacity .2s cubic-bezier(.2,.8,.2,1), transform .2s cubic-bezier(.2,.8,.2,1); pointer-events: none; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(27,42,94,.3); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); max-width: min(92vw, 560px); }
@media (prefers-reduced-motion: reduce) { #toast, button { transition: none; } }

/* F-003 buyer research panel (Valio staff) */
.research { border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin: 10px 0; overflow-wrap: anywhere; }
.research.flagged { border-color: #e3cf75; background: var(--held); }
.research.clean { border-color: var(--ok); }
.research .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.research h4 { margin: 8px 0 4px; font-size: 13px; }
.research ul { margin: 0; padding-left: 18px; font-size: 13px; }
.research .facts li.bad { color: var(--bad); } .research .facts li.ok { color: var(--ok); }

/* home page */
.lede { max-width: 1120px; margin: 0 auto; padding: 40px 16px 8px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); gap: 40px; align-items: center; }
.lede h1 { font-size: 40px; font-weight: 700; font-stretch: 87%; line-height: 1.08; letter-spacing: -.015em; margin: 0 0 14px; text-wrap: balance; }
.lede p { font-size: 17px; color: var(--muted); margin: 0 0 12px; max-width: 58ch; }
.example { margin: 0; }
.example .card { margin: 0; }
.example figcaption { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
/* the two consoles as ruled columns, no card chrome */
.home { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; border-top: 2px solid var(--ink); margin-top: 28px; padding-top: 8px; }
.home a.entry { color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 4px; padding: 14px 0 18px; }
.home a.entry h2 { margin: 0; font-size: 20px; font-weight: 700; font-stretch: 87%; }
.home a.entry ul { margin: 6px 0 10px; padding-left: 18px; font-size: 14px; }
.home a.entry .go { margin-top: auto; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.home a.entry:hover h2, .home a.entry:hover .go { text-decoration-thickness: 2px; color: var(--muted); }
.home .tools { border-top: 1px solid var(--line); padding-top: 12px; }
.home .tools { grid-column: 1 / -1; display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); padding: 4px 2px; }

@media (max-width: 760px) {
  .top { position: static; }
  .brand small { display: none; }
  .home a.entry + a.entry { border-top: 1px solid var(--line); }
  .tally { grid-template-columns: repeat(2, 1fr); }
  .cell.lead { grid-column: 1 / -1; }
  .cell + .cell { border-left: 0; }
  .cell { border-top: 1px solid var(--line); }
  .cell.lead { border-top: 0; }
  .cell:nth-child(odd):not(.lead) { border-left: 1px solid var(--line); }
  .lede, .home { grid-template-columns: 1fr; }
  .lede h1 { font-size: 30px; }
  .timeline li { grid-template-columns: 58px 26px 1fr; }
  .actions button { flex: 1 1 auto; white-space: nowrap; }
  .card { padding: 14px; }
  article.card[data-id] > .row:first-child { margin: 0 -14px 12px; padding: 10px 14px; }
  .switch a { padding: 5px 9px; }
}
a.btn { display: inline-block; text-decoration: none; }
.logo .i { width: 18px; height: 18px; stroke-width: 2.4; }
.lede .actions { border-top: 0; padding-top: 0; margin-top: 20px; }
.example article.card[data-id] .actions { justify-content: flex-start; }

/* held order: reasons on the left, lines on the right; one column on narrow screens */
.total { text-align: right; }
.example .total { text-align: left; }  /* the example column is narrow: the head wraps, so amount and limit start under the title */
.limit { font-size: 12.5px; color: var(--held-ink); }
.limit.over { font-weight: 700; }
.docket-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 4px 28px; }
.docket-body > section { min-width: 0; }
.card h4, #detail-body h4 { margin: 4px 0 6px; font-size: 13px; font-weight: 700; color: var(--muted); font-stretch: 87%; }
#detail-body h4 { margin-top: 18px; }
.docket-body .checks { margin-top: 0; }
.docket-body details { margin-top: 10px; }

/* order lines as a list: name, quantity and total on one row, details below */
.lines { border-top: 1px solid var(--line); }
.line { padding: 8px 0; border-bottom: 1px solid var(--line); }
.line-main { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; align-items: baseline; }
.line-name { font-weight: 600; }
.line-qty, .line-total { white-space: nowrap; text-align: right; }
.line-total { font-weight: 700; min-width: 76px; }
.line-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }

/* orders toolbar: status filters left, exports right */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .export { margin: 0; }
.filters { display: flex; flex-wrap: wrap; border: 1px solid #6f7b98; border-radius: 4px; overflow: hidden; background: var(--card); }
.filters button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: none; color: var(--ink); padding: 6px 11px; cursor: pointer; min-height: 32px; }
.filters button + button { border-left: 1px solid var(--line); }
.filters button span { color: var(--muted); margin-left: 3px; }
.filters button:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--soft); }
.filters button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.filters button[aria-pressed="true"] span { color: #c9d1ea; }
.filters button:disabled { color: #8a93ab; cursor: default; opacity: 1; }
.card.flush { padding: 0; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-left: 16px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-right: 16px; }
.card.flush tr:last-child td { border-bottom: 0; }
table.orders td { vertical-align: middle; }
.oid { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

/* order dialog facts */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 18px; margin: 12px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kv dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 2px 0 0; font-size: 14px; }
.kv dd.amount { font-size: 18px; }

@media (max-width: 860px) {
  .docket-body { grid-template-columns: 1fr; }
  .docket-body > section + section { margin-top: 10px; }
}
.show-sm { display: none; }
@media (max-width: 760px) {
  .total { text-align: left; }  /* the head wraps on a phone: amount and limit line start together under the title */
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .filters { width: 100%; }
  .filters button { flex: 1 1 auto; }
}
.agents { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 2px; font-size: 14px; }
.agents li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agents-t { table-layout: fixed; min-width: 760px; }
.agents-t td { overflow-wrap: anywhere; }
