/* Operator console. Light theme, Valetax brand: navy chrome, one green accent, 16px cards. */

:root {
  --navy: #141921;
  --navy-2: #1f2a37;
  --ink: #141921;
  --ink-2: #374151;
  --grey-1: #4b5563;
  --grey-2: #6b7280;
  --grey-3: #9ca3af;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --canvas: #f6f6f6;
  --card: #ffffff;

  --green: #25c660;
  --green-ink: #12803b;
  --green-pale: #e6f7e6;
  --amber: #e09b1a;
  --amber-ink: #8a5300;
  --amber-pale: #fff4dd;
  --blue: #5890db;
  --blue-ink: #2b5ea6;
  --blue-pale: #eaf1fb;
  --red: #dc3b3b;
  --red-ink: #a42323;
  --red-pale: #fdecec;

  --mark: #fff1b8;
  --mark-strong: #ffe27a;

  --r-card: 16px;
  --r-ctl: 8px;
  --shadow: 0 1px 2px rgba(20, 25, 33, .04), 0 1px 1px rgba(20, 25, 33, .03);
  --shadow-lift: 0 6px 24px rgba(20, 25, 33, .08);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Manrope", "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --topbar-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 var(--font-ui);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -0.01em; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--blue-ink); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--grey-2); }
.pad { padding: 12px 16px; margin: 0; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.num { font-family: var(--font-head); font-variant-numeric: tabular-nums; font-weight: 700; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}
.skip {
  position: absolute; left: 12px; top: -40px; z-index: 50;
  background: var(--card); padding: 8px 12px; border-radius: var(--r-ctl);
}
.skip:focus { top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; color: #fff; text-decoration: none; white-space: nowrap; flex: none; }
.wordmark {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -0.03em;
  color: var(--green);
}
.product { font-weight: 500; font-size: 13.5px; color: rgba(255, 255, 255, 0.82); }
.status { display: flex; gap: 6px; flex-wrap: wrap; }
/* Status pills stay quiet so the business-case button reads as the one action in the bar. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  white-space: nowrap;
  cursor: help;
}
.pill b { font-weight: 500; color: rgba(255, 255, 255, 0.82); }
.biz-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 6px 14px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: var(--r-ctl);
  color: #fff; text-decoration: none; font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.biz-btn svg { width: 15px; height: 15px; flex: none; }
.biz-btn:hover, .biz-btn:focus-visible { border-color: var(--green); color: var(--green); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.pill.off .dot { background: var(--amber); }
.topnav { margin-left: auto; display: flex; align-items: center; }
/* EN | RU switch: same shape as on the business-case page, inverted for the dark bar. */
.lang-switch {
  display: inline-flex; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: var(--r-ctl); overflow: hidden;
}
.lang-switch button {
  border: 0; background: transparent; padding: 3px 10px; cursor: pointer;
  font: 600 12px/1.4 var(--font-ui); color: rgba(255, 255, 255, 0.75);
}
.lang-switch button + button { border-left: 1px solid rgba(255, 255, 255, 0.22); }
.lang-switch button:hover { color: #fff; }
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--navy); }
.lang-switch button:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; border-radius: 0; }

