/* ===========================================================================
   Sitewise — Components
   =========================================================================== */

/* --- Button ----------------------------------------------------------- */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-4);
  min-height: 34px; padding: 0 var(--s-8);
  border: 1px solid var(--line-control);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--t-base); font-weight: 550; letter-spacing: var(--tr-normal);
  white-space: nowrap;
  transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease,
              color var(--dur-1) ease, transform var(--dur-1) var(--ease-out);
}
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.btn:hover { background: var(--surface); border-color: var(--ink-muted); }
.btn:active { transform: scale(0.975); }
.btn[disabled], .btn[aria-disabled='true'] {
  opacity: 0.45; pointer-events: none;
}

.btn--primary {
  background: var(--ink); border-color: var(--ink); color: var(--ink-invert);
}
.btn--primary:hover { background: oklch(0.28 0.01 62); border-color: oklch(0.28 0.01 62); }

.btn--brand {
  background: var(--brand); border-color: color-mix(in oklch, var(--brand) 82%, black);
  color: oklch(0.16 0.03 62); font-weight: 650;
}
.btn--brand:hover { background: var(--brand-hover); color: oklch(0.99 0 0); }

.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }

.btn--danger { color: var(--negative); border-color: var(--negative-edge); }
.btn--danger:hover { background: var(--negative-wash); border-color: var(--negative); }

.btn--sm { min-height: 28px; padding: 0 var(--s-6); font-size: var(--t-sm); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { min-height: 42px; padding: 0 var(--s-12); font-size: var(--t-md); }
.btn--icon { padding: 0; width: 34px; min-height: 34px; }
.btn--icon.btn--sm { width: 28px; min-height: 28px; }
.btn--block { width: 100%; }

/* Segmented control */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.seg__btn {
  border: 0; background: transparent; color: var(--ink-muted);
  padding: var(--s-3) var(--s-6); border-radius: var(--r-xs);
  font-size: var(--t-sm); font-weight: 550;
  display: inline-flex; align-items: center; gap: var(--s-3);
  transition: background-color var(--dur-1) ease, color var(--dur-1) ease;
}
.seg__btn svg { width: 14px; height: 14px; }
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-pressed='true'], .seg__btn[aria-selected='true'] {
  background: var(--bg); color: var(--ink); font-weight: 650;
  box-shadow: 0 1px 2px oklch(0.2 0 0 / 0.08);
}

/* --- Form fields ------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.field__label {
  font-size: var(--t-xs); font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: var(--tr-label);
  display: flex; align-items: center; gap: var(--s-3);
}
.field__hint { font-size: var(--t-xs); color: var(--ink-muted); }
.field__err { font-size: var(--t-xs); color: var(--negative); font-weight: 550; }

.input, .select, .textarea {
  width: 100%;
  min-height: 34px;
  padding: var(--s-4) var(--s-6);
  border: 1px solid var(--line-control);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--t-base);
  transition: border-color var(--dur-1) ease, box-shadow var(--dur-1) ease, background-color var(--dur-1) ease;
}
.textarea { min-height: 84px; resize: vertical; line-height: var(--lh-body); padding: var(--s-5) var(--s-6); }
.input::placeholder, .textarea::placeholder { color: var(--ink-muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 22%, transparent);
}
.input[readonly] { background: var(--surface); color: var(--ink-2); }
.input.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.select {
  appearance: none;
  padding-right: var(--s-16);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f5b56' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-5) center;
}

.input-group { display: flex; align-items: stretch; }
.input-group > .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group > .input-group__addon {
  display: inline-flex; align-items: center; padding: 0 var(--s-6);
  border: 1px solid var(--line-control); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface); color: var(--ink-muted); font-size: var(--t-sm);
}
.input-group--prefix > .input-group__addon:first-child {
  border-left: 1px solid var(--line-control); border-right: 0;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
.input-group--prefix > .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* Search */
.search { position: relative; display: flex; align-items: center; }
.search svg {
  position: absolute; left: var(--s-6); width: 15px; height: 15px;
  color: var(--ink-faint); pointer-events: none;
}
.search .input { padding-left: var(--s-14); }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: var(--s-5); cursor: pointer; font-size: var(--t-base); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); flex: 0 0 auto; cursor: pointer; }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: var(--s-6); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  width: 36px; height: 20px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line-control);
  position: relative; flex: 0 0 auto;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) ease;
}
.toggle__track::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--bg);
  box-shadow: 0 1px 2px oklch(0.2 0 0 / 0.25);
  transition: transform var(--dur-2) var(--ease-out);
}
.toggle input:checked + .toggle__track { background: var(--positive-fill); border-color: color-mix(in oklch, var(--positive-fill) 80%, black); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --- Badge / pill ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: 2px var(--s-5); border-radius: var(--r-pill);
  font-size: var(--t-2xs); font-weight: 650; letter-spacing: 0.01em;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  white-space: nowrap; line-height: 1.5;
}
.badge svg { width: 11px; height: 11px; }
.badge--attn { background: var(--brand-wash); border-color: var(--brand-edge); color: var(--brand-ink); }
.badge--pos  { background: var(--positive-wash); border-color: var(--positive-edge); color: var(--positive); }
.badge--neg  { background: var(--negative-wash); border-color: var(--negative-edge); color: var(--negative); }
.badge--info { background: var(--info-wash); border-color: var(--info-edge); color: var(--info); }
.badge--solid{ background: var(--ink); border-color: var(--ink); color: var(--ink-invert); }
.badge--dot::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 auto;
}

/* Channel chips carry a source glyph */
.chip-src {
  display: inline-flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-xs); color: var(--ink-muted); font-weight: 550;
}
.chip-src svg { width: 13px; height: 13px; }

/* --- Avatar ----------------------------------------------------------- */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  font-size: var(--t-2xs); font-weight: 700; letter-spacing: 0;
  border: 1px solid var(--line);
}
.avatar--lg { width: 36px; height: 36px; font-size: var(--t-xs); }
.avatar--agent { background: var(--ink); color: var(--brand); border-color: var(--ink); }
.avatar--agent svg { width: 15px; height: 15px; }

/* ===========================================================================
   Table — the workhorse. Hairlines, tabular figures, sticky head.
   =========================================================================== */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); }

