/* Verdict demo, company style, light. Values follow the "4 Компанія, світлий"
   mockup. No inline styles anywhere: the proxy's CSP doesn't allow them. */

:root {
  color-scheme: light;
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --sunken: #F2F4F7;
  --hover: #F7F8FA;
  --ink: #151C26;
  --muted: #56657A;
  --line: #E4E8EE;
  --line-strong: #D6DCE5;
  --brand: #0675E2;
  --brand-hover: #0568CA;
  --brand-deep: #0355A5;
  --brand-soft: #B5D9F9;
  --brand-tint: #E6F1FC;
  --dark: #151C26;
  --on-dark: #FFFFFF;
  --on-dark-muted: #C5CEDA;
  --allow-tint: #E3F4EC;
  --allow-ink: #0B7A52;
  --hold-tint: #FBF0DA;
  --hold-ink: #8F5B00;
  --escalate-tint: #FBE6E3;
  --escalate-ink: #C42B1C;
  --sans: 'Jost', 'Century Gothic', Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

a { color: var(--brand-deep); text-decoration: none; }
a:hover { color: var(--brand); }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, ul:focus-visible, pre:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h2 { margin: 0; font-size: 22px; font-weight: 500; line-height: 1.2; }
.title-sm { font-size: 19px; }
.muted { color: var(--muted); }
.caption { margin: 0; color: var(--muted); font-size: 15px; }

.page {
  max-width: 1400px;
  margin: 0 auto;
  /* Room at the bottom for the floating button, so it never covers the last card. */
  padding: 0 clamp(16px, 3vw, 32px) 96px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Header ───────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding-top: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 500; line-height: 1.1; }
.nav { display: flex; gap: 4px; }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--ink);
  font-size: 17px;
}
.nav-link:hover { color: var(--brand-deep); }
.nav-link[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; }
.topbar-status {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  color: var(--muted);
}
.live { display: inline-flex; align-items: center; gap: 8px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--allow-ink); }
.live[data-state="connecting"] .live-dot { background: var(--line-strong); }
.live[data-state="down"] .live-dot { background: var(--hold-ink); }

/* ── Layout ───────────────────────────────────────────────────────── */

.view { display: flex; flex-direction: column; gap: 20px; }

