/* AutoCall Portal — tokens and components from the design handoff
   (design_handoff_autocall_portal/README.md). Light-only, by design. */

:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #DDE1E6;
  --grid-line: #C7CDD6;
  --cell-line: #E4E7EC;
  --divider-soft: #EEF0F3;
  --th-bg: #EEF0F3;
  --zebra: #FAFBFC;
  --row-hover: #F1F5FE;
  --ink: #171A21;
  --ink-2: #3B4150;
  --muted: #6B7280;
  --faint: #9AA1AD;
  --accent: #1D4ED8;
  --accent-deep: #1E3A8A;
  --accent-tint: #EFF4FF;
  --accent-line: #BFD0F8;
  --focus-ring: #DBE6FE;
  --red: #B3261E;
  --red-bg: #FBEAE9;
  --red-line: #F3C5C1;
  --green: #15803D;
  --green-bg: #F0FDF4;
  --green-line: #BBF7D0;
  --green-ink: #14532D;
  --warn-bg: #FFF8E6;
  --warn-line: #F4DFA6;
  --warn-ink: #5C4203;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --shadow-menu: 0 10px 28px rgba(15, 23, 42, .16);
  --cell-pad: 4px 8px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { color: var(--accent-deep); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=checkbox] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; cursor: pointer; }