.table th {
  position: sticky; top: 0; z-index: var(--z-raised);
  text-align: left; font-weight: 600; font-size: var(--t-2xs);
  text-transform: uppercase; letter-spacing: var(--tr-label);
  color: var(--ink-muted);
  padding: var(--s-5) var(--s-6);
  background: var(--bg);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table th.num, .table td.num { text-align: right; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th.sortable::after {
  content: ''; display: inline-block; width: 0; height: 0; margin-left: var(--s-3);
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
  opacity: 0; transition: opacity var(--dur-1) ease;
}
.table th[data-dir='asc']::after  { border-bottom: 4px solid currentColor; opacity: 1; }
.table th[data-dir='desc']::after { border-top: 4px solid currentColor; opacity: 1; }

.table td {
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--dur-1) ease; }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr.is-selected { background: var(--info-wash); }
.table tbody tr.is-attn td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.table tbody tr.is-new {
  animation: rowLand var(--dur-4) var(--ease-out) both;
}
@keyframes rowLand {
  from { background: var(--brand-wash-2); opacity: 0; transform: translateY(-4px); }
  to   { background: transparent; opacity: 1; transform: none; }
}
.table tfoot td {
  padding: var(--s-6);
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-weight: 650;
  background: var(--surface);
}
.table--rowlink tbody tr { cursor: pointer; }
.table .cellsub { display: block; font-size: var(--t-2xs); color: var(--ink-muted); margin-top: 1px; }
.table .cellmain { font-weight: 550; color: var(--ink); }

/* Inline-editable cell */
select.cell-edit {
  appearance: none; padding-right: var(--s-10);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a8a5a1' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 3px center;
  text-overflow: ellipsis;
}
.cell-edit {
  display: block; width: 100%; border: 1px solid transparent; border-radius: var(--r-xs);
  padding: var(--s-2) var(--s-3); margin: calc(var(--s-2) * -1) calc(var(--s-3) * -1);
  background: transparent; text-align: inherit; font: inherit; letter-spacing: inherit;
  transition: border-color var(--dur-1) ease, background-color var(--dur-1) ease;
}
.cell-edit:hover { border-color: var(--line-control); background: var(--bg); }
.cell-edit:focus {
  outline: none; border-color: var(--brand); background: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 20%, transparent);
}

/* Toolbar above a table */
.toolbar {
  display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap;
  padding: var(--s-6) var(--s-8);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.toolbar .search { flex: 1 1 220px; max-width: 320px; }
.toolbar__spacer { flex: 1 1 auto; }
.toolbar__count { font-size: var(--t-xs); color: var(--ink-muted); font-family: var(--font-mono); }

/* Bulk-action bar slides up when rows are selected */
.bulkbar {
  position: sticky; bottom: var(--s-8); z-index: var(--z-dropdown);
  margin: var(--s-8) auto 0; width: fit-content;
  display: flex; align-items: center; gap: var(--s-6);
  padding: var(--s-5) var(--s-6) var(--s-5) var(--s-10);
  background: var(--ink); color: var(--ink-invert);
  border-radius: var(--r-pill); box-shadow: var(--sh-pop);
  font-size: var(--t-sm);
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2) ease;
}
.bulkbar[hidden] { display: none; }
.bulkbar .btn { background: transparent; border-color: oklch(1 0 0 / 0.24); color: var(--ink-invert); }
.bulkbar .btn:hover { background: oklch(1 0 0 / 0.12); border-color: oklch(1 0 0 / 0.4); }

/* ===========================================================================
   Confidence meter — the agent showing its work
   =========================================================================== */
.conf {
  display: inline-flex; align-items: center; gap: var(--s-4);
  font-family: var(--font-mono); font-size: var(--t-2xs);
  font-variant-numeric: tabular-nums; color: var(--ink-muted);
}
.conf__track {
  width: 34px; height: 4px; border-radius: var(--r-pill);
  background: var(--surface-3); overflow: hidden; flex: 0 0 auto;
}
.conf__fill {
  height: 100%; border-radius: inherit; background: var(--positive-fill);
  transition: width var(--dur-4) var(--ease-out);
}
.conf[data-level='med'] .conf__fill { background: var(--brand); }
.conf[data-level='low'] .conf__fill { background: var(--negative-fill); }
.conf[data-level='med'] { color: var(--brand-ink); }
.conf[data-level='low'] { color: var(--negative); }

/* ===========================================================================
   Extraction field — value + provenance + confidence
   =========================================================================== */
.xfield {
  display: grid; grid-template-columns: 148px minmax(0, 1fr);
  gap: var(--s-6); align-items: center;
  padding: var(--s-5) var(--s-8);
  border-bottom: 1px solid var(--line-faint);
  transition: background-color var(--dur-2) ease;
  position: relative;
}
.xfield:last-child { border-bottom: 0; }
.xfield:hover, .xfield.is-linked { background: var(--surface); }
.xfield.is-attn { background: var(--brand-wash); }
.xfield.is-attn::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--brand);
}
.xfield__key {
  font-size: var(--t-xs); font-weight: 600; color: var(--ink-muted);
  display: flex; align-items: center; gap: var(--s-3);
}
.xfield__val { display: flex; align-items: center; gap: var(--s-5); min-width: 0; }
.xfield__val .input, .xfield__val .select { min-height: 30px; font-size: var(--t-sm); }
.xfield__meta { display: flex; align-items: center; gap: var(--s-5); margin-top: var(--s-3); }
.xfield__why {
  grid-column: 2; font-size: var(--t-xs); color: var(--brand-ink);
  display: flex; align-items: flex-start; gap: var(--s-3); line-height: var(--lh-snug);
}
.xfield__why svg { width: 12px; height: 12px; margin-top: 2px; flex: 0 0 auto; }
.xfield__peek {
  border: 0; background: transparent; padding: var(--s-2); border-radius: var(--r-xs);
  color: var(--ink-faint); display: inline-grid; place-items: center;
  transition: color var(--dur-1) ease, background-color var(--dur-1) ease;
}
.xfield__peek:hover { color: var(--brand-ink); background: var(--brand-wash-2); }
.xfield__peek svg { width: 14px; height: 14px; }

/* ===========================================================================
   Document facsimile — HTML "paper", so highlights land pixel-perfect
   =========================================================================== */