/* ---------- Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 380px;
  height: calc(100vh - var(--topbar-h));
}
.col { min-height: 0; overflow: auto; }
.col-inbox {
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.col-sources { background: var(--card); border-left: 1px solid var(--line); }
.col-work { padding: 20px 24px 40px; outline: none; }
.col-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px 16px 8px;
}
.col-title { font-size: 15px; font-weight: 800; }
.col-count { color: var(--grey-2); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Inbox ---------- */
.inbox-search { padding: 0 12px 8px; }
.inbox-search input {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--canvas);
}
.inbox-search input:focus { background: #fff; border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-pale); }
.inbox-list { flex: 1; overflow: auto; padding: 0 8px 8px; }
.group-head {
  position: sticky; top: 0; z-index: 1; background: var(--card);
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--grey-2); padding: 10px 8px 6px;
}
.tk {
  display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 2px 10px;
  width: 100%; text-align: start; border: 0; background: none; cursor: pointer;
  padding: 9px 8px; border-radius: 10px; position: relative;
}
.tk:hover { background: var(--canvas); }
.tk[aria-current="true"] { background: var(--green-pale); }
.tk[aria-current="true"]::before {
  content: ""; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--green);
}
.lang {
  grid-row: span 2; align-self: start; margin-top: 1px;
  font: 600 10px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .02em;
  height: 20px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 5px; background: var(--line-2); color: var(--grey-1);
}
.tk-text {
  font-size: 13px; color: var(--ink); font-weight: 500;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  unicode-bidi: plaintext;
}
.tk-meta { font-size: 11.5px; color: var(--grey-2); display: flex; gap: 6px; min-width: 0; }
.tk-meta .id { font-family: var(--font-mono); color: var(--grey-3); }
.tk-meta .gold { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gold-route { font-weight: 600; }
.gold-route::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--grey-3); }
.g-auto { color: var(--green-ink); } .g-auto::before { background: var(--green); }
.g-review { color: var(--amber-ink); } .g-review::before { background: var(--amber); }
.g-decline { color: var(--blue-ink); } .g-decline::before { background: var(--blue); }
.gold-cat { font-weight: 400; color: var(--grey-2); }

