/* B1 Assistant: quiet chrome, data-first answers. The one loud thing is the live "checks" strip. */
:root {
  --paper: #F5F7FA; --surface: #FFFFFF; --sunk: #EEF2F7;
  --ink: #14213D; --muted: #5B6578; --line: #DCE2EA;
  --signal: #1F5BFF; --signal-soft: #E7EEFF; --signal-ink: #FFFFFF;
  --ok: #12805C; --warn: #B4540A; --bad: #C62E3A;
  --mint: #7CF2C8;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side: 284px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0F1626; --surface: #161F33; --sunk: #1B2640;
  --ink: #E6EBF3; --muted: #97A3B8; --line: #26324C;
  --signal: #6F95FF; --signal-soft: #1E2B4D; --signal-ink: #0F1626;
  --ok: #4FD1A5; --warn: #F0A35E; --bad: #FF7A85;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --paper: #0F1626; --surface: #161F33; --sunk: #1B2640;
  --ink: #E6EBF3; --muted: #97A3B8; --line: #26324C;
  --signal: #6F95FF; --signal-soft: #1E2B4D; --signal-ink: #0F1626;
  --ok: #4FD1A5; --warn: #F0A35E; --bad: #FF7A85;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; font-weight: 500; transition: background .15s, border-color .15s; }
.btn:hover { border-color: color-mix(in srgb, var(--signal) 40%, var(--line)); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--signal) 88%, black); }
.btn.ghost { background: transparent; }
.btn.link { border: 0; background: none; color: var(--muted); text-decoration: underline; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }

/* Gate: signed out / not on the list */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 15% -10%, var(--signal-soft), transparent 60%), var(--paper); }
.gate-card { max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow); }
.gate-card h1 { margin: 18px 0 8px; font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
.gate-card p { margin: 0 0 24px; color: var(--muted); }
.gate-mark { display: block; }

/* App shell */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100%; }
.sidebar { display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.new-chat { justify-content: flex-start; width: 100%; background: var(--signal-soft); border-color: transparent; color: var(--signal); font-weight: 600; }
.new-chat:hover { border-color: var(--signal); }
.search { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 12px; }
.chat-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.chat-list h3 { margin: 14px 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chat-link { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; font-size: 14px; }
.chat-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link:hover { background: var(--sunk); }
.chat-link[aria-current="page"] { background: var(--sunk); font-weight: 600; }
.chat-empty { margin: 16px 8px; color: var(--muted); font-size: 13px; }
.side-foot { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.storage { display: grid; gap: 4px; padding: 0 6px; }
.storage .bar { height: 4px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.storage .bar span { display: block; height: 100%; width: 0; background: var(--signal); }
.storage.warn .bar span { background: var(--warn); }
.storage small { color: var(--muted); font-size: 12px; }
.me { position: relative; display: flex; align-items: center; gap: 10px; padding: 4px 4px 0 6px; }
.me img { border-radius: 50%; background: var(--sunk); flex: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--signal-soft); color: var(--signal); font-weight: 700; font-size: 13px; }
.me-text { min-width: 0; flex: 1; display: grid; line-height: 1.25; }
.me-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; bottom: 44px; right: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--sunk); }

.main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 85%, transparent); backdrop-filter: blur(8px); }
.chat-title { flex: 1; margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 2px; }
#pin-chat[aria-pressed="true"] { color: var(--signal); }

/* Thread */
.thread { overflow-y: auto; padding: 28px 20px 12px; scroll-behavior: smooth; }
.turn { max-width: 820px; margin: 0 auto 26px; }
.q { display: flex; justify-content: flex-end; }
.q p { margin: 0; max-width: 85%; background: var(--signal-soft); color: var(--ink); padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.a { margin-top: 18px; }

/* The checks strip: what the assistant read live, as it happens */
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 4px 10px 4px 8px; border-radius: 999px; }
.check i { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); flex: none; }
.check.running i { animation: pulse 1.1s ease-in-out infinite; }
.check.done i { background: var(--ok); }
.check.error i { background: var(--bad); }
.check.done { color: var(--ink); }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.15); opacity: 1; } }