.docview {
  background: var(--surface-2);
  padding: var(--s-10);
  overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
}
.paper {
  position: relative;
  width: 620px;
  flex: 0 0 auto;
  background: oklch(0.995 0.002 90);
  box-shadow: var(--sh-paper);
  border-radius: 2px;
  padding: 40px 44px;
  font-size: 11.5px;
  line-height: 1.5;
  color: oklch(0.24 0.006 60);
  transform-origin: top center;
  transition: transform var(--dur-3) var(--ease-out);
}
/* Scan texture: faint diagonal grain + a slight vignette. Cheap, convincing. */
.paper::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    repeating-linear-gradient(101deg, oklch(0.2 0 0 / 0.014) 0 1px, transparent 1px 4px),
    radial-gradient(120% 90% at 50% 0%, transparent 55%, oklch(0.2 0 0 / 0.05) 100%);
  mix-blend-mode: multiply;
}
.paper__head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.paper__logo {
  font-weight: 800; font-size: 15px; letter-spacing: -0.03em;
  font-stretch: 112%; color: oklch(0.22 0.01 60); line-height: 1.1;
}
.paper__logo span { display: block; font-size: 8px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: oklch(0.5 0.01 60); margin-top: 3px; }
.paper__addr { font-size: 9.5px; color: oklch(0.45 0.006 60); text-align: right; line-height: 1.55; }
.paper__band {
  margin: 22px 0 18px; padding: 9px 0; border-top: 1.5px solid oklch(0.25 0.01 60);
  border-bottom: 1px solid oklch(0.78 0.006 60);
  display: flex; justify-content: space-between; align-items: baseline;
}
.paper__doctype { font-size: 15px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.paper__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.paper__k { font-size: 8px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase;
  color: oklch(0.52 0.008 60); margin-bottom: 2px; }
.paper__v { font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.paper table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.paper th {
  text-align: left; font-size: 8px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: oklch(0.45 0.008 60); padding: 6px 6px; border-bottom: 1px solid oklch(0.35 0.01 60);
}
.paper td { padding: 6px; border-bottom: 1px solid oklch(0.87 0.005 60); vertical-align: top; }
.paper .r { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.paper__totals { margin-top: 14px; margin-left: auto; width: 260px; font-size: 11px; }
.paper__totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.paper__totals .grand {
  border-top: 1.5px solid oklch(0.25 0.01 60); margin-top: 5px; padding-top: 7px;
  font-weight: 700; font-size: 13px;
}
.paper__note {
  margin-top: 22px; padding: 9px 11px; border: 1px solid oklch(0.8 0.006 60);
  font-size: 9.5px; color: oklch(0.38 0.008 60); line-height: 1.5;
}
.paper__foot { margin-top: 20px; font-size: 8.5px; color: oklch(0.55 0.006 60); text-align: center; line-height: 1.6; }
.paper--photo { transform: rotate(-0.5deg); }

/* Zoom stage: transform doesn't affect layout, so the wrapper height is
   driven from the measured natural height × the scale. Keeps the scroll
   area honest at every zoom level. */
.docstage {
  width: 620px; flex: 0 0 auto;
  height: calc(var(--doc-h, 900px) * var(--doc-s, 1));
  transition: height var(--dur-3) var(--ease-out);
}
.docstage .paper { transform: scale(var(--doc-s, 1)); }
.docstage .paper.paper--photo { transform: scale(var(--doc-s, 1)) rotate(-0.5deg); }

/* Highlight overlay — one coordinate source shared with the form */
.hl {
  position: absolute; border-radius: 2px; pointer-events: none;
  border: 1.5px solid transparent;
  background: transparent;
  transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease,
              box-shadow var(--dur-2) ease;
}
.hl.is-shown {
  background: color-mix(in oklch, var(--brand) 20%, transparent);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 14%, transparent);
}
.hl.is-shown[data-level='low'] {
  background: color-mix(in oklch, var(--negative-fill) 16%, transparent);
  border-color: var(--negative-fill);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--negative-fill) 12%, transparent);
}
.hl__tag {
  position: absolute; top: -17px; left: -1.5px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  padding: 1px 4px; border-radius: 2px 2px 0 0;
  background: var(--brand); color: oklch(0.16 0.03 62);
  opacity: 0; transform: translateY(3px);
  transition: opacity var(--dur-2) ease, transform var(--dur-2) var(--ease-out);
  white-space: nowrap;
}
.hl.is-shown .hl__tag { opacity: 1; transform: none; }
.hl.is-shown[data-level='low'] .hl__tag { background: var(--negative-fill); color: oklch(0.99 0 0); }

.docbar {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-8);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: var(--t-xs); color: var(--ink-muted);
}

/* ===========================================================================
   Pipeline — the agent's processing states, made visible
   =========================================================================== */
.pipe { display: flex; align-items: center; gap: var(--s-2); }
.pipe__step {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-2xs); font-weight: 600; color: var(--ink-faint);
  padding: var(--s-2) var(--s-5) var(--s-2) var(--s-4);
  border-radius: var(--r-pill); border: 1px solid transparent;
  white-space: nowrap;
  transition: color var(--dur-2) ease, background-color var(--dur-2) ease, border-color var(--dur-2) ease;
}
.pipe__dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  transition: background-color var(--dur-2) ease, border-color var(--dur-2) ease;
}
.pipe__step.is-done { color: var(--ink-muted); }
.pipe__step.is-done .pipe__dot { background: var(--positive-fill); border-color: var(--positive-fill); }
.pipe__step.is-live {
  color: var(--brand-ink); background: var(--brand-wash); border-color: var(--brand-edge);
}
.pipe__step.is-live .pipe__dot {
  background: var(--brand); border-color: var(--brand);
  animation: pulseDot 1.1s var(--ease-in-out) infinite;
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 55%, transparent); }
  60%      { box-shadow: 0 0 0 5px color-mix(in oklch, var(--brand) 0%, transparent); }
}
.pipe__arrow { width: 10px; height: 1px; background: var(--line-strong); flex: 0 0 auto; }
@media (prefers-reduced-motion: reduce) { .pipe__step.is-live .pipe__dot { animation: none; } }

/* Slim progress bar */
.bar { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; display: flex; }
.bar__seg { height: 100%; transition: width var(--dur-4) var(--ease-out); }
.bar--thin { height: 4px; }
.bar__seg.over { background: repeating-linear-gradient(45deg,
  var(--negative-fill) 0 5px, color-mix(in oklch, var(--negative-fill) 72%, black) 5px 10px); }

/* ===========================================================================
   Chat — two skins over one transcript
   =========================================================================== */
.chatframe { display: flex; flex-direction: column; min-height: 0; height: 100%; }