.card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  background: var(--surface);
  border-radius: 20px;
}
.card-dark { background: var(--dark); color: var(--on-dark); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row { display: flex; flex-wrap: wrap; gap: 20px; }
/* The agent is first in the page. Reversed, the stats sit on its left while both
   fit, and the agent goes on top once they don't. */
.row-top { flex-direction: row-reverse; }
/* Two columns that grow on their own: the feed with the agents and the policy
   under it, and the decision and the queue beside them. A long review queue makes
   only its own column longer. */
.row-mid { flex-wrap: nowrap; align-items: flex-start; }
.main-col { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.side { flex: 1 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.duo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 20px;
}

/* Too narrow for two columns: the columns dissolve into one wrapping row, and the
   cards go in reading order, the decision and the queue right after the feed. */
@media (max-width: 1084px) {
  .row-mid { flex-wrap: wrap; align-items: stretch; }
  .main-col, .side, .duo { display: contents; }
  .card-feed { order: 1; flex: 1 1 100%; }
  .card-decision { order: 2; flex: 1 1 360px; }
  .card-queue { order: 3; flex: 1 1 360px; }
  .card-agents { order: 4; flex: 1 1 300px; }
  .card-policy { order: 5; flex: 1 1 300px; }
}

/* ── Verdict pills and tags ───────────────────────────────────────── */

.verdict {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.verdict-ALLOW { background: var(--allow-tint); color: var(--allow-ink); }
.verdict-HOLD { background: var(--hold-tint); color: var(--hold-ink); }
.verdict-ESCALATE { background: var(--escalate-tint); color: var(--escalate-ink); }

.tag {
  padding: 0 10px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-you { background: var(--brand-tint); color: var(--brand-deep); }

.notice {
  margin: 0;
  padding: 10px 14px;
  background: var(--hold-tint);
  border-radius: 12px;
  color: var(--ink);
  font-size: 15px;
}
.empty { margin: 0; padding: 8px 0; color: var(--muted); }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 500;
}
.link-open { align-self: flex-start; min-height: 32px; }
.link-open::after { content: "\2192"; margin-left: 6px; }
.link-back { align-self: flex-start; }
.link-back::before { content: "\2190"; margin-right: 6px; }

/* ── Stats ────────────────────────────────────────────────────────── */

.card-stats {
  flex: 1 1 320px;
  gap: 14px;
  container-type: inline-size;
}
.stats-body { display: flex; flex-direction: column; gap: 14px; }
.gauge { width: 100%; max-width: 300px; align-self: center; }
.gauge path { fill: none; stroke-width: 30; }
.gauge-track { stroke: var(--line); }
.gauge-allow { stroke: var(--brand); }
.gauge-hold { stroke: var(--brand-soft); }
.gauge-escalate { stroke: var(--brand-deep); }
.gauge-value { fill: var(--ink); font-size: 36px; font-weight: 500; }
.gauge-label { fill: var(--muted); font-size: 15px; }
.legend { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 10px; }
.legend-row dt { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; }
.legend-row dd { margin: 0; font-weight: 500; white-space: nowrap; }
.legend-row .muted { font-size: 15px; }
.legend-sep { padding-top: 8px; border-top: 1px solid var(--line); }
.swatch { flex: none; width: 14px; height: 14px; }
.swatch-allow { background: var(--brand); }
.swatch-hold { background: var(--brand-soft); }
.swatch-escalate { background: var(--brand-deep); }

/* Once the card has the whole row to itself, the gauge and the numbers sit side
   by side instead of leaving the card mostly empty. */
@container (min-width: 600px) {
  .stats-body { flex-direction: row; align-items: center; gap: 40px; }
  .gauge { flex: 0 0 280px; }
  .legend { flex: 1 1 auto; max-width: 420px; }
}

/* ── Talk to the agent ────────────────────────────────────────────── */

.card-talk { flex: 999 1 640px; gap: 16px; padding: 28px; }
.talk-intro { display: flex; flex-direction: column; gap: 4px; }
.talk-title { font-size: 28px; font-weight: 500; line-height: 1.15; }
.talk-form { display: flex; flex-wrap: wrap; gap: 10px; }
/* One line tall like the mockup's input, and grows with the text (see app.js). */
.talk-form textarea {
  flex: 999 1 320px;
  display: block;
  min-width: 0;
  min-height: 54px;
  max-height: 172px;
  padding: 13px 18px;
  background: var(--sunken);
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  line-height: 24px;
  resize: none;
}
.talk-form textarea:focus { outline: none; border-color: var(--brand); }
.talk-form textarea:disabled { color: var(--muted); }
.btn-send {
  flex: 1 1 110px;
  align-self: flex-start;
  min-height: 54px;
  margin-bottom: 4px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  box-shadow: 0 4px 0 var(--brand-deep);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 500;
}
.btn-send:hover:not(:disabled) { background: var(--brand-hover); }
.btn-send:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-deep); }

.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-example {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.3;
  text-align: left;
}
.btn-example:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-deep); }

.steps {
  scroll-margin: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 12px;
}
.step {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--sunken);
  border-radius: 16px;
  overflow-wrap: anywhere;
}
.step-label, .step-empty { color: var(--muted); }
.step-code { font-family: var(--mono); font-size: 14px; white-space: pre-wrap; }
.step-verdict { background: var(--dark); color: var(--on-dark); }
.step-verdict .step-label, .step-verdict .step-empty { color: var(--on-dark-muted); }
.step-verdict-body { display: flex; flex-direction: column; gap: 6px; }
.verdict-word { font-size: 28px; font-weight: 500; line-height: 1.1; }

/* ── Live actions ─────────────────────────────────────────────────── */

