/* Operations UI. Neutral white and light-grey surfaces, thin dividers, compact type, one restrained blue
   for links and primary actions, grey selected states. Proportions follow the Stuut product screens
   (sidebar, detail cards with key/value rows, activity list, plain tables). No brand assets are reused. */
:root {
  --canvas: #F6F7F9;
  --surface: #FFFFFF;
  --ink: #1A1F26;
  --ink-2: #5B6675;       /* 5.6:1 on canvas, 6.0:1 on white */
  --line: #E6E8EC;
  --line-strong: #D0D5DD;
  --hover: #F4F5F7;
  --selected: #EEF0F3;
  --blue: #1A66D6;        /* 5.2:1 on white: links, primary action */
  --blue-strong: #1553B0;

  --ok: #1A7048;   --ok-bg: #EAF5EE;
  --bad: #B3261E;  --bad-bg: #FCEDEB;
  --warn: #8A5300; --warn-bg: #FBF1DE;
  --info: #1A56A8; --info-bg: #EAF1FB;

  --r: 6px;
  --font: "Inter", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 14px/1.45 var(--font); }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1 { font-size: 18px; line-height: 1.3; font-weight: 600; }
h2 { font-size: 14px; font-weight: 600; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 0.93em; }
.num { font-variant-numeric: tabular-nums; }
.muted, .sub, .hint, .s { color: var(--ink-2); }
.strong { font-weight: 600; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--r); z-index: 20; }
.skip:focus { top: 8px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink); font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-strong); border-color: var(--blue-strong); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); background: var(--hover); }
.btn:disabled { background: #EEF0F3; border-color: #EEF0F3; color: #5B6675; cursor: not-allowed; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
input[type="password"], input[type="text"] { height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); font: 400 14px var(--font); color: var(--ink); background: var(--surface); }