/* --- WhatsApp skin ---------------------------------------------------- */
.phone {
  width: 372px; max-width: 100%; margin-inline: auto;
  border-radius: 28px; overflow: hidden;
  border: 8px solid oklch(0.18 0.005 260);
  box-shadow: var(--sh-modal);
  background: #efe7de;
  display: flex; flex-direction: column;
  height: min(720px, calc(100dvh - 200px));
}
.wa__bar {
  background: #008069; color: #fff; padding: var(--s-5) var(--s-6);
  display: flex; align-items: center; gap: var(--s-5); flex: 0 0 auto;
}
.wa__bar .avatar { background: #0b7d68; color: #d7f7ee; border-color: #0b7d68; }
.wa__name { font-size: var(--t-base); font-weight: 600; line-height: 1.25; }
.wa__status { font-size: var(--t-2xs); opacity: 0.85; }
.wa__body {
  flex: 1 1 auto; overflow-y: auto; padding: var(--s-6) var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
  background-color: #efe7de;
  background-image:
    radial-gradient(circle at 18% 22%, oklch(0.55 0.03 70 / 0.055) 0 1.5px, transparent 2px),
    radial-gradient(circle at 68% 58%, oklch(0.55 0.03 70 / 0.05) 0 2px, transparent 2.5px),
    radial-gradient(circle at 42% 84%, oklch(0.55 0.03 70 / 0.045) 0 1.5px, transparent 2px);
  background-size: 88px 88px, 132px 132px, 106px 106px;
}
.wa__day {
  align-self: center; background: #e2f4fd; color: #4a6572;
  font-size: 11px; padding: 3px 10px; border-radius: 7px; margin: var(--s-3) 0;
  box-shadow: 0 1px 0.5px oklch(0.2 0 0 / 0.13);
}
.bub {
  max-width: 84%; padding: 6px 9px 7px; border-radius: 8px;
  font-size: 14.2px; line-height: 1.42; color: #111b21;
  box-shadow: 0 1px 0.5px oklch(0.2 0 0 / 0.13);
  position: relative; word-break: break-word;
}
.bub--in  { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.bub--out { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 2px; }
.bub__time {
  float: right; font-size: 10.5px; color: #667781; margin: 6px -2px -3px 8px;
  display: inline-flex; align-items: center; gap: 2px;
}
.bub__time svg { width: 14px; height: 14px; color: #53bdeb; }
.bub strong { font-weight: 650; }
.bub em { font-style: italic; }

/* Rich card inside a bubble (extraction summary the agent sends back) */
.bub__card {
  background: oklch(0.985 0.002 90); border: 1px solid oklch(0.88 0.004 90);
  border-radius: 6px; padding: 8px 9px; margin: 2px 0 4px; font-size: 12.5px;
}
.bub__card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s-6); margin: 0; }
.bub__card dt { color: #667781; font-size: 11px; }
.bub__card dd { margin: 0; font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.bub__card .warn { color: var(--negative); font-weight: 600; }
.bub__thumb {
  border-radius: 5px; overflow: hidden; margin: -2px -3px 5px; background: #b9c2c6;
  width: 240px; max-width: 100%; height: 300px; position: relative;
}
/* A phone photo shows the top of the page, slightly off-square, on a dark ground */
.bub__thumb .paper {
  position: absolute; top: 10px; left: 50%;
  width: 620px; box-shadow: 0 2px 10px oklch(0.2 0 0 / 0.3);
  transform: translateX(-50%) scale(0.365) rotate(-0.7deg);
  transform-origin: top center; pointer-events: none;
}
.bub__thumb::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(178deg, oklch(0.2 0 0 / 0) 62%, oklch(0.2 0 0 / 0.30) 100%);
}
.bub__thumb .hint {
  position: absolute; left: 8px; bottom: 7px; z-index: 2;
  font-size: 10.5px; color: #fff; text-shadow: 0 1px 3px oklch(0.2 0 0 / 0.6);
  display: flex; align-items: center; gap: 4px;
}
.bub__thumb .hint svg { width: 12px; height: 12px; }
.bub__quick { display: flex; flex-direction: column; gap: 2px; margin-top: 5px; }
.bub__qbtn {
  width: 100%; text-align: center; background: #fff; border: 0;
  border-top: 1px solid #e9edef; color: #027eb5; font-size: 13.5px; font-weight: 500;
  padding: 8px 6px; border-radius: 0;
  transition: background-color var(--dur-1) ease;
}
.bub__qbtn:first-child { border-radius: 6px 6px 0 0; }
.bub__qbtn:last-child { border-radius: 0 0 6px 6px; }
.bub__qbtn:hover:not([disabled]) { background: #f0f2f5; }
.bub__qbtn[disabled] { color: #8696a0; cursor: default; }
.bub__qbtn svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }

.typing { display: inline-flex; align-items: center; gap: 3px; padding: 3px 1px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #8696a0; display: block;
  animation: typeBob 1.05s var(--ease-in-out) infinite;
}
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes typeBob { 0%,60%,100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: 0.6; } }

.wa__compose {
  flex: 0 0 auto; background: #f0f2f5; padding: var(--s-4) var(--s-5);
  display: flex; align-items: center; gap: var(--s-4);
}
.wa__compose .input { border-radius: var(--r-pill); border-color: transparent; background: #fff; min-height: 36px; }
.wa__send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: #008069; color: #fff;
  display: grid; place-items: center; flex: 0 0 auto;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-1) ease;
}
.wa__send:hover { background: #01705c; }
.wa__send:active { transform: scale(0.94); }
.wa__send svg { width: 17px; height: 17px; }

/* --- Email skin ------------------------------------------------------- */
.mail {
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  display: flex; flex-direction: column; background: var(--bg);
  height: min(720px, calc(100dvh - 200px));
}
.mail__bar {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-6) var(--s-8); border-bottom: 1px solid var(--line); background: var(--surface);
  flex: 0 0 auto;
}
.mail__subject { font-weight: 650; font-size: var(--t-base); }
.mail__thread { flex: 1 1 auto; overflow-y: auto; }
.msg { border-bottom: 1px solid var(--line-faint); padding: var(--s-8) var(--s-10); }
.msg:last-child { border-bottom: 0; }
.msg--agent { background: var(--brand-wash); }
.msg__head { display: flex; align-items: center; gap: var(--s-5); margin-bottom: var(--s-5); }
.msg__from { font-weight: 650; font-size: var(--t-sm); }
.msg__addr { font-size: var(--t-xs); color: var(--ink-muted); font-family: var(--font-mono); }
.msg__when { margin-left: auto; font-size: var(--t-xs); color: var(--ink-muted); font-family: var(--font-mono); }
.msg__body { font-size: var(--t-base); line-height: var(--lh-body); max-width: var(--reading-max); }
.msg__body p + p { margin-top: var(--s-5); }
.msg__attach {
  display: inline-flex; align-items: center; gap: var(--s-4); margin-top: var(--s-6);
  padding: var(--s-4) var(--s-6); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--t-sm); background: var(--bg); color: var(--ink-2); text-decoration: none;
}
.msg__attach svg { width: 15px; height: 15px; color: var(--negative); }
.msg__quick { display: flex; gap: var(--s-4); flex-wrap: wrap; margin-top: var(--s-8); }