.card-feed { gap: 8px; }
.feed-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
}
.feed-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.segmented { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--sunken); }
.seg {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
}
.seg:hover { color: var(--brand-deep); }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 500; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--ink);
}
.feed-row:hover { background: var(--hover); color: var(--ink); }
.feed-row[aria-current="true"] { background: var(--sunken); }
.feed-time { flex: none; width: 72px; color: var(--muted); }
.feed-body { flex: 999 1 280px; min-width: 0; display: flex; flex-direction: column; }
.feed-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.feed-title { font-weight: 500; }
.feed-meta { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.is-new { animation: arrive 0.5s ease-out; }
@keyframes arrive {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .is-new { animation: none; }
}

/* ── Decision card and queue ──────────────────────────────────────── */

.outcome {
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--sunken);
  border-radius: 14px;
}
.outcome-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.outcome-row dt { flex: 0 0 110px; color: var(--muted); }
.outcome-row dd { flex: 1 1 160px; margin: 0; min-width: 0; font-weight: 500; }

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.check {
  display: flex;
  flex-direction: column;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.check-name { font-weight: 500; }
.check-fail { color: var(--escalate-ink); }
.check-pass { color: var(--allow-ink); }
.check-detail { color: var(--muted); font-size: 15px; }
.severity { margin: 0; color: var(--muted); font-size: 15px; }
.replay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 6px; }
.btn-replay {
  min-height: 44px;
  padding: 0 20px;
  border: 2px solid var(--brand);
  border-radius: 12px;
  background: var(--surface);
  color: var(--brand-deep);
  font-weight: 500;
}
.btn-replay:hover:not(:disabled) { background: var(--brand-tint); }
.replay-result { flex: 1 1 170px; min-width: 0; color: var(--muted); font-size: 15px; }
.replay-result[data-state="mismatch"], .replay-result[data-state="error"] { color: var(--escalate-ink); }

.card-queue { gap: 6px; }
.queue-count { font-size: 22px; font-weight: 500; color: var(--brand-deep); }
.queue {
  max-height: 340px;
  overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent;
  list-style: none;
  margin: 0;
  padding: 0;
}
.queue-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.queue-text { flex: 999 1 190px; min-width: 0; display: flex; flex-direction: column; }
.queue-title { align-self: flex-start; color: var(--ink); font-weight: 500; }
.queue-title:hover { color: var(--brand-deep); }
@media (pointer: coarse) {
  .queue-title { display: flex; align-items: center; min-height: 44px; }
}
.queue-meta { color: var(--muted); font-size: 15px; }
.queue-verdict { font-weight: 500; }
.queue-verdict-ALLOW { color: var(--allow-ink); }
.queue-verdict-HOLD { color: var(--hold-ink); }
.queue-verdict-ESCALATE { color: var(--escalate-ink); }
.queue-actions { flex: none; display: flex; gap: 6px; }
.btn-approve, .btn-reject { min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; }
.btn-approve { background: var(--brand); color: #FFFFFF; }
.btn-approve:hover:not(:disabled) { background: var(--brand-hover); }
.btn-reject { background: var(--sunken); color: var(--ink); }
.btn-reject:hover:not(:disabled) { background: var(--line); }

/* ── Agents, policy ───────────────────────────────────────────────── */

.card-agents, .card-policy { gap: 8px; }
.agents { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.agent { display: flex; justify-content: space-between; gap: 12px; }
.agent-total { font-weight: 500; }

.policy-version { font-size: 22px; font-weight: 500; color: var(--brand-deep); }
.policy-more summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--brand-deep);
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}
.policy-more summary::-webkit-details-marker { display: none; }
.policy-more summary::after { content: "\2193"; margin-left: 6px; }
.policy-more[open] summary::after { content: "\2191"; }
.policy-more summary:hover { color: var(--brand); }
.policy-more summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.policy-details { display: flex; flex-direction: column; gap: 10px; }
.policy-details:not(:empty) { margin-top: 6px; }
.policy-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 15px; }
.policy-rules li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.policy-other { margin: 0; color: var(--muted); font-size: 15px; }
.policy-name { color: var(--ink); font-weight: 500; }
.policy-old {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
}

/* ── Decisions screen ─────────────────────────────────────────────── */