h2, h3, h4 { margin: 0; }
.hidden { display: none !important; }
.grow { flex: 1; }
.mono-label { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; color: var(--muted); }
.muted-sm { font-size: 12.5px; color: var(--muted); }
.err { color: var(--red); font-size: 13px; }
.err:empty { display: none; }
.empty-note { font-size: 13px; color: var(--faint); margin: 0; }
.tnum { font-variant-numeric: tabular-nums; }
@keyframes acPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── Buttons & fields ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:focus-visible, .link-btn:focus-visible, .icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.btn.sm { padding: 7px 12px; border-radius: 7px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: #116932; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary:disabled:hover { background: var(--accent); }
.btn.block { width: 100%; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.link-btn:hover { color: var(--accent-deep); }
.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; border: none; background: transparent;
  font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.boxed { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-size: 17px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.fld { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.fld input, .fld select, .fld textarea, .sm-select, .inline-fld select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font-size: 13.5px; font-weight: 400; color: var(--ink); outline: none; min-width: 0;
}
.fld input[type=date] { padding: 7px 10px; }
.fld input:focus, .fld select:focus, .fld textarea:focus, .sm-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring);
}
.fld-hint { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.45; }
.sm-select { padding: 6px 10px; font-size: 13px; }
.inline-fld { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.inline-fld select { padding: 5px 8px; border-radius: 7px; font-size: 13px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.tint { background: var(--accent-tint); color: var(--accent-deep); }
.pill.grey { background: var(--bg); color: var(--ink-2); font-size: 11.5px; padding: 1px 8px; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; }
.auth-inner { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 20px; }
.wordmark { display: flex; align-items: baseline; gap: 8px; justify-content: center; }
.wm-name { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.wordmark .mono-label { font-size: 11px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.auth-tab {
  padding: 12px; border: none; background: var(--zebra); font-weight: 600; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.auth-tab.active { background: var(--surface); color: var(--ink); border-bottom-color: var(--accent); }
.auth-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-form .fld { font-size: 12.5px; gap: 6px; }
.auth-form .fld input { padding: 9px 11px; font-size: 14px; }
.auth-form .btn { margin-top: 6px; padding: 10px 18px; font-size: 14px; }
.type-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-tile {
  text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer;
}
.type-tile.selected { border: 1.5px solid var(--accent); background: var(--accent-tint); color: var(--accent-deep); padding: 9.5px 11.5px; }

/* ── Chrome ───────────────────────────────────────────────────────────────── */
#app-screen { min-height: 100vh; padding-bottom: 96px; }
.app-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1240px; margin: 0 auto; padding: 14px 28px 0; display: flex; flex-direction: column; gap: 10px; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.header-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.brand { display: flex; align-items: baseline; gap: 7px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.vdivider { width: 1px; height: 20px; background: var(--border); }
.org-name { font-weight: 600; font-size: 14.5px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.username { font-size: 12.5px; color: var(--muted); }
.main-tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -10px; }
.main-tab {
  padding: 10px 12px 11px; border: none; background: none; border-bottom: 2px solid transparent;
  font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.main-tab:hover { color: var(--ink); }
.main-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.app-main { max-width: 1240px; margin: 0 auto; padding: 24px 28px; }
.subtabs {
  display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; width: max-content; max-width: 100%; overflow-x: auto; margin-bottom: 20px;
}
.subtab {
  padding: 7px 14px; border: none; border-radius: 7px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.subtab:hover { color: var(--ink); }
.subtab.active { background: var(--accent-tint); color: var(--accent-deep); }

.panel { display: flex; flex-direction: column; gap: 16px; }
.panel.narrow { max-width: 820px; }
.panel.mid { max-width: 920px; }
.panel.ask-panel { max-width: 760px; }
#panel-contacts { gap: 14px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 2px; }
.page-title h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.page-sub { font-size: 13px; color: var(--muted); }
.head-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save-note { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--green); font-weight: 500; }
.save-note .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.save-note.saving { color: var(--muted); }
.save-note.error { color: var(--red); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--divider-soft); font-size: 13.5px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.form-grid.wide-cols { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.result-ok {
  background: var(--green-bg); border: 1px solid var(--green-line); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; color: var(--green-ink);
}
.result-err {
  background: var(--red-bg); border: 1px solid var(--red-line); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; color: var(--red);
}
.count-line strong { font-variant-numeric: tabular-nums; }

/* ── Popover menus (Columns + column filters) ─────────────────────────────── */
.menu-anchor { position: relative; }
.popmenu {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-menu);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--ink);
}
.columns-menu { position: absolute; top: calc(100% + 6px); right: 0; width: 260px; z-index: 35; }
.menu-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.menu-list { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 13px; cursor: pointer; border-radius: 4px; }
.menu-item:hover { background: var(--bg); }
.menu-item span.lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .cnt { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.menu-item .del { border: none; background: none; padding: 0 2px; color: var(--muted); font-size: 12px; cursor: pointer; }
.menu-item .del:hover { color: var(--red); }
.menu-add { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--divider-soft); }
.menu-add-row { display: flex; gap: 6px; }
.menu-input { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--grid-line); border-radius: 6px; font-size: 13px; outline: none; }
.menu-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.menu-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.menu-btn:hover { background: var(--accent-deep); }
.menu-note { font-size: 12px; color: var(--muted); line-height: 1.45; }
.menu-note code { font-family: var(--mono); font-size: 11.5px; }
.filter-menu { position: fixed; width: 230px; z-index: 60; padding: 10px; gap: 8px; }
.filter-menu .menu-input { font-size: 12.5px; }
.filter-menu .menu-actions { display: flex; gap: 12px; }
.filter-menu .menu-list {
  max-height: 200px; border-top: 1px solid var(--divider-soft); border-bottom: 1px solid var(--divider-soft); padding: 4px 0;
}
.filter-menu .menu-item { padding: 4px 2px; }

/* ── Filter chips ─────────────────────────────────────────────────────────── */
.filter-chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.chip {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px;
  border: 1px solid var(--accent-line); background: var(--accent-tint); color: var(--accent-deep);
  font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.chip .x { font-size: 14px; line-height: 1; padding: 0 3px; }

/* ── Contacts table ───────────────────────────────────────────────────────── */
.table-box {
  background: var(--surface); border: 1px solid var(--grid-line); border-radius: 10px;
  overflow: auto; max-height: calc(100vh - 250px); min-height: 320px;
}
#contacts-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 1040px; font-size: 13px; }
#contacts-table th {
  position: sticky; top: 0; z-index: 3; background: var(--th-bg);
  padding: 7px 8px 7px 10px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-2); border-bottom: 1px solid var(--grid-line);
  border-right: 1px solid var(--border); white-space: nowrap;
}
#contacts-table th .th-inner { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
#contacts-table th.num .th-inner span { margin-left: auto; }
#contacts-table th.sel, #contacts-table td.sel { position: sticky; left: 0; width: 36px; min-width: 36px; padding: 0 10px; }
#contacts-table th.sel { z-index: 5; }
#contacts-table th.namecol, #contacts-table td.namecol { position: sticky; left: 36px; border-right: 1px solid var(--grid-line); }
#contacts-table th.namecol { z-index: 5; }
#contacts-table td.sel, #contacts-table td.namecol { z-index: 2; }
.funnel {
  display: grid; place-items: center; width: 20px; height: 20px; border: none; border-radius: 4px;
  cursor: pointer; background: transparent; color: var(--faint); flex: none;
}
.funnel:hover { background: var(--border); color: var(--ink-2); }
.funnel.active { background: var(--accent); color: #fff; }

#contacts-table tbody tr { background: var(--surface); }
#contacts-table tbody tr:nth-child(even) { background: var(--zebra); }
#contacts-table tbody tr:hover { background: var(--row-hover); }
#contacts-table tbody tr.selected { background: var(--accent-tint); }
#contacts-table td {
  background: inherit; padding: 0; border-bottom: 1px solid var(--cell-line);
  border-right: 1px solid var(--cell-line); white-space: nowrap;
}
#contacts-table tr.inactive .cell-input, #contacts-table tr.inactive .cell-select { color: var(--faint); }
.cell-input, .cell-select {
  width: 100%; border: 1px solid transparent; background: transparent; padding: var(--cell-pad);
  font-size: 13px; color: var(--ink); border-radius: 4px; outline: none; font-variant-numeric: tabular-nums;
}
.cell-select { cursor: pointer; }
.cell-select.is-default { color: var(--muted); }
.cell-input:hover, .cell-select:hover { border-color: var(--grid-line); background: var(--surface); }
.cell-input:focus, .cell-select:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px var(--focus-ring); }
.cell-input.needs { border: 1px dashed var(--warn-line); background: var(--warn-bg); }
.cell-input.needs::placeholder { color: var(--warn-ink); }
.name-cell { display: flex; align-items: center; gap: 2px; padding-right: 5px; }
.name-cell .cell-input { flex: 1; min-width: 0; font-weight: 600; }
.open-chip {
  flex: none; display: flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--accent); font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.open-chip:hover { background: var(--accent-tint); border-color: var(--accent-line); }
.bal-btn {
  width: 100%; display: flex; justify-content: flex-end; align-items: center; border: none; background: transparent;
  padding: var(--cell-pad); padding-right: 10px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.bal-btn:hover { background: var(--accent-tint); }
.bal-btn span { text-decoration: underline dotted; text-underline-offset: 3px; }
.bal-btn.high { color: var(--red); font-weight: 600; }
.bal-btn.some { color: var(--accent-deep); font-weight: 600; }
.bal-btn.zero { color: var(--faint); }
.status-wrap { padding: 0 8px; }
.status-pill { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; cursor: pointer; border: 1px solid; }
.status-pill.on { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.status-pill.off { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.row-msg { padding: 0 10px; font-size: 12px; }
.row-msg.err { color: var(--red); }
.row-msg.warn { color: var(--warn-ink); }
#contacts-table tr.new-row, #contacts-table tr.new-row:hover { background: var(--surface); }
#contacts-table tr.new-row td { border-bottom: none; }
.new-plus { color: var(--faint); font-size: 15px; text-align: center; }
.new-input {
  width: 100%; border: 1px dashed var(--grid-line); background: var(--zebra); padding: var(--cell-pad);
  font-size: 13px; border-radius: 4px; outline: none;
}
.new-input:focus { border-style: solid; border-color: var(--accent); background: var(--surface); }
.new-hint { padding: 6px 10px; font-size: 12px; color: var(--faint); }

.selection-bar {
  position: sticky; bottom: 16px; align-self: flex-start; display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 16px; background: var(--ink); color: #fff; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .24); flex-wrap: wrap; z-index: 20;
}
.sel-count { font-size: 13px; font-weight: 600; }
.sel-divider { width: 1px; height: 18px; background: var(--ink-2); }
.sel-label { font-size: 12.5px; color: var(--grid-line); }
.selection-bar select { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--ink-2); background: #262A33; color: #fff; font-size: 13px; }
.sel-apply { padding: 6px 12px; border-radius: 6px; border: none; background: #fff; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.sel-clear { padding: 6px 10px; border-radius: 6px; border: none; background: transparent; color: var(--grid-line); font-size: 13px; cursor: pointer; }
.sel-clear:hover { color: #fff; }

/* ── Drawers ──────────────────────────────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; z-index: 40; }
.backdrop.light { background: rgba(23, 26, 33, .18); }
#assistant-backdrop { z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.drawer.record { width: min(520px, 100vw); box-shadow: -12px 0 32px rgba(15, 23, 42, .12); z-index: 41; }
.drawer.assistant { width: min(460px, 100vw); box-shadow: -16px 0 40px rgba(15, 23, 42, .14); z-index: 51; }

.record-head { padding: 18px 20px 0; display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid var(--border); }
.record-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.record-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.record-title .mono-label { letter-spacing: .1em; }
.record-name { font-size: 17px; font-weight: 700; }
.record-sub { font-size: 12.5px; color: var(--muted); }
.balance-strip {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px;
  border-radius: 10px; background: var(--zebra); border: 1px solid var(--divider-soft); font-size: 13px; color: var(--muted);
}
.balance-amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-amt.due { color: var(--red); }
.balance-amt.clear { color: var(--green); }
.record-tabs { display: flex; gap: 2px; margin: 0 -10px; }
.record-tab {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; border: none; background: none;
  border-bottom: 2px solid transparent; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.record-tab:hover { color: var(--ink); }
.record-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.record-tab .cnt { padding: 0 6px; border-radius: 999px; background: var(--th-bg); color: var(--ink-2); font-size: 11px; font-weight: 600; }
.record-body { flex: 1; overflow-y: auto; }
.rec-list { padding: 4px 20px; }
.rec-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 11px 0; border-bottom: 1px solid var(--divider-soft); }
.rec-row .main { font-size: 13.5px; font-weight: 500; }
.rec-row .amt { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.rec-row .amt.due { color: var(--red); }
.rec-row .amt.credit { color: var(--green); }
.rec-row .meta { font-size: 12px; color: var(--muted); }
.rec-row .running { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rec-empty { padding: 20px; font-size: 13px; color: var(--faint); line-height: 1.5; }
.outcome-pill { justify-self: end; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--bg); color: var(--muted); }
.outcome-pill.accent { background: var(--accent-tint); color: var(--accent-deep); }
.outcome-pill.green { background: var(--green-bg); color: var(--green); }
.outcome-pill.amber { background: var(--warn-bg); color: #8A5A00; }
.details-grid { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.details-grid .note { grid-column: span 2; font-size: 12px; color: var(--muted); }
.notes-pane { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.notes-pane textarea {
  min-height: 70px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  line-height: 1.5; resize: vertical; outline: none;
}
.notes-pane textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.notes-pane .btn { align-self: flex-end; padding: 7px 14px; font-size: 13px; }
.note-card { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 8px; background: var(--zebra); border: 1px solid var(--divider-soft); }
.note-card .txt { font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.note-card .when { font-size: 11.5px; color: var(--muted); }
.ledger-form {
  padding: 14px 20px 16px; border-top: 1px solid var(--border); display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--zebra);
}
.ledger-form-title { grid-column: span 3; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ledger-form input, .ledger-form select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; min-width: 0; outline: none;
}
.ledger-form select { padding: 8px; }
.ledger-form input[type=date] { padding: 7px 10px; }
.ledger-form input:focus, .ledger-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.ledger-form .btn { padding: 9px; font-size: 13px; }

/* ── Assistant ────────────────────────────────────────────────────────────── */
.as-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.as-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.as-title { display: flex; gap: 10px; align-items: center; }
.as-tile { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-tint); overflow: hidden; }
.as-tile img { width: 30px; height: 30px; object-fit: contain; }
.as-name { font-size: 14.5px; font-weight: 700; }
.as-tag { font-size: 12px; color: var(--muted); }
.as-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.as-step { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--faint); }
.as-step .bar { height: 3px; border-radius: 2px; background: var(--border); }
.as-step.active { color: var(--ink); }
.as-step.active .bar { background: var(--accent); }
.as-step.done { color: var(--green); }
.as-step.done .bar { background: var(--green); }
.as-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.as-trail { display: flex; flex-direction: column; border-bottom: 1px solid var(--divider-soft); background: var(--zebra); }
.trail-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 18px; border-bottom: 1px solid var(--divider-soft); }
.trail-row:last-child { border-bottom: none; }
.tick { display: grid; place-items: center; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; background: var(--green); color: #fff; font-size: 10px; font-weight: 700; }
.trail-row .lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.trail-row .val { font-size: 13px; line-height: 1.45; }
.as-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.as-q { display: flex; flex-direction: column; gap: 8px; }
.as-q .q-label { font-size: 13.5px; font-weight: 600; }
.as-textarea {
  min-height: 92px; padding: 11px 12px; border: 1px solid var(--grid-line); border-radius: 10px;
  font-size: 14px; line-height: 1.5; resize: vertical; outline: none; font-family: inherit;
}
.as-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.as-textarea.msg { min-height: 120px; font-size: 13.5px; line-height: 1.55; }
.small-label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.examples { display: flex; flex-direction: column; gap: 6px; }
.example {
  text-align: left; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--divider-soft); background: var(--zebra);
  font-size: 13px; color: var(--ink-2); cursor: pointer; line-height: 1.4;
}
.example:hover { border-color: var(--accent-line); background: var(--accent-tint); color: var(--accent-deep); }
.thinking { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.thinking .pdot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: acPulse 1s infinite; }
.asked { font-size: 13.5px; color: var(--ink-2); font-style: italic; }
.understood { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--accent-line); background: #F6F9FF; border-radius: 10px; }
.understood .small-label { color: var(--accent-deep); }
.understood .sentence { font-size: 14.5px; font-weight: 500; line-height: 1.5; text-wrap: pretty; }
.cond-table { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cond-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--divider-soft); font-size: 13px; }
.cond-row:last-child { border-bottom: none; }
.cond-row .k { color: var(--muted); }
.cond-row .v { font-weight: 600; }
.cond-remove { border: none; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 4px; }
.cond-remove:hover { color: var(--red); }
.warn-box {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); font-size: 13px; color: var(--warn-ink); line-height: 1.5;
}
.warn-box .bang { font-weight: 700; }
.match-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; }
.match-head strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.people { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.people-head, .person {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 52px 80px; gap: 10px; align-items: center; padding: 7px 12px;
}
.people-head { background: var(--th-bg); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.people-head .r, .person .metric { text-align: right; }
.person { border-top: 1px solid var(--divider-soft); cursor: pointer; }
.person:hover { background: #F6F9FF; }
.person.out { opacity: .5; }
.person .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.person .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .nm { font-size: 13px; font-weight: 600; }
.person .sub { font-size: 12px; color: var(--muted); }
.person .cls { font-size: 13px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.person .metric { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hear-box { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 10px; background: var(--bg); }
.hear-box .txt { font-size: 13.5px; line-height: 1.6; text-wrap: pretty; white-space: pre-wrap; }
.ready { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 10px; border: 1px solid var(--border); }
.ready .n { font-size: 26px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ready .line { font-size: 13.5px; color: var(--ink-2); }
.done-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 10px; background: var(--green-bg); border: 1px solid var(--green-line); color: var(--green-ink); }
.done-card .big-tick { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; }
.done-card .t { font-size: 16px; font-weight: 700; }
.done-card .d { font-size: 13.5px; line-height: 1.5; }
.as-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); }
.as-foot .btn { padding: 9px 16px; }
.as-foot .btn.outline { padding: 9px 14px; }

.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 52; display: flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 8px; border-radius: 999px; border: 1px solid var(--accent-deep); background: var(--accent);
  color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer;
  box-shadow: 0 8px 24px rgba(29, 78, 216, .32);
}
.fab:hover { background: var(--accent-deep); }
.fab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring), 0 8px 24px rgba(29, 78, 216, .32); }
.fab-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; overflow: hidden; }
.fab-icon img { width: 30px; height: 30px; object-fit: contain; }

/* ── Calls ────────────────────────────────────────────────────────────────── */
.pointer-line { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.pointer-badge { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-tint); color: var(--accent); font-weight: 700; font-size: 12px; }
.pointer-line .link-btn { font-size: 13px; }
.ann-form { padding: 16px; gap: 12px; display: grid; }
.ann-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ann-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ann-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ann-type { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .1em; color: var(--accent); text-transform: uppercase; }
.ann-date { font-size: 12.5px; color: var(--muted); }
.ann-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.ann-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--divider-soft); font-size: 13px; color: var(--ink-2); }
.ann-foot .btn { padding: 6px 12px; border-radius: 7px; font-size: 13px; }
.ann-foot .btn.done { color: var(--green); border-color: var(--green-line); background: var(--green-bg); }
.script-card { padding: 16px; gap: 10px; }
.script-fields { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.script-card textarea {
  min-height: 72px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  line-height: 1.55; resize: vertical; outline: none;
}
.script-card textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.script-status { font-size: 12px; color: var(--muted); min-height: 18px; }
.script-status.ok { color: var(--green); }
.script-status.err { color: var(--red); }

/* ── Results ──────────────────────────────────────────────────────────────── */
.log-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 90px 100px; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--divider-soft); font-size: 13px; }
.log-row:last-child { border-bottom: none; }
.log-row .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-row .what { display: flex; flex-direction: column; min-width: 0; }
.log-row .what b { font-weight: 600; }
.log-row .what span { color: var(--muted); font-size: 12.5px; }
.log-row .n { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.log-row .pill { justify-self: end; }
.log-empty { padding: 20px 16px; font-size: 13px; color: var(--faint); }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.stat { background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .l { font-size: 12px; color: var(--muted); }
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 28px; }
.bd-group { display: flex; flex-direction: column; gap: 6px; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 48px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--divider-soft); font-size: 13.5px; }
.bd-bar { height: 6px; border-radius: 3px; background: var(--divider-soft); overflow: hidden; display: block; }
.bd-bar i { display: block; height: 100%; background: var(--accent); }
.bd-row .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.usage-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 140px; gap: 16px; padding: 11px 16px; border-top: 1px solid var(--divider-soft); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.usage-row.head { padding: 10px 16px; background: var(--th-bg); border-top: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.usage-row .r { text-align: right; }
.usage-row .m { font-weight: 500; }
.usage-row .c { font-weight: 600; }

/* ── Ask ──────────────────────────────────────────────────────────────────── */
.faq-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.faq-pill { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; cursor: pointer; }
.faq-pill:hover { border-color: var(--accent); color: var(--accent); }
.ask-card { padding: 16px; min-height: 240px; }
.ask-log { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.ask-pair { display: flex; flex-direction: column; gap: 6px; }
.ask-q { align-self: flex-end; max-width: 80%; padding: 8px 12px; border-radius: 10px 10px 2px 10px; background: var(--accent-tint); color: var(--accent-deep); font-size: 13.5px; }
.ask-a { align-self: flex-start; max-width: 85%; padding: 8px 12px; border-radius: 10px 10px 10px 2px; background: var(--bg); font-size: 13.5px; line-height: 1.55; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ask-a .ttl { font-weight: 600; }
.ask-a .meta { font-size: 12px; color: var(--muted); }
.ask-a .tbl-wrap { overflow-x: auto; }
.mini-table { border-collapse: collapse; font-size: 12.5px; background: var(--surface); border-radius: 6px; }
.mini-table th, .mini-table td { padding: 5px 10px; border-bottom: 1px solid var(--divider-soft); text-align: left; white-space: nowrap; }
.mini-table th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); background: var(--th-bg); }
.ask-input-row { margin-top: auto; display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--divider-soft); }
.ask-input-row input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.ask-input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }

