:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #64748b;
  --border: #e4e7ec;
  --border-strong: #cfd5de;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f4f2;
  --side: #0b1324;
  --side-ink: #cbd5e1;
  --side-muted: #64748b;
  --side-active: #16223b;
  --high: #b42318; --high-soft: #fdecea;
  --med: #b54708; --med-soft: #fef3e2;
  --low: #475467; --low-soft: #eef1f5;
  --ok: #067647; --ok-soft: #e7f6ee;
  --info: #175cd3; --info-soft: #e8f0fd;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --radius: 12px;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1a; --surface: #111827; --surface-2: #0f1522; --ink: #e8ecf3; --ink-2: #c3cad6; --muted: #8b95a7;
    --border: #1f2937; --border-strong: #2b3646; --accent: #2dd4bf; --accent-ink: #04211e; --accent-soft: #0f2c2a;
    --side: #070b14; --side-active: #131c2e;
    --high: #f97066; --high-soft: #3a1513; --med: #fdb022; --med-soft: #3a2a0b; --low: #98a2b3; --low-soft: #1b2330;
    --ok: #47cd89; --ok-soft: #0f2c1f; --info: #84adff; --info-soft: #14213d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f1a; --surface: #111827; --surface-2: #0f1522; --ink: #e8ecf3; --ink-2: #c3cad6; --muted: #8b95a7;
  --border: #1f2937; --border-strong: #2b3646; --accent: #2dd4bf; --accent-ink: #04211e; --accent-soft: #0f2c2a;
  --side: #070b14; --side-active: #131c2e;
  --high: #f97066; --high-soft: #3a1513; --med: #fdb022; --med-soft: #3a2a0b; --low: #98a2b3; --low-soft: #1b2330;
  --ok: #47cd89; --ok-soft: #0f2c1f; --info: #84adff; --info-soft: #14213d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #2dd4bf, #0f766e); display: grid; place-items: center; font-weight: 800; color: #04211e; }