.list-head { display: flex; flex-direction: column; gap: 4px; }
.list-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
  gap: 10px;
  padding: 6px 0 8px;
}
.list-filters label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 15px;
}
.list-filters select, .list-filters input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  background: var(--sunken);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  color-scheme: light;
  font: inherit;
  font-size: 16px;
}
.list-filters select:focus, .list-filters input:focus { outline: none; border-color: var(--brand); }
.btn-soft {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--sunken);
  color: var(--ink);
  font-weight: 500;
}
.btn-soft:hover:not(:disabled) { background: var(--line); }

.list-table { width: 100%; border-collapse: collapse; }
.list-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
  text-align: left;
}
.list-table tbody tr { position: relative; border-bottom: 1px solid var(--line); }
.list-table tbody tr:hover { background: var(--hover); }
.list-table td { padding: 12px; font-size: 15px; overflow-wrap: anywhere; }
.list-time { color: var(--muted); white-space: nowrap; }
/* The whole row opens the decision, and the link is what a keyboard lands on. */
.list-link { color: var(--ink); font-weight: 500; }
.list-link::after { content: ""; position: absolute; inset: 0; }
.list-summary { display: block; color: var(--muted); }
.list-version { white-space: nowrap; }
.list-reasons { color: var(--muted); }
.list-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

/* ── Decision page ────────────────────────────────────────────────── */

.card-page { gap: 14px; }
.page-head { flex-wrap: wrap; align-items: flex-start; }
.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h2 span { color: var(--muted); font-weight: 400; }
.page-message { margin: 0; color: var(--ink); }
.page-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-note {
  margin: 0;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
}
.page-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px;
}
.page-fact-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--sunken);
  border-radius: 16px;
}
.page-fact-block h3 { margin: 0; font-size: 17px; font-weight: 500; }
.page-action { margin: 0; font-family: var(--mono); font-size: 14px; font-weight: 500; }
.fact-list { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.fact-row { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.fact-row dt { color: var(--muted); }
.fact-row dd { margin: 0; font-family: var(--mono); font-size: 14px; text-align: right; overflow-wrap: anywhere; }
.page-rules-title { margin: 6px 0 0; font-size: 19px; font-weight: 500; }

/* ── Responsive ───────────────────────────────────────────────────── */

/* The table turns into cards. */
@media (max-width: 760px) {
  .list-table, .list-table tbody, .list-table tr, .list-table td { display: block; }
  .list-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .list-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 12px 0;
  }
  .list-table tbody tr:hover { background: none; }
  .list-table td { padding: 0; }
  .list-time { grid-column: 1; grid-row: 1; align-self: center; }
  .list-verdict { grid-column: 2; grid-row: 1; }
  .list-action { grid-column: 1 / -1; margin-top: 4px; }
  .list-table td[data-label]:not([data-label=""]) { grid-column: 1 / -1; color: var(--muted); }
  .list-table td[data-label]:not([data-label=""])::before { content: attr(data-label) ": "; }
  .list-version { white-space: normal; }
  .list-none { display: none !important; }
}

@media (max-width: 640px) {
  .page { gap: 16px; padding-bottom: 88px; }
  .view, .row { gap: 16px; }
  .topbar { padding-top: 16px; gap: 8px 16px; }
  .brand h1 { font-size: 26px; }
  .nav { order: 3; flex: 1 1 100%; padding: 3px; border-radius: 14px; background: rgba(255, 255, 255, 0.5); }
  .nav-link { flex: 1 1 0; justify-content: center; }

  .card { padding: 20px; }
  .card-talk { padding: 20px; }
  .talk-title { font-size: 24px; }
  .btn-send { flex-basis: 100%; }
  .step-code { white-space: pre; overflow-x: auto; }

  .list-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn-clear { grid-column: 1 / -1; }
}

@media (max-width: 540px) {
  .feed-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "time verdict" "body body";
    gap: 4px 12px;
    padding: 12px 10px;
  }
  .feed-time { grid-area: time; width: auto; }
  .feed-row .verdict { grid-area: verdict; }
  .feed-body { grid-area: body; }
}

@media (max-width: 400px) {
  .topbar-status { gap: 4px 12px; font-size: 15px; }
  /* A date input doesn't fit half of a phone this narrow. */
  .list-filters label:has(input) { grid-column: 1 / -1; }
}