/* ===========================================================================
   Overlays — drawer, modal, toast
   =========================================================================== */
.backdrop {
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: oklch(0.2 0 0 / 0.34);
  opacity: 0; transition: opacity var(--dur-3) ease;
}
.backdrop.is-open { opacity: 1; }
.backdrop[hidden] { display: none; }

.drawer {
  position: fixed; inset: 0 0 0 auto; z-index: var(--z-drawer);
  width: min(560px, 100vw);
  background: var(--bg); box-shadow: var(--sh-drawer);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-4) var(--ease-out-expo);
}
.drawer.is-open { transform: none; }
.drawer[hidden] { display: none; }
.drawer__head {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-6);
  padding: var(--s-8) var(--s-10); border-bottom: 1px solid var(--line);
}
.drawer__title { font-size: var(--t-md); font-weight: 650; }
.drawer__body { flex: 1 1 auto; overflow-y: auto; }
.drawer__foot {
  flex: 0 0 auto; display: flex; gap: var(--s-5); justify-content: flex-end;
  padding: var(--s-8) var(--s-10); border-top: 1px solid var(--line); background: var(--surface);
}

.modal {
  position: fixed; z-index: var(--z-modal);
  top: 50%; left: 50%;
  width: min(720px, calc(100vw - 2rem));
  max-height: min(84dvh, 780px);
  background: var(--bg); border-radius: var(--r-lg); box-shadow: var(--sh-modal);
  display: flex; flex-direction: column; overflow: hidden;
  /* modals are not anchored to a trigger — they stay centre-origin */
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0;
  transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2) ease;
}
.modal.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.modal[hidden] { display: none; }
.modal--wide { width: min(1040px, calc(100vw - 2rem)); }
.modal__head {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-6);
  padding: var(--s-8) var(--s-10); border-bottom: 1px solid var(--line);
}
.modal__title { font-size: var(--t-md); font-weight: 650; }
.modal__body { flex: 1 1 auto; overflow: auto; padding: var(--s-10); }
.modal__body--flush { padding: 0; }
.modal__foot {
  flex: 0 0 auto; display: flex; gap: var(--s-5); justify-content: flex-end;
  padding: var(--s-8) var(--s-10); border-top: 1px solid var(--line); background: var(--surface);
}

.toaster {
  position: fixed; right: var(--s-10); bottom: var(--s-10); z-index: var(--z-toast);
  display: flex; flex-direction: column-reverse; gap: var(--s-5);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--s-5);
  min-width: 280px; max-width: 380px;
  padding: var(--s-6) var(--s-8);
  background: var(--ink); color: var(--ink-invert);
  border-radius: var(--r-md); box-shadow: var(--sh-pop);
  font-size: var(--t-sm); line-height: var(--lh-snug);
  opacity: 1; transform: translateY(0);
  transition: opacity var(--dur-3) ease, transform var(--dur-3) var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(14px); } }
.toast.is-out { opacity: 0; transform: translateY(8px); }
.toast svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.toast--ok svg { color: var(--positive-fill); }
.toast--attn svg { color: var(--brand); }
.toast--err svg { color: var(--negative-fill); }
.toast__title { font-weight: 650; }
.toast__sub { opacity: 0.72; font-size: var(--t-xs); margin-top: 1px; }

/* ===========================================================================
   Tabs
   =========================================================================== */
.tabs {
  display: flex; gap: var(--s-2); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; }
.tab {
  border: 0; background: transparent; padding: var(--s-5) var(--s-6);
  font-size: var(--t-base); font-weight: 550; color: var(--ink-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: var(--s-4);
  transition: color var(--dur-1) ease, border-color var(--dur-1) ease;
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); font-weight: 650; border-bottom-color: var(--brand); }
.tabpanel[hidden] { display: none; }

/* ===========================================================================
   Dropzone, empty, skeleton
   =========================================================================== */
.dropzone {
  border: 1.5px dashed var(--line-control); border-radius: var(--r-lg);
  padding: var(--s-24) var(--s-12); text-align: center;
  background: var(--surface); color: var(--ink-muted);
  transition: border-color var(--dur-2) ease, background-color var(--dur-2) ease;
}
.dropzone.is-over { border-color: var(--brand); background: var(--brand-wash); }
.dropzone__icon {
  width: 44px; height: 44px; margin: 0 auto var(--s-8);
  border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); color: var(--brand-ink);
}
.dropzone__icon svg { width: 21px; height: 21px; }
.dropzone__title { font-size: var(--t-md); font-weight: 650; color: var(--ink); }
.dropzone__sub { margin-top: var(--s-3); font-size: var(--t-sm); }

.empty { text-align: center; padding: var(--s-24) var(--s-12); color: var(--ink-muted); }
.empty__title { font-size: var(--t-md); font-weight: 650; color: var(--ink); margin-bottom: var(--s-3); }
.empty svg { width: 26px; height: 26px; color: var(--ink-faint); margin: 0 auto var(--s-8); }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ===========================================================================
   Callout — agent reasoning, warnings, notices
   =========================================================================== */
.callout {
  display: flex; gap: var(--s-6); padding: var(--s-6) var(--s-8);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--t-sm); line-height: var(--lh-snug);
}
.callout > svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; color: var(--ink-faint); }
.callout__title { font-weight: 650; color: var(--ink); margin-bottom: var(--s-2); }
.callout--agent { background: var(--brand-wash); border-color: var(--brand-edge); color: var(--ink-2); }
.callout--agent > svg { color: var(--brand-ink); }
.callout--warn  { background: var(--negative-wash); border-color: var(--negative-edge); color: var(--ink-2); }
.callout--warn > svg { color: var(--negative); }
.callout--info  { background: var(--info-wash); border-color: var(--info-edge); color: var(--ink-2); }
.callout--info > svg { color: var(--info); }
.callout--ok    { background: var(--positive-wash); border-color: var(--positive-edge); color: var(--ink-2); }
.callout--ok > svg { color: var(--positive); }