.ico { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap; vertical-align: middle; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.neutral { color: var(--ink-2); background: #EEF0F3; }
.badge.sim { color: var(--warn); background: var(--surface); box-shadow: inset 0 0 0 1px #C99A3A; }
.tag { display: inline-block; margin-right: 4px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-2); font-size: 12px; line-height: 18px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: #98A2B3; flex: none; }
.status, .conn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status { padding: 2px 8px; border-radius: 4px; background: #EEF0F3; color: var(--ink); font-weight: 500; }
.status[data-tone="ok"] { background: var(--ok-bg); color: var(--ok); }
.status[data-tone="ok"] .dot { background: var(--ok); }
.status[data-tone="info"] { background: var(--info-bg); color: var(--info); }
.status[data-tone="info"] .dot { background: var(--info); }
.status[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }
.status[data-tone="warn"] .dot { background: #C99A3A; }
.conn[data-state="ok"] .dot { background: var(--ok); }
.conn[data-state="retry"] .dot { background: #C99A3A; }
.conn[data-state="down"] { color: var(--bad); }
.conn[data-state="down"] .dot { background: var(--bad); }

/* ---------- shell ---------- */
body.app { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 12px 10px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.mark { width: 18px; height: 18px; border-radius: 4px; background: var(--ink); position: relative; flex: none; }
.mark::after { content: ""; position: absolute; left: 5px; top: 5px; width: 8px; height: 8px; border-radius: 2px; background: var(--surface); }
.nav-group { margin: 12px 8px 4px; color: var(--ink-2); font-size: 12px; }
.side nav { display: grid; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: var(--r); color: var(--ink); font-size: 13px; font-weight: 500; }
.nav-item .ico { color: var(--ink-2); width: 15px; height: 15px; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.is-current { background: var(--selected); }
.nav-item.is-current .ico { color: var(--ink); }
.nav-item .cnt { margin-left: auto; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: 12px; }
.side-foot div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side-foot dt { color: var(--ink-2); }
.side-foot .conn { font-size: 12px; }

.main { padding: 16px 20px 24px; min-width: 0; outline: none; }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.titlebar .left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.titlebar h1 .mono { font-weight: 600; }
.titlebar .crumb { color: var(--ink-2); font-size: 13px; }
.ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrls .msg { color: var(--bad); font-size: 13px; }
.pinform { display: flex; gap: 6px; }
.pinform input { width: 130px; }

.notice { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-left: 3px solid #C99A3A; border-radius: var(--r); background: var(--surface); font-size: 13px; }
.notice .ico { margin-top: 2px; color: var(--warn); }
.notice strong { font-weight: 600; margin-right: 6px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.card-head .hint { font-size: 12px; }
.empty { color: var(--ink-2); padding: 16px 14px; text-align: left; font-size: 13px; }

.detail { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 12px; align-items: start; }
.kv { padding: 4px 14px 6px; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-2); flex: none; }
.kv dd { text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.kv dd.num { font-weight: 600; }
.kv .total dt { color: var(--ink); font-weight: 600; }
.kv .total dd { font-size: 16px; font-weight: 600; }

.outcome { padding: 2px 14px; }
.outcome li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.outcome li:last-child { border-bottom: 0; }
.o-mark { width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; background: #EEF0F3; color: var(--ink-2); }
.o-mark .ico { width: 12px; height: 12px; }
.o-ok .o-mark { background: var(--ok-bg); color: var(--ok); }
.o-bad .o-mark { background: var(--bad-bg); color: var(--bad); }
.o-warn .o-mark { background: var(--warn-bg); color: var(--warn); }
.o-info .o-mark { background: var(--info-bg); color: var(--info); }
.o-sim .o-mark { background: var(--surface); color: var(--warn); box-shadow: inset 0 0 0 1px #C99A3A; }
.o-title { font-weight: 500; }
.o-detail { color: var(--ink-2); font-size: 13px; }

.pay-state { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.pay-state .ico { margin-top: 2px; }
.pay-state strong { color: var(--ink); font-weight: 600; }
.card-foot { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }

/* conversation as an activity list */
.tx { min-height: 200px; max-height: max(320px, calc(100vh - 140px)); overflow-y: auto; scroll-behavior: smooth; }
.turn { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.turn:last-child { border-bottom: 0; }
.turn .who { font-size: 13px; font-weight: 500; color: var(--ink-2); display: grid; align-content: start; gap: 1px; }
.turn.participant .who > span:first-child { color: var(--ink); }
.turn .ltag { font-weight: 400; font-size: 12px; }
.turn .txt { font-size: 15px; line-height: 1.45; max-width: 80ch; }
.turn.participant { background: #FAFBFC; }
.turn.prov .txt { color: var(--ink-2); }

.onboard { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: center; padding: 20px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.onboard.compact { grid-template-columns: 1fr; padding: 14px; }
.onboard .qr { padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.onboard .qr svg { display: block; width: 100%; height: auto; }
.onboard h2 { font-size: 16px; margin-bottom: 2px; }
.onboard .lead { color: var(--ink-2); max-width: 60ch; margin-bottom: 12px; }
.steps { display: grid; gap: 8px; margin-bottom: 12px; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.steps .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.steps li.done { color: var(--ink-2); }
.steps li.done .n { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
.joinurl { color: var(--ink-2); overflow-wrap: anywhere; font-size: 13px; }

/* ---------- tables, inspector ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; padding: 7px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FAFBFC; }
.tbl .t-time { width: 84px; white-space: nowrap; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tbl .sub { font-size: 12px; }
.tbl .amount, .tbl th.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.is-error td { background: #FEF8F7; }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; }

.inspector { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.inspector > summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 40px; padding: 8px 14px; cursor: pointer; list-style: none; }
.inspector > summary::-webkit-details-marker { display: none; }
.inspector > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: rotate(-45deg); transition: transform 0.15s; }
.inspector[open] > summary::before { transform: rotate(45deg); }
.ins-title { font-weight: 600; }
.ins-sum { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.ins-body { border-top: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 9px 10px 8px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-2); font: 500 13px var(--font); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.count { margin-left: 4px; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.note { padding: 10px 14px 2px; color: var(--ink-2); font-size: 13px; max-width: 100ch; }
[role="tabpanel"] { max-height: 400px; overflow: auto; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics > div { padding: 10px 14px; border-left: 1px solid var(--line); }
.metrics > div:first-child { border-left: 0; }
.metrics dt { color: var(--ink-2); font-size: 12px; }
.metrics dd.num { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.metrics dd.s { font-size: 12px; }

/* ---------- start page ---------- */
.start-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 12px; align-items: start; }
.card .body { padding: 14px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; max-width: 260px; }
.field label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.plain-steps { display: grid; gap: 6px; counter-reset: s; }
.plain-steps li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; counter-increment: s; }
.plain-steps li::before { content: counter(s) "."; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- customer pages (mobile first) ---------- */
body.person { background: var(--canvas); }
.sheet { max-width: 480px; margin: 0 auto; padding: 16px 16px 32px; font-size: 15px; }
.sheet .brand { padding: 0; margin-bottom: 16px; }
.sheet h1 { font-size: 20px; margin-bottom: 4px; }
.sheet .lead { color: var(--ink-2); margin-bottom: 16px; }
.sheet .card { margin-bottom: 12px; }
.sheet .card + .card { margin-top: 0; }
.sheet .card > h2 { padding: 12px 14px 0; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.sheet .kv dd.amount { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet .kv > div { padding: 9px 0; }
.info-line { display: flex; gap: 8px; padding: 0 14px 12px; color: var(--ink-2); font-size: 13px; }
.info-line .ico { margin-top: 2px; }
.next { padding: 8px 14px 12px; display: grid; gap: 10px; counter-reset: n; }
.next li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; counter-increment: n; }
.next li::before { content: counter(n); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; }
.check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-of-type { border-bottom: 0; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue); }
.small { font-size: 13px; color: var(--ink-2); }
.fallback { padding: 12px 14px; }
.fallback a { overflow-wrap: anywhere; }
.state-msg { padding: 16px 0; }
.state-msg h2 { font-size: 16px; margin-bottom: 4px; }

/* ---------- dialogs, fatal ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(26, 31, 38, 0.36); z-index: 30; }
.modal .box { width: min(420px, 100%); padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(26, 31, 38, 0.12); }
.modal h2 { font-size: 15px; margin-bottom: 6px; }
.modal p { color: var(--ink-2); margin-bottom: 14px; }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--canvas); z-index: 40; text-align: center; }
.fatal h1 { margin-bottom: 6px; }
.fatal p { color: var(--ink-2); margin-bottom: 12px; }

/* ---------- responsive ---------- */
@media (min-width: 1700px) {
  body { font-size: 16px; }
  body.app { grid-template-columns: 232px minmax(0, 1fr); }
  h1 { font-size: 20px; } h2 { font-size: 16px; }
  .turn { grid-template-columns: 160px minmax(0, 1fr); padding: 11px 16px; }
  .turn .txt { font-size: 18px; }
  .turn .who, .nav-item, .o-detail, .tbl, .btn, .status { font-size: 14px; }
  .detail { grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); }
  .steps li { font-size: 18px; }
  .onboard { grid-template-columns: 320px minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .detail, .start-grid { grid-template-columns: 1fr; }
  .tx { max-height: 460px; }
}
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; }
  .nav-group, .side-foot { display: none; }
  .side nav { display: flex; margin-left: auto; }
  .nav-item .ico, .nav-item .cnt { display: none; }
  .main { padding: 12px; }
  .turn { grid-template-columns: 1fr; gap: 2px; }
  .turn .who { display: flex; gap: 8px; }
  .onboard { grid-template-columns: 1fr; gap: 16px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.logo-pig { display: block; flex: none; object-fit: contain; }