.compose {
  border-top: 1px solid var(--line); padding: 12px; background: var(--card);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
}
.compose-label { font-size: 12px; font-weight: 600; color: var(--grey-1); }
.compose textarea {
  width: 100%; resize: vertical; min-height: 64px; max-height: 240px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 8px 10px;
  background: var(--canvas); line-height: 1.45;
}
.compose textarea:focus { background: #fff; border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-pale); }
.compose-row { display: flex; gap: 8px; }
.compose-row .btn-primary { flex: 1; justify-content: center; }
.voice-row { flex-wrap: wrap; }
.voice-row .btn { flex: 1 1 auto; justify-content: center; }
.compose-msg { margin: 0; font-size: 12px; color: var(--grey-2); min-height: 0; }
.compose-msg:empty { display: none; }
.compose-msg.is-error { color: var(--red-ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { border-color: #d1d5db; background: var(--canvas); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #1fb456; border-color: #1fb456; }
.btn-primary kbd {
  font: 500 11px var(--font-ui); background: rgba(255, 255, 255, .22); border-radius: 4px; padding: 1px 5px;
}
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red-ink); }
.btn-danger:hover { background: var(--red-pale); border-color: #f5c2c2; }
.btn-mic .mic-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.btn-mic.is-recording { background: var(--red-pale); border-color: var(--red); color: var(--red-ink); }
.btn-mic.is-recording .mic-dot { animation: rec 1s ease-in-out infinite; }
@keyframes rec { 50% { opacity: .25; } }

/* ---------- Empty state ---------- */
.empty { max-width: 560px; margin: 12vh auto 0; text-align: center; }
.empty-kicker { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--grey-2); margin: 0 0 8px; }
.empty-title { font-size: 24px; font-weight: 800; }
.empty-text { color: var(--grey-1); margin: 10px 0 24px; }
.empty-steps {
  list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px;
  counter-reset: s;
}
.empty-steps li {
  counter-increment: s; font-size: 12px; font-weight: 500; color: var(--grey-1);
  padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
}
.empty-steps li::before { content: counter(s) " "; color: var(--grey-3); font-family: var(--font-head); font-weight: 700; }

/* ---------- Result cards ---------- */
.result { max-width: 900px; margin: 0 auto; display: grid; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px 0;
}
.card-title { font-size: 13px; font-weight: 800; color: var(--ink); }
.card-sub { font-size: 12px; color: var(--grey-2); margin-left: auto; }
.card-body { padding: 12px 18px 16px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--grey-2); }

/* Ticket */
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--grey-2); }
.ticket-meta .lang { grid-row: auto; height: 20px; padding: 0 6px; }
.ticket-meta .sep { color: var(--line); }
.expect { display: inline-flex; align-items: center; gap: 6px; }
.expect .tick { font-weight: 700; }
.expect.is-match .tick { color: var(--green-ink); }
.expect.is-miss .tick { color: var(--amber-ink); }
.ticket-text {
  margin: 10px 0 0; font-size: 15.5px; line-height: 1.6; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.ticket-text[dir="rtl"] { font-size: 17px; text-align: right; }
.hit { border-radius: 3px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hit-red { background: var(--red-pale); box-shadow: inset 0 -2px 0 var(--red); }
.hit-amber { background: var(--amber-pale); box-shadow: inset 0 -2px 0 var(--amber); }
.hit-blue { background: var(--blue-pale); box-shadow: inset 0 -2px 0 var(--blue); }
.transcript {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--canvas);
  font-size: 12.5px; color: var(--grey-1); display: flex; flex-wrap: wrap; gap: 4px 12px;
}
.transcript b { color: var(--ink); font-weight: 600; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--canvas); color: var(--ink-2);
  border: 1px solid var(--line);
}
.chip b { font-weight: 500; color: var(--grey-2); }
.chip-red { background: var(--red-pale); border-color: #f6caca; color: var(--red-ink); }
.chip-amber { background: var(--amber-pale); border-color: #f5ddb0; color: var(--amber-ink); }
.chip-blue { background: var(--blue-pale); border-color: #cfe0f6; color: var(--blue-ink); }
.chip-red b, .chip-amber b, .chip-blue b { color: inherit; opacity: .7; }
.chip-flag::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: currentColor; transform: rotate(45deg); }

/* Pipeline trace */
.trace { padding: 14px 18px 16px; }
.rail {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); position: relative;
}
.rail-track, .rail-fill {
  position: absolute; top: 11px; height: 2px; left: calc(100% / 14); right: calc(100% / 14);
  background: var(--line);
}
.rail-fill { background: var(--green); transform-origin: left center; }
.step { position: relative; display: grid; align-content: start; justify-items: center; text-align: center; gap: 2px; padding: 0 4px; }
.node {
  width: 24px; height: 24px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center; background: #fff; border: 2px solid var(--line);
  font: 800 10px/1 var(--font-head); color: var(--grey-3);
}
.step.is-on .node { border-color: var(--green); color: var(--green-ink); background: var(--green-pale); }
.step.st-skip .node { border-style: dashed; border-color: #cbd0d6; background: #fff; color: var(--grey-3); }
.step.st-warn .node { border-color: var(--amber); background: var(--amber-pale); color: var(--amber-ink); }
.step.st-fail .node { border-color: var(--red); background: var(--red-pale); color: var(--red-ink); }
.step.st-info .node { border-color: var(--blue); background: var(--blue-pale); color: var(--blue-ink); }
.step-name { font-size: 12px; font-weight: 600; margin-top: 6px; color: var(--ink); }
.step-ms { font: 700 12px/1.2 var(--font-head); font-variant-numeric: tabular-nums; color: var(--grey-1); }
.step-ms small { font-weight: 600; color: var(--grey-3); font-size: 10.5px; }
.step-detail {
  font-size: 11px; line-height: 1.35; color: var(--grey-2); margin-top: 2px;
  overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.step-state { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.st-skip .step-state { color: var(--grey-3); }
.st-warn .step-state { color: var(--amber-ink); }
.st-fail .step-state { color: var(--red-ink); }
.st-ok .step-state { color: var(--green-ink); }
.st-info .step-state { color: var(--blue-ink); }
.budget { margin-top: 14px; }
.budget-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line-2); gap: 1px; }
.budget-bar span { display: block; height: 100%; background: #b9c0c9; transform-origin: left center; }
.budget-bar span.is-big { background: var(--navy-2); }
.budget-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--grey-2); }
.budget-legend b { color: var(--ink); font-family: var(--font-head); font-variant-numeric: tabular-nums; }

/* Route card */
.route { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0; overflow: hidden; }
.route-side {
  padding: 16px 20px; display: grid; align-content: start; gap: 8px; width: 270px;
  border-right: 1px solid var(--line-2);
}
.route-badge {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start;
  font: 800 15px/1 var(--font-head); padding: 9px 14px 9px 12px; border-radius: 10px;
  letter-spacing: -0.01em;
}
.route-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.route-code { font-family: var(--font-mono); font-size: 11px; color: var(--grey-3); text-transform: none; letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.route-verdict { font-size: 13px; color: var(--ink-2); }
.r-auto .route-badge { background: var(--green-pale); color: var(--green-ink); }
.r-auto .route-badge::before { background: var(--green); }
.r-review .route-badge { background: var(--amber-pale); color: var(--amber-ink); }
.r-review .route-badge::before { background: var(--amber); }
.r-decline .route-badge { background: var(--blue-pale); color: var(--blue-ink); }
.r-decline .route-badge::before { background: var(--blue); }
.r-auto { box-shadow: inset 4px 0 0 var(--green), var(--shadow); }
.r-review { box-shadow: inset 4px 0 0 var(--amber), var(--shadow); }
.r-decline { box-shadow: inset 4px 0 0 var(--blue), var(--shadow); }
.reasons { list-style: none; margin: 0; padding: 14px 18px; display: grid; gap: 8px; align-content: start; }
.reason { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: baseline; font-size: 13.5px; }
html[lang="ru"] .reason { grid-template-columns: 84px minmax(0, 1fr); }
.sev {
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 5px; padding: 3px 0; text-align: center;
}
.sev-block { background: var(--red-pale); color: var(--red-ink); }
.sev-review { background: var(--amber-pale); color: var(--amber-ink); }
.sev-info { background: var(--blue-pale); color: var(--blue-ink); }
.sev-ok { background: var(--green-pale); color: var(--green-ink); }
.reason-code { font-family: var(--font-mono); font-size: 11px; color: var(--grey-3); margin-left: 6px; overflow-wrap: anywhere; }
.reason small { color: var(--grey-2); }

/* Reply */
.banner {
  margin: 12px 18px 0; padding: 12px 14px; border-radius: 12px; font-size: 13px;
  display: grid; gap: 4px;
}
.banner strong { font-family: var(--font-head); font-size: 14px; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner li { margin: 2px 0; }
.banner-amber { background: var(--amber-pale); color: var(--amber-ink); border: 1px solid #f5ddb0; }
.banner-blue { background: var(--blue-pale); color: var(--blue-ink); border: 1px solid #cfe0f6; }
.banner-red { background: var(--red-pale); color: var(--red-ink); border: 1px solid #f6caca; }
.banner .mono { color: inherit; opacity: .8; }
.decline-text {
  margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, .7);
  color: var(--ink); font-size: 14px; line-height: 1.6; white-space: pre-wrap; unicode-bidi: plaintext;
}
.banner + .banner { margin-top: 8px; }

.evidence { padding: 12px 18px 4px; }
.evidence-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--grey-2); margin-left: auto; }
.legend i { display: inline-block; width: 14px; height: 0; border-bottom: 2px solid var(--green); vertical-align: middle; margin-right: 4px; }
.legend i.c { border-bottom: 2px dotted #c3c8cf; }
.sentences {
  font-size: 15px; line-height: 1.75; color: var(--ink); margin: 0; unicode-bidi: plaintext;
}
.sent {
  border-radius: 4px; padding: 1px 1px; cursor: default;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  transition: background-color .15s;
}
.sent-fact { text-decoration: underline 2px var(--green); text-underline-offset: 4px; cursor: pointer; }
.sent-courtesy { color: var(--grey-1); text-decoration: underline dotted 1.5px #c3c8cf; text-underline-offset: 4px; }
.sent-fact:hover, .sent-fact.is-linked, .sent-fact:focus-visible { background: var(--green-pale); }
.sent.is-dim { opacity: .45; }
.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 5px;
  font: 800 10.5px/1 var(--font-head); background: var(--navy); color: #fff;
  vertical-align: 2px;
}
.sentences.is-stale { opacity: .55; }
.stale-note { font-size: 12px; color: var(--amber-ink); margin: 6px 0 0; }

.editor { padding: 12px 18px 0; }
.editor-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; font-weight: 600; color: var(--grey-1); margin-bottom: 6px; }
.editor-label span { font-weight: 400; color: var(--grey-2); font-variant-numeric: tabular-nums; }
.editor textarea {
  width: 100%; min-height: 110px; resize: vertical; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--canvas);
  font-size: 14px; line-height: 1.6;
}
.editor textarea:focus { background: #fff; border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-pale); }
.editor textarea.is-edited { border-color: var(--amber); background: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px 16px; align-items: center; }
.actions .spacer { flex: 1; }
.action-msg { width: 100%; font-size: 12.5px; color: var(--grey-1); margin: 0; }
.action-msg:empty { display: none; }
.action-msg.is-ok { color: var(--green-ink); }
.action-msg.is-error { color: var(--red-ink); }

/* Audit */
.audit {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden;
}
.audit div { background: var(--card); padding: 10px 14px; min-width: 0; }
.audit dt { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--grey-2); }
.audit dd { margin: 2px 0 0; font: 700 13px/1.3 var(--font-head); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit dd.mono { font: 500 12px/1.4 var(--font-mono); }
.audit button.copy { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.errors { font-size: 12.5px; color: var(--red-ink); }

/* Loading */
.loading .rail .node { animation: wait 1.2s ease-in-out infinite; }
.loading .rail .step:nth-child(3) .node { animation-delay: .1s; }
.loading .rail .step:nth-child(4) .node { animation-delay: .2s; }
.loading .rail .step:nth-child(5) .node { animation-delay: .3s; }
.loading .rail .step:nth-child(6) .node { animation-delay: .4s; }
.loading .rail .step:nth-child(7) .node { animation-delay: .5s; }
.loading .rail .step:nth-child(8) .node { animation-delay: .6s; }
@keyframes wait { 50% { border-color: var(--green); background: var(--green-pale); } }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--line-2), #f8f9fa, var(--line-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.error-card { padding: 16px 18px; border-color: #f6caca; background: var(--red-pale); color: var(--red-ink); }
.error-card strong { display: block; font-family: var(--font-head); margin-bottom: 2px; }

/* ---------- Sources ---------- */
.sources-sum { font-size: 12px; color: var(--grey-2); margin: 0; padding: 0 16px 10px; border-bottom: 1px solid var(--line-2); }
.sources { padding: 8px 10px 40px; display: grid; gap: 8px; }
.page { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.page.is-cited { border-color: #bfe8cc; }
.page-head { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; }
.page-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: start;
  border: 0; background: none; padding: 8px 6px; cursor: pointer; border-radius: 8px;
}
.page-toggle:hover { background: var(--canvas); }
.chev { width: 8px; height: 8px; border-right: 1.5px solid var(--grey-2); border-bottom: 1.5px solid var(--grey-2); transform: rotate(-45deg); transition: transform .2s; flex: none; margin: 0 2px; }
.page-toggle[aria-expanded="true"] .chev { transform: rotate(45deg); }
.page-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-badges { display: flex; gap: 4px; margin-left: auto; flex: none; }
.pb { font-size: 10.5px; font-weight: 600; border-radius: 5px; padding: 2px 6px; background: var(--line-2); color: var(--grey-1); }
.pb-cited { background: var(--green-pale); color: var(--green-ink); }
.page-link {
  flex: none; font-size: 11.5px; font-weight: 600; color: var(--blue-ink); text-decoration: none;
  padding: 6px 8px; border-radius: 6px;
}
.page-link:hover { background: var(--blue-pale); }
.page-body { padding: 0 8px 8px; display: grid; gap: 6px; }
.chunk { border-radius: 10px; border: 1px solid var(--line-2); background: var(--canvas); }
.chunk-head {
  width: 100%; display: flex; gap: 8px; align-items: baseline; text-align: start;
  border: 0; background: none; padding: 8px 10px; cursor: pointer; border-radius: 10px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
}
.chunk-head .h { flex: 1; min-width: 0; }
.chunk-head .score { flex: none; font: 600 11px var(--font-mono); color: var(--grey-2); }
.chunk-text { margin: 0; padding: 0 10px 10px; font-size: 12.5px; line-height: 1.6; color: var(--grey-1); white-space: pre-wrap; overflow-wrap: anywhere; }
.chunk-id { display: block; font: 500 10.5px var(--font-mono); color: var(--grey-3); padding: 0 10px 8px; }
.chunk.is-cited { background: #fff; border-color: #bfe8cc; box-shadow: inset 3px 0 0 var(--green); }
.chunk.is-cited .chunk-head { font-weight: 600; color: var(--ink); }
.chunk.is-retrieved { opacity: .62; }
.chunk.is-retrieved:hover, .chunk.is-retrieved:focus-within { opacity: 1; }
.chunk.is-linked { box-shadow: inset 3px 0 0 var(--green), 0 0 0 2px var(--green), 0 6px 20px rgba(37, 198, 96, .18); opacity: 1; }
body.is-linking .chunk:not(.is-linked), body.is-linking .page:not(:has(.is-linked)) { opacity: .4; transition: opacity .2s; }
.chunk, .page { transition: opacity .2s, box-shadow .2s; }
.chunk-tag { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; flex: none; }
.chunk.is-cited .chunk-tag { color: var(--green-ink); }
.chunk.is-retrieved .chunk-tag { color: var(--grey-2); }
mark.q {
  background: var(--mark); color: var(--ink); border-radius: 3px; padding: 0 1px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; cursor: pointer;
}
mark.q.is-linked { background: var(--mark-strong); box-shadow: 0 0 0 2px var(--mark-strong); }
mark.q .cite { vertical-align: 1px; margin-inline-end: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .shell { grid-template-columns: 272px minmax(0, 1fr) 340px; }
  .col-work { padding: 16px 16px 32px; }
}
/* Medium widths: one-line bar; prompt and speech versions remain in the audit footer. */
@media (min-width: 900px) and (max-width: 1140px) {
  .status .pill:nth-child(n+3) { display: none; }
}
@media (max-width: 1100px) {
  .step-detail { -webkit-line-clamp: 2; }
}
@media (max-width: 899px) {
  .audit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: 8px 16px; gap: 8px 14px; }
  .status { width: 100%; order: 3; margin: 0; }
  .shell { display: flex; flex-direction: column; height: auto; }
  .col { overflow: visible; }
  .col-inbox { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .inbox-list { max-height: 320px; overflow: auto; }
  .col-work { padding: 16px; }
  .col-sources { border-left: 0; border-top: 1px solid var(--line); }
  .empty { margin-top: 24px; }
  .empty-title { font-size: 20px; }
  .route { grid-template-columns: 1fr; }
  .route-side { border-right: 0; border-bottom: 1px solid var(--line-2); width: auto; }
  .route-verdict { max-width: none; }
  .rail { grid-template-columns: 1fr; gap: 0; }
  .rail-track, .rail-fill { display: none; }
  .step {
    grid-template-columns: 24px 1fr auto; justify-items: start; text-align: start;
    column-gap: 12px; row-gap: 0; padding: 6px 0; position: relative;
  }
  .step::after { content: ""; position: absolute; left: 11px; top: 30px; bottom: -6px; width: 2px; background: var(--line); }
  .step:last-child::after { display: none; }
  .step .node { grid-row: span 3; }
  .step-name { margin: 0; grid-column: 2; }
  .step-ms { grid-column: 3; grid-row: 1; }
  .step-state { grid-column: 3; grid-row: 2; justify-self: end; }
  .step-detail { grid-column: 2 / 4; -webkit-line-clamp: 2; }
  .reason { grid-template-columns: 64px minmax(0, 1fr); }
  html[lang="ru"] .reason { grid-template-columns: 80px minmax(0, 1fr); }
  .legend { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .actions .spacer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