/* Reasoning trail — why the agent picked this project */
.why { display: flex; flex-direction: column; gap: var(--s-4); }
.why__item {
  display: grid; grid-template-columns: 18px minmax(0,1fr) auto; gap: var(--s-5);
  align-items: baseline; font-size: var(--t-sm);
}
.why__item svg { width: 14px; height: 14px; color: var(--positive); grid-row: 1; align-self: center; }
.why__item.is-weak svg { color: var(--ink-faint); }
.why__label { color: var(--ink-2); }
.why__label b { font-weight: 650; color: var(--ink); }
.why__w {
  font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   Timeline / audit trail
   =========================================================================== */
.trail { position: relative; padding-left: var(--s-12); }
.trail::before {
  content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: var(--line);
}
.trail__item { position: relative; padding-bottom: var(--s-8); }
.trail__item:last-child { padding-bottom: 0; }
.trail__item::before {
  content: ''; position: absolute; left: calc(var(--s-12) * -1 + 4px); top: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--line-strong);
}
.trail__item.is-agent::before { border-color: var(--brand); background: var(--brand); }
.trail__item.is-human::before { border-color: var(--info); background: var(--info); }
.trail__when { font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-muted); }
.trail__what { font-size: var(--t-sm); margin-top: 1px; }
.trail__what b { font-weight: 650; }
.trail__diff {
  font-family: var(--font-mono); font-size: var(--t-xs); margin-top: var(--s-3);
  display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap;
}
.trail__diff .old { color: var(--ink-muted); text-decoration: line-through; }
.trail__diff .new { color: var(--positive); }

/* ===========================================================================
   Google Sheets preview — literally their spreadsheet
   =========================================================================== */
.sheet { font-family: var(--font-mono); font-size: 11.5px; border-collapse: collapse; width: 100%; }
.sheet th, .sheet td { border: 1px solid #d9dcdf; padding: 4px 7px; white-space: nowrap; }
.sheet thead th {
  background: #f1f3f4; color: #5f6368; font-weight: 500; text-align: center;
  position: sticky; top: 0; text-transform: none; letter-spacing: 0; font-size: 11px;
}
.sheet tbody tr:first-child td { background: #e8f0fe; font-weight: 600; color: #174ea6; }
.sheet td.rownum {
  background: #f1f3f4; color: #5f6368; text-align: center; width: 34px; position: sticky; left: 0;
}
.sheet td.r { text-align: right; }
.sheetbar {
  display: flex; align-items: center; gap: var(--s-5); padding: var(--s-5) var(--s-8);
  background: #fff; border-bottom: 1px solid var(--line); font-size: var(--t-sm);
}
.sheetbar__name { font-weight: 650; }
.syncdot {
  display: inline-flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-xs); color: var(--positive); font-weight: 550;
}
.syncdot i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--positive-fill); display: block;
  animation: breathe 2.4s var(--ease-in-out) infinite;
}
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .syncdot i { animation: none; } }

/* ===========================================================================
   Demo mode
   =========================================================================== */
.demo {
  position: fixed; left: 50%; bottom: var(--s-8); transform: translateX(-50%);
  z-index: var(--z-demo);
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-4) var(--s-5) var(--s-4) var(--s-8);
  background: var(--ink); color: var(--ink-invert);
  border-radius: var(--r-pill); box-shadow: var(--sh-modal);
  max-width: min(760px, calc(100vw - 2rem));
}
.demo[hidden] { display: none; }
.demo__n {
  font-family: var(--font-mono); font-size: var(--t-2xs); font-weight: 600;
  color: var(--brand); flex: 0 0 auto; letter-spacing: 0;
}
.demo__txt { font-size: var(--t-sm); line-height: var(--lh-snug); min-width: 0; }
.demo__txt b { font-weight: 650; }
.demo__txt span { display: block; opacity: 0.66; font-size: var(--t-xs); }
.demo__btns { display: flex; gap: var(--s-3); margin-left: var(--s-5); flex: 0 0 auto; }
.demo .btn {
  background: oklch(1 0 0 / 0.10); border-color: oklch(1 0 0 / 0.22); color: var(--ink-invert);
}
.demo .btn:hover { background: oklch(1 0 0 / 0.2); border-color: oklch(1 0 0 / 0.4); }
.demo .btn--brand { background: var(--brand); border-color: var(--brand); color: oklch(0.16 0.03 62); }
.demo .btn--brand:hover { background: oklch(0.68 0.15 65); color: oklch(0.16 0.03 62); }

/* Spotlight ring pulls the eye to the element the demo is talking about */
.demo-target {
  position: relative; z-index: var(--z-raised);
  border-radius: var(--r-md);
  animation: spot 1.6s var(--ease-in-out) infinite;
  /* Keep the spotlit element clear of the fixed pill and the sticky header */
  scroll-margin-block: 140px 180px;
}
/* Nothing should end up permanently hidden behind the demo pill */
body.demo-on .page,
body.demo-on .chatpage__main,
body.demo-on .review__scroll { padding-bottom: 132px; }
body.demo-on .review__actions { margin-bottom: 88px; }
@keyframes spot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 60%, transparent); }
  55%      { box-shadow: 0 0 0 7px color-mix(in oklch, var(--brand) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .demo-target { animation: none; outline: 2px solid var(--brand); outline-offset: 3px; }
}

/* ===========================================================================
   Misc
   =========================================================================== */
.kbd {
  font-family: var(--font-mono); font-size: var(--t-2xs); padding: 1px 5px;
  border: 1px solid var(--line-control); border-bottom-width: 2px; border-radius: var(--r-xs);
  background: var(--surface); color: var(--ink-muted);
}
.dl-rows { display: grid; grid-template-columns: auto minmax(0,1fr); gap: var(--s-4) var(--s-10); font-size: var(--t-sm); }
.dl-rows dt { color: var(--ink-muted); }
.dl-rows dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.is-pos { color: var(--positive); }
.is-neg { color: var(--negative); }
.is-attn { color: var(--brand-ink); }
.u-muted { color: var(--ink-muted); }
.u-right { text-align: right; }
.u-nowrap { white-space: nowrap; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Staggered list entrance — decorative, never blocks interaction */
.stagger > * { animation: rise var(--dur-4) var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
/* The entrance uses animation-fill-mode: backwards, so the element starts at
   opacity 0. If the animation never runs — reduced motion, print, a user
   stylesheet — the content must fall back to visible, not stay hidden. */
@media (prefers-reduced-motion: reduce) { .stagger > * { animation: none; } }
@media print { .stagger > *, .demo-target { animation: none; } }

@media (max-width: 720px) {
  .xfield { grid-template-columns: minmax(0,1fr); gap: var(--s-3); }
  .xfield__why { grid-column: 1; }
  .drawer { width: 100vw; }
  .toaster { left: var(--s-6); right: var(--s-6); }
  .toast { max-width: none; }
  .demo { flex-wrap: wrap; border-radius: var(--r-lg); }
}

/* ===========================================================================
   Chart furniture
   =========================================================================== */
.chart-line { width: 100%; height: 190px; }
.legend { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--t-sm); }
.legend li { display: flex; align-items: center; gap: var(--s-5); padding: var(--s-3) 0; border-bottom: 1px solid var(--line-faint); }
.legend li:last-child { border-bottom: 0; }
.legend i { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.legend__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.legend__val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--t-xs); }
.legend__pct { font-family: var(--font-mono); font-size: var(--t-2xs); color: var(--ink-muted); width: 34px; text-align: right; }

.hbars { display: flex; flex-direction: column; gap: var(--s-4); }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0,1fr) auto; gap: var(--s-6); align-items: center; font-size: var(--t-sm); }
.hbar__label { color: var(--ink-2); }
.hbar__track { height: 8px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.hbar__fill { display: block; height: 100%; border-radius: inherit; transition: width var(--dur-4) var(--ease-out); }
.hbar__val { font-family: var(--font-mono); font-size: var(--t-xs); font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 62px; text-align: right; }

.chartrow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-12); align-items: center; }
@media (max-width: 640px) { .chartrow { grid-template-columns: minmax(0,1fr); justify-items: center; } }