.thinking { display: inline-flex; gap: 5px; padding: 6px 2px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }

/* Answer prose */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md ul, .md ol { padding-left: 1.3em; }
.md li { margin: 3px 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin: 20px 0 8px; letter-spacing: -.005em; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3, .md h4 { font-size: 16px; }
.md a { color: var(--signal); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--sunk); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--sunk); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* Ledger tables */
.ledger { margin: 4px 0 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.ledger-scroll { overflow: auto; max-height: 460px; }
.ledger table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.ledger th { position: sticky; top: 0; background: var(--sunk); text-align: left; font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ledger td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: normal; min-width: 9ch; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger tbody tr:hover td { background: color-mix(in srgb, var(--signal-soft) 50%, transparent); }
.ledger .num { text-align: right; white-space: nowrap; }
.ledger-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--line); background: var(--paper); }
.ledger-bar small { flex: 1; color: var(--muted); padding-left: 4px; }
.ledger-bar .btn { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.ledger-bar svg { width: 16px; height: 16px; }

/* Answer footer */
.a-foot { display: flex; align-items: center; gap: 2px; margin-top: 4px; color: var(--muted); }
.a-foot .icon-btn { width: 30px; height: 30px; }
.a-foot .icon-btn svg { width: 17px; height: 17px; }
.a-foot .icon-btn[aria-pressed="true"] { color: var(--signal); background: var(--signal-soft); }
.a-foot .flag { font-size: 13px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.a-foot .flag:hover { background: var(--sunk); color: var(--ink); }
.a-foot .flag[aria-pressed="true"] { color: var(--bad); }
.a-error { color: var(--bad); margin: 6px 0; }
.connect { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; padding: 10px 12px; border: 1px dashed var(--signal); border-radius: 10px; background: var(--signal-soft); font-size: 14px; }

/* Welcome */
.welcome { overflow-y: auto; padding: 8vh 20px 20px; }
.welcome > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.welcome h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -.02em; margin-bottom: 10px; font-weight: 700; }
.lede { color: var(--muted); font-size: 17px; margin-top: 0; margin-bottom: 28px; text-wrap: pretty; }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.starter-group { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 14px 14px 8px; }
.starter-group h3 { margin: 0 0 6px; font-size: 14px; }
.starter { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--muted); padding: 7px 8px; margin: 0 -8px; width: calc(100% + 16px); border-radius: 8px; cursor: pointer; font-size: 14px; }
.starter:hover { background: var(--sunk); color: var(--ink); }