.brand b { font-size: 16px; letter-spacing: .02em; }
.brand small { display: block; color: var(--side-muted); font-size: 11px; margin-top: -2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 2px 0 0 #2dd4bf; }
.nav svg { width: 17px; height: 17px; opacity: .85; flex: none; }
.nav .count { margin-left: auto; background: #1e2a44; color: #e2e8f0; font-size: 11px; padding: 1px 7px; border-radius: 99px; }
.nav .count.alert { background: #7a271a; }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 11.5px; color: var(--side-muted); line-height: 1.45; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 28px; top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; z-index: 5; }
.top .search { flex: 1; max-width: 420px; position: relative; }
.top .search input { padding-left: 34px; }
.top .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.search-results a { display: block; padding: 8px 12px; color: var(--ink); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.top .menu-btn { display: none; }
.content { padding: 24px 28px 64px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }

/* Cards / grid */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.alert .value { color: var(--high); }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.diff { background: var(--med-soft); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--low-soft); color: var(--low); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-high { background: var(--high-soft); color: var(--high); }
.b-med { background: var(--med-soft); color: var(--med); }
.b-low { background: var(--low-soft); color: var(--low); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-accent { background: var(--accent-soft); color: var(--accent); }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--high); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
label.field { display: block; }
label.field > span { display: block; font-size: 12.5px; font-weight: 550; color: var(--ink-2); margin-bottom: 5px; }
label.field > small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
input, select, textarea { width: 100%; font: 14px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
textarea.letter { font: 13px/1.6 var(--mono); min-height: 520px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid.g3f { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.g4f { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 8px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-color: var(--accent); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-top: 7px; flex: none; }

/* Finding */
.finding { border: 1px solid var(--border); border-left: 3px solid var(--low); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.finding.high { border-left-color: var(--high); }
.finding.medium { border-left-color: var(--med); }
.finding + .finding { margin-top: 10px; }
.finding .t { font-weight: 600; }
.finding .d { color: var(--ink-2); margin: 4px 0 6px; }
.finding .f { font-size: 12px; color: var(--muted); }

/* Steps */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.tick { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex: none; font-size: 12px; }
.tick.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Pipeline */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.col h3 { display: flex; justify-content: space-between; padding: 4px 4px 10px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ticket { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: var(--ink); box-shadow: var(--shadow); }
.ticket + .ticket { margin-top: 8px; }
.ticket:hover { border-color: var(--accent); text-decoration: none; }
.ticket .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Progress / bars */
.bar { height: 8px; background: var(--low-soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.score { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: var(--high); font-weight: 600; }

.callout { border-radius: 10px; padding: 12px 14px; background: var(--info-soft); color: var(--ink); border: 1px solid transparent; }
.callout.warn { background: var(--med-soft); }
.callout.bad { background: var(--high-soft); }
.callout.good { background: var(--ok-soft); }
.callout b { display: block; margin-bottom: 2px; }
.prose { max-width: 760px; }
.prose p, .prose li { color: var(--ink-2); }
.prose h3 { margin: 20px 0 6px; }
pre.doc { white-space: pre-wrap; font: 13px/1.65 var(--font); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin: 0; max-height: 520px; overflow: auto; }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(8, 12, 22, .55); display: grid; place-items: start center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.wide { max-width: 980px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 14px 14px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 60; font-weight: 500; animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .top .menu-btn { display: inline-flex; }
  .top .top-new { display: none; }
  .top { padding-block: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .content { padding-block: 18px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .g2, .form-grid, .form-grid.g3f, .form-grid.g4f { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 22px; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .empty-banner { flex-direction: column; align-items: flex-start; }
  .form-grid .span2 { grid-column: auto; }
  .board { grid-template-columns: repeat(5, 240px); }
}
@media print {
  .side, .top, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

td.actions .btn { padding: 0 8px; margin-right: 3px; }

/* Ledger AI drawer */
.ai-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 45; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .2s ease; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.ai-drawer.open { transform: none; }
.ai-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ai-head b { font-size: 15px; }
.ai-ctx { padding: 10px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 4px; }
.ai-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child { margin: 0; }
.ai-msg ul, .ai-msg ol { margin: 4px 0 8px; padding-left: 20px; }
.ai-msg h4 { margin: 8px 0 4px; font-size: 13.5px; }
.ai-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.ai-msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }
.ai-empty { color: var(--ink-2); }
.ai-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); align-items: flex-end; }
.ai-input textarea { min-height: 44px; resize: none; flex: 1; width: auto; min-width: 0; }
.ai-input .btn { flex: none; }
.ai-foot { padding: 0 16px 12px; }
.ai-fab { position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); z-index: 30; border-radius: 99px; height: 44px; padding: 0 18px; box-shadow: var(--shadow-lg); }
@media print { .ai-drawer, .ai-fab { display: none !important; } }

/* Upload hub */
.up-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.up-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.up-card h3 { font-size: 14px; }
.up-main { grid-row: span 2; border-color: var(--accent); background: var(--accent-soft); }
.drop { flex: 1; min-height: 140px; border: 2px dashed var(--border-strong); border-radius: 12px; display: grid; place-content: center; text-align: center; gap: 4px; cursor: pointer; background: var(--surface); padding: 16px; }
.drop:hover, .drop.over { border-color: var(--accent); }
@media (max-width: 820px) { .up-grid { grid-template-columns: 1fr; } .up-main { grid-row: auto; } }

/* Library */
.lib-search { margin-bottom: 16px; max-width: 720px; }
.lib-search input { height: 42px; font-size: 15px; }
.lib-dl { margin: 0; display: grid; gap: 0; }
.lib-dl > div { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lib-dl > div:last-child { border-bottom: 0; }
.lib-dl dt { font-weight: 600; }
.lib-dl dd { margin: 0; color: var(--ink-2); }
@media (max-width: 820px) { .lib-dl > div { grid-template-columns: 1fr; gap: 4px; } }

/* Letter templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.tpl-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tpl-card small { color: var(--muted); line-height: 1.4; }

/* Sales pipeline */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kan-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 120px; }
.kan-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; }
.kan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.kan-card a { color: inherit; text-decoration: none; }
/* Report comparison */
tr.cmp-deleted td { background: var(--ok-soft); }
tr.cmp-new td { background: var(--high-soft); }
tr.cmp-changed td { background: var(--med-soft); }
/* Toggle */
.switch input { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; background: var(--border-strong); border-radius: 99px; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 16px; }

/* Empty-workspace banner */
.empty-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; }
.empty-banner .row { gap: 8px; flex-wrap: wrap; }
/* Keep the page usable while Ledger AI is open: on wide screens the page shifts left instead of being covered. */
@media (min-width: 1100px) { body.ai-open .main { padding-right: 440px; } body.ai-open .ai-fab { display: none; } }

.field-err { color: var(--high); font-weight: 550; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--high) !important; box-shadow: 0 0 0 3px var(--high-soft); }

/* Ledger Assistant (staff) and helper (portal/apply) */
.lb-fab { bottom: max(76px, calc(env(safe-area-inset-bottom, 0px) + 76px)); background: var(--surface); }
.kb-list li { align-items: flex-start; }
.helper-fab { position: fixed; right: 20px; bottom: 20px; z-index: 40; border-radius: 99px; height: 44px; padding: 0 18px; box-shadow: var(--shadow-lg); }
.helper-panel { position: fixed; right: 20px; bottom: 76px; z-index: 41; width: min(380px, calc(100vw - 40px)); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.helper-panel[hidden] { display: none; }
.helper-log { padding: 12px; overflow: auto; flex: 1; font-size: 14px; }
.helper-log .me { text-align: right; color: var(--ink); margin: 6px 0; }
.helper-log .bot { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.helper-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.deadline-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.deadline-bar > span { display: block; height: 100%; background: var(--accent); }
.deadline-bar.late > span { background: var(--high); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media print { .lb-fab, .helper-fab, .helper-panel { display: none !important; } }