/* ===========================================================================
   Review — the split screen. Two independently scrolling columns.
   =========================================================================== */
.review {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(430px, 0.98fr);
  height: calc(100dvh - var(--header-h));
  min-height: 0;
}
.review__doc { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.review__doc .docview { flex: 1 1 auto; min-height: 0; }
.review__side { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.review__scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.review__actions {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap;
  padding: var(--s-6) var(--s-8); border-top: 1px solid var(--line); background: var(--surface);
}
.review__nav {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-8); border-bottom: 1px solid var(--line);
}
.review__nav .u-muted { font-size: var(--t-xs); font-family: var(--font-mono); }

.xgroup__head {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-8);
  background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: var(--t-2xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: var(--tr-label); color: var(--ink-muted);
}
.xgroup__head .badge { text-transform: none; letter-spacing: 0; }

.splitrow {
  display: grid; grid-template-columns: minmax(0,1fr) 130px 32px;
  gap: var(--s-5); align-items: center; padding: var(--s-5) 0;
  border-bottom: 1px solid var(--line-faint);
}
.splitrow:last-of-type { border-bottom: 0; }

@media (max-width: 1180px) {
  .review { grid-template-columns: minmax(0,1fr); height: auto; }
  .review__doc { border-right: 0; border-bottom: 1px solid var(--line); }
  .review__doc .docview { max-height: 62vh; }
  .review__side { min-height: 0; }
  .review__scroll { overflow: visible; }
  .review__actions { position: sticky; bottom: 0; z-index: var(--z-sticky); }
}

/* ===========================================================================
   Chat page layout — conversations | thread | context
   =========================================================================== */
.chatpage {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 320px;
  height: calc(100dvh - var(--header-h));
  min-height: 0;
}
.chatpage__list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.chatpage__main {
  min-width: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); padding: var(--s-10); overflow-y: auto;
}
.chatpage__ctx { border-left: 1px solid var(--line); overflow-y: auto; min-height: 0; background: var(--bg); }

.convo {
  display: grid; grid-template-columns: 32px minmax(0,1fr); gap: var(--s-5);
  padding: var(--s-6) var(--s-8); border-bottom: 1px solid var(--line-faint);
  cursor: pointer; text-align: left; width: 100%; border-left: 0; border-right: 0; border-top: 0;
  background: transparent;
  transition: background-color var(--dur-1) ease;
}
.convo:hover { background: var(--surface); }
.convo[aria-current='true'] { background: var(--surface-2); }
.convo[aria-current='true'] .convo__name { font-weight: 700; }
.convo__name { font-size: var(--t-sm); font-weight: 600; display: flex; align-items: center; gap: var(--s-4); }
.convo__name .u-muted { font-family: var(--font-mono); font-size: var(--t-2xs); margin-left: auto; font-weight: 400; }
.convo__last {
  font-size: var(--t-xs); color: var(--ink-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo__meta { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-3); }

.ctxblock { padding: var(--s-8); border-bottom: 1px solid var(--line); }
.ctxblock__label {
  font-size: var(--t-2xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: var(--tr-label); color: var(--ink-muted); margin-bottom: var(--s-5);
}

@media (max-width: 1240px) { .chatpage { grid-template-columns: 240px minmax(0,1fr); } .chatpage__ctx { display: none; } }
@media (max-width: 860px) {
  .chatpage { grid-template-columns: minmax(0,1fr); height: auto; }
  .chatpage__list { display: none; }
  .chatpage__main { padding: var(--s-6); }
  .phone, .mail { height: min(640px, calc(100dvh - 160px)); }
}

/* ===========================================================================
   Ask bar — reports requested in plain English
   =========================================================================== */
.ask {
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: var(--bg); overflow: hidden;
}
.ask__row { display: flex; align-items: center; gap: var(--s-5); padding: var(--s-5) var(--s-6) var(--s-5) var(--s-8); }
.ask__row > span:first-child { color: var(--brand-ink); flex: 0 0 auto; }
.ask__row .ico { width: 18px; height: 18px; }
.ask__input {
  flex: 1 1 auto; border: 0; background: transparent; outline: none;
  font-size: var(--t-md); min-width: 0; padding: var(--s-3) 0;
}
.ask__input::placeholder { color: var(--ink-muted); }
.ask__eg { display: flex; gap: var(--s-4); flex-wrap: wrap; padding: 0 var(--s-8) var(--s-6); }
.ask__chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: var(--r-pill); padding: var(--s-2) var(--s-6);
  font-size: var(--t-xs); font-weight: 500;
  transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease;
}
.ask__chip:hover { background: var(--brand-wash); border-color: var(--brand-edge); color: var(--brand-ink); }

.parsed {
  display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap;
  padding: var(--s-5) var(--s-8); border-top: 1px solid var(--line);
  background: var(--brand-wash); font-size: var(--t-xs); color: var(--ink-2);
}
.parsed b { font-weight: 650; }

/* Print-ready report sheet */
.sheetpage {
  max-width: 900px; margin: 0 auto; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-20);
}
.sheetpage__head { display: flex; justify-content: space-between; gap: var(--s-12);
  align-items: flex-start; padding-bottom: var(--s-10); border-bottom: 2px solid var(--ink); }