/* ── Narrow screens ───────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: 12px 16px 0; }
  .app-main { padding: 18px 16px; }
  .span2 { grid-column: auto; }
  .log-row { grid-template-columns: minmax(0, 1fr) auto; }
  .log-row .when { grid-column: span 2; }
  .details-grid { grid-template-columns: 1fr; }
  .details-grid .span2, .details-grid .note { grid-column: auto; }
  .fab { right: 16px; bottom: 16px; }
}

/* Assistant: the request + corrections thread, and the correction box */
.as-thread { display: flex; flex-direction: column; gap: 6px; }
.as-thread .bubble {
  align-self: flex-end; max-width: 85%; padding: 6px 11px; border-radius: 10px 10px 2px 10px;
  background: var(--accent-tint); color: var(--accent-deep); font-size: 13px; line-height: 1.45;
}
.refine { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--divider-soft); }
.refine-row { display: flex; gap: 8px; }
.refine-row input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--grid-line); border-radius: 8px;
  font-size: 13.5px; outline: none;
}
.refine-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.refine-row .btn { padding: 8px 14px; }
.info-box {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px;
  background: var(--accent-tint); border: 1px solid var(--accent-line); font-size: 13px; color: var(--accent-deep); line-height: 1.5;
}
.info-box .bang { font-weight: 700; font-style: italic; font-family: Georgia, serif; }