/* Composer */
.composer { padding: 10px 20px 16px; }
.composer-box { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); transition: border-color .15s; }
.composer-box:focus-within { border-color: var(--signal); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; padding: 7px 0; max-height: 220px; line-height: 1.5; }
.send { width: 38px; height: 38px; border-radius: 11px; border: 0; background: var(--signal); color: var(--signal-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { opacity: .4; cursor: default; }
.send.stop { background: var(--ink); color: var(--paper); }
.send.stop svg { fill: currentColor; stroke: none; }
.composer-box .icon-btn { flex: none; width: 38px; height: 38px; }
.mic[aria-pressed="true"] { color: #fff; background: #d93025; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(217, 48, 37, .18); } }
@media (prefers-reduced-motion: reduce) { .mic[aria-pressed="true"] { animation: none; } }
.attached, .q-files { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.q-files { margin: 6px 0 0; max-width: none; justify-content: flex-end; }
.file-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 260px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .icon-btn { width: 22px; height: 22px; }
.file-chip .icon-btn svg { width: 14px; height: 14px; }
.hint { max-width: 820px; margin: 8px auto 0; font-size: 12px; color: var(--muted); text-align: center; }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 16, 30, .45); }
.admin { width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.admin[open] { display: flex; flex-direction: column; }
.admin-head { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin-head h2 { margin: 0; font-size: 18px; flex: 1 0 auto; }
.tabs { display: flex; gap: 4px; background: var(--sunk); padding: 3px; border-radius: 10px; }
.tabs button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.admin-body { padding: 16px 18px 20px; overflow: auto; }
.add-user { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-user input[type="email"] { flex: 1 1 240px; }
.add-user input[type="email"], .add-user select, .people select { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 7px 10px; }
.check-label, .add-user .check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink); border: 0; background: none; padding: 0; }
.table-scroll { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; }
.people { border-collapse: collapse; width: 100%; font-size: 14px; }
.people th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 9px 12px; background: var(--sunk); white-space: nowrap; }
.people td { padding: 8px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.people .num { text-align: right; }
.people .who { display: grid; line-height: 1.3; }
.people .who small { color: var(--muted); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 4px 2px 9px; white-space: nowrap; }
.chip.google { color: var(--muted); background: var(--sunk); padding-right: 9px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; }
.chips select { font-size: 12px; border: 1px dashed var(--line); background: none; border-radius: 999px; padding: 2px 6px; color: var(--muted); }
.people input.limit { width: 70px; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 4px 6px; }
.spend-totals { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.spend-tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: grid; gap: 2px; min-width: 130px; }
.spend-tile small { color: var(--muted); font-size: 12px; }
.spend-tile b { font-size: 20px; }
.group-cards { display: grid; gap: 12px; margin: 10px 0; }
.group-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.group-card header { display: flex; align-items: center; gap: 10px; }
.group-card header b { flex: 1; }
.group-card .sets { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.group-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); padding: 6px 10px; }
.group-card .err { color: var(--bad); font-size: 13px; white-space: pre-wrap; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 6px 0; }
.fb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.fb-list li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.fb-list .meta { font-size: 13px; color: var(--muted); }
.fb-list q { display: block; margin: 4px 0; quotes: none; }
.rating { font-weight: 600; }
.rating.up { color: var(--ok); } .rating.down, .rating.wrong, .rating.rule { color: var(--bad); }
.small-dialog { width: min(520px, calc(100vw - 32px)); }
.small-dialog form { padding: 20px; display: grid; gap: 12px; }
.small-dialog h2 { margin: 0; font-size: 17px; }
.small-dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 10px 12px; resize: vertical; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }
.toast a { color: var(--mint); }

.only-mobile { display: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .ledger-bar { flex-wrap: wrap; }
  .ledger-bar small { flex-basis: 100%; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .app.side-open .sidebar { transform: none; }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,16,30,.4); z-index: 25; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 10px 12px; }
  .thread { padding: 18px 16px 8px; }
  .composer { padding: 8px 12px 12px; }
  .starters { grid-template-columns: 1fr; }
  .welcome { padding-top: 4vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.policy-text { width: 100%; font-family: var(--mono); font-size: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 10px 12px; resize: vertical; margin: 8px 0; }
.toast { white-space: pre-line; }
.fb-list .evidence { white-space: pre-wrap; font-size: 12.5px; max-height: 240px; overflow: auto; background: var(--sunk); padding: 8px; border-radius: 8px; }
.review-actions { display: grid; gap: 8px; margin-top: 8px; }
.review-actions textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 8px 10px; resize: vertical; }
/* CPQ card: the preview Salesforce priced, and the one button that acts on it. */
.qcard { margin: 12px 0; border: 1px solid var(--line); border-left: 3px solid var(--signal); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); padding: 14px 16px; }
.qcard.done { border-left-color: var(--ok); }
.qcard.failed { border-left-color: var(--bad); }
.qcard.replaced { opacity: .6; border-left-color: var(--line); }
.qcard-head { font-weight: 600; font-size: 13px; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.qcard-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.qcard-note { color: var(--muted); font-size: 13px; }
.qcard-status { font-weight: 600; font-size: 14px; }
.qcard-status.done { color: var(--ok); }
.qcard-status.failed { color: var(--bad); }
.qcard-status.replaced { color: var(--muted); }
.qcard-result { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--sunk); }
p.error { color: var(--bad); font-size: 13px; }