.sheetpage__title { font-size: var(--t-xl); font-weight: 650; letter-spacing: var(--tr-display); font-stretch: 104%; }
.sheetpage__meta { text-align: right; font-size: var(--t-xs); color: var(--ink-muted); line-height: 1.7; }
@media print {
  .sheetpage { border: 0; border-radius: 0; padding: 0; max-width: none; }
  .page { padding: 0; }
}
@media (max-width: 640px) { .sheetpage { padding: var(--s-10); } }

/* ===========================================================================
   Flow diagram — the pipeline, in HTML so it stays legible and responsive
   =========================================================================== */
.lane { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.lane + .lane { margin-top: var(--s-6); }
.lane__head {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-5) var(--s-8); background: var(--surface); border-bottom: 1px solid var(--line);
}
.lane__n {
  font-family: var(--font-mono); font-size: var(--t-2xs); font-weight: 600;
  color: var(--brand-ink); letter-spacing: 0;
}
.lane__title { font-size: var(--t-sm); font-weight: 650; }
.lane__note { margin-left: auto; font-size: var(--t-xs); color: var(--ink-muted); }
.lane__body { padding: var(--s-8); display: flex; align-items: stretch; gap: var(--s-4); flex-wrap: wrap; }

.node {
  flex: 1 1 150px; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: var(--s-6); background: var(--bg);
}
.node__t { font-size: var(--t-sm); font-weight: 650; display: flex; align-items: center; gap: var(--s-4); }
.node__t .ico { width: 14px; height: 14px; color: var(--ink-faint); }
.node__d { font-size: var(--t-xs); color: var(--ink-muted); margin-top: var(--s-3); line-height: var(--lh-snug); }
.node--agent { background: var(--brand-wash); border-color: var(--brand-edge); }
.node--agent .node__t .ico { color: var(--brand-ink); }
.node--store { background: var(--info-wash); border-color: var(--info-edge); }
.node--store .node__t .ico { color: var(--info); }

.arrow {
  flex: 0 0 auto; align-self: center; color: var(--ink-faint);
  display: grid; place-items: center; width: 16px;
}
.arrow .ico { width: 14px; height: 14px; }
@media (max-width: 720px) { .arrow { width: 100%; transform: rotate(90deg); height: 18px; } }

.lane__link {
  display: flex; align-items: center; justify-content: center; gap: var(--s-4);
  padding: var(--s-3) 0; color: var(--ink-faint);
}
.lane__link .ico { width: 14px; height: 14px; }
.lane__link span { font-size: var(--t-2xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tr-label); color: var(--ink-muted); }

/* ===========================================================================
   Landing — the front door. Product tokens, editorial pacing.
   =========================================================================== */
.top {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-8);
  padding: var(--s-6) var(--s-12);
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
.top__actions { margin-left: auto; display: flex; gap: var(--s-5); align-items: center; flex-wrap: wrap; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 var(--s-12); }

.hero { padding: var(--s-32) 0 var(--s-24); }
.hero__kicker {
  font-size: var(--t-sm); font-weight: 600; color: var(--brand-ink);
  display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-8);
}
.hero__h {
  font-size: clamp(2.4rem, 6.2vw, 4.4rem);
  line-height: 0.98; letter-spacing: -0.035em; font-weight: 650; font-stretch: 104%;
  max-width: 17ch;
}
.hero__h em { font-style: normal; color: var(--brand-ink); }
.hero__p {
  margin-top: var(--s-10); font-size: clamp(1rem, 1.6vw, 1.1875rem);
  color: var(--ink-2); max-width: 58ch; line-height: 1.6;
}
.hero__cta { margin-top: var(--s-14); display: flex; gap: var(--s-6); flex-wrap: wrap; align-items: center; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts > div { padding: var(--s-12) var(--s-10) var(--s-12) 0; border-right: 1px solid var(--line); }
.facts > div:last-child { border-right: 0; }
.facts b { display: block; font-family: var(--font-mono); font-size: var(--t-2xl);
  font-weight: 500; letter-spacing: -0.035em; line-height: 1; }
.facts span { display: block; font-size: var(--t-sm); color: var(--ink-muted); margin-top: var(--s-4);
  max-width: 26ch; line-height: var(--lh-snug); }
@media (max-width: 720px) { .facts > div { border-right: 0; border-bottom: 1px solid var(--line-faint);
  padding: var(--s-8) 0; } .facts > div:last-child { border-bottom: 0; } }

.big { padding: var(--s-24) 0; border-bottom: 1px solid var(--line); }
.big__h { font-size: clamp(1.5rem, 3vw, 2.125rem); letter-spacing: -0.03em; font-weight: 650;
  font-stretch: 102%; max-width: 22ch; }
.big__p { margin-top: var(--s-6); color: var(--ink-muted); max-width: 62ch; }

.req { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1.15fr) auto;
  gap: var(--s-8); align-items: baseline; padding: var(--s-8) 0; border-bottom: 1px solid var(--line-faint); }
.req__n { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--brand-ink); font-weight: 600; }
.req__ask { font-size: var(--t-base); font-weight: 550; }
.req__do { font-size: var(--t-sm); color: var(--ink-muted); line-height: var(--lh-snug); }
.req__go { font-size: var(--t-xs); font-weight: 600; white-space: nowrap; }
@media (max-width: 760px) {
  .req { grid-template-columns: 26px minmax(0,1fr); gap: var(--s-4) var(--s-6); }
  .req__do, .req__go { grid-column: 2; }
}

.screens { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0;
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.screen {
  padding: var(--s-8); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; display: block;
  transition: background-color var(--dur-1) ease;
}
.screen:hover { background: var(--surface); }
.screen__t { font-weight: 650; font-size: var(--t-sm); display: flex; align-items: center; gap: var(--s-4); }
.screen__t .ico { color: var(--brand-ink); }
.screen__d { font-size: var(--t-xs); color: var(--ink-muted); margin-top: var(--s-3); line-height: var(--lh-snug); }

.foot { padding: var(--s-16) 0 var(--s-24); color: var(--ink-muted); font-size: var(--t-sm); }
