:root {
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ink: #222; --ink-2: #4d4d4d; --muted: #666; --faint: #8a8a8a;
  --line: #e3e3e3; --line-2: #d4d2da; --paper: #fff; --band: #f4f2f8; --neutral: #f5f6f9;
  --accent: #7a1fc2; --accent-soft: #f1e8fa; --accent-line: #c9a6e8;
  --sel: #efe6f9;
  --ro-bg: #eeedf3; --total-bg: #ebe8f1; --group-bg: #e3dfec;
  /* states: tinted backgrounds + dark text, always paired with an icon and a word */
  --draft-ink: #4d4d4d; --draft-bg: #fff; --draft-line: #c9c9c9;
  --review-ink: #7a4300; --review-bg: #fff4e0; --review-line: #efc98a;
  --ok-ink: #1d6b3c; --ok-bg: #e8f4ec; --ok-line: #a9d3b7;
  --bad-ink: #a3261c; --bad-bg: #fdecea;
  --remote: #0b6e8a; --remote-bg: #e4f3f7;
  --radius: 4px; --card: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--paper);
  font-size: 14px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100dvh; height: 100dvh; overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { width: 16px; height: 16px; display: inline-block; flex: none; vertical-align: -3px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: 8px; top: -40px; background: #222; color: #fff; padding: 8px 12px; border-radius: 4px; z-index: 100; }
.skip:focus { top: 8px; }
mark { background: #fbe9a6; color: inherit; border-radius: 2px; }
kbd { font: 12px/1 var(--font); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; background: #fff; color: var(--ink); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid transparent; background: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn.dark { background: #222; color: #fff; }
.btn.dark:hover { background: var(--accent); }
.btn.ghost { border-color: var(--line); background: #fff; color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent-line); color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }
.btn.chip { border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.btn.chip[aria-pressed="true"] { background: #222; color: #fff; border-color: #222; }
.icon-btn { padding: 0 8px; }
.btn > svg { width: 16px; height: 16px; flex: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 2px; gap: 2px; }
.seg-btn { border: 0; background: none; height: 26px; padding: 0 10px; border-radius: 3px; color: var(--ink-2); white-space: nowrap; }
.seg-btn:hover { color: var(--accent); }
.seg-btn[aria-pressed="true"] { background: #222; color: #fff; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fff; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand-name { font-weight: 700; }
.brand-co { color: var(--muted); white-space: nowrap; }
.brand-co .sep { margin: 0 4px; color: var(--line-2); }
.views { display: flex; gap: 2px; margin-left: 12px; background: var(--neutral); padding: 3px; border-radius: 6px; }
.view-btn { border: 0; background: none; padding: 6px 12px; border-radius: 4px; color: var(--ink-2); white-space: nowrap; }
.view-btn:hover { color: var(--accent); }
.view-btn[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.savestate { margin: 0 6px 0 0; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sv { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sv-ok { background: var(--ok-ink); }
.sv-busy { border: 2px solid var(--line-2); border-top-color: var(--accent); width: 12px; height: 12px; animation: spin .8s linear infinite; }
.sv-bad { color: var(--bad-ink); display: inline-flex; gap: 5px; align-items: center; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgb(30 10 60 / .14); padding: 6px; display: grid; }
.menu-h { margin: 6px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu [role^=menuitem] { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 4px; display: grid; gap: 2px; }
.menu [role^=menuitem]:hover, .menu [role^=menuitem]:focus-visible { background: var(--accent-soft); outline: none; color: var(--accent); }
.menu [role=menuitemcheckbox]::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.menu [role=menuitemcheckbox] { display: block; }
.menu [aria-checked="true"]::before { background: currentColor; box-shadow: inset 0 0 0 2px #fff; }
.menu [role=menuitem] span { font-size: 12px; color: var(--muted); }
.status-menu { position: fixed; right: auto; top: 0; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px 10px; flex: none; }
.tb-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-grow { flex: 1; }
.view-title { font-size: 20px; font-weight: 300; margin: 0; letter-spacing: -.01em; white-space: nowrap; }
.unit { color: var(--muted); font-size: 13px; white-space: nowrap; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 9px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { height: 32px; width: 210px; padding: 0 10px 0 32px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
body[data-view=plan] .var-only, body[data-view=var] .plan-only { display: none !important; }
#btn-threshold b { font-weight: 700; }

/* ---------- inspector strip ---------- */
.inspector { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-height: 36px; padding: 6px 16px; margin: 0; background: var(--neutral); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); flex: none; }
.inspector .ins-k { font-weight: 700; color: var(--ink); }
.inspector .ins-v { font-variant-numeric: tabular-nums; color: var(--ink); }
.inspector .tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 3px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); background: #fff; }
.inspector .t-calc { color: var(--accent); border-color: var(--accent-line); }
.inspector .t-locked { color: var(--ok-ink); border-color: var(--ok-line); }
.inspector .t-remote { color: var(--remote); border-color: #9fd0dd; }
.inspector .t-unsaved { color: var(--bad-ink); border-color: #f0b4ad; }
.inspector.flash { background: var(--accent-soft); color: var(--ink); }
.inspector.flash.error { background: var(--bad-bg); color: var(--bad-ink); }
.inspector.flash.locked { background: var(--ok-bg); color: var(--ok-ink); }
.inspector.flash .ic { color: currentColor; }
.filter-note { margin: 0; padding: 6px 16px; font-size: 13px; color: var(--ink-2); background: #fffbea; border-bottom: 1px solid #f2e6b4; flex: none; }

/* ---------- grid ---------- */
.grid-area { position: relative; flex: 1; min-height: 0; display: flex; }
.grid-scroll { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; }
.grid-scroll:focus { outline: none; }
#grid { position: relative; min-width: 100%; font-variant-numeric: tabular-nums; --rh: 36px; }
.ghead { position: sticky; top: 0; z-index: 4; }
.row { display: flex; height: var(--rh); border-bottom: 1px solid var(--line); background: #fff; }
.hrow { height: 40px; background: #fff; border-bottom: 1px solid var(--line-2); }
.cell { flex: none; height: 100%; display: flex; align-items: center; padding: 0 10px; border-right: 1px solid #eeedf1; position: relative; background: inherit; white-space: nowrap; overflow: visible; outline: none; }
.cell.num { justify-content: flex-end; }
.cell.sticky { position: sticky; z-index: 2; }
.row .cell.sticky:nth-child(1) { box-shadow: none; }
.cell.sticky + .cell:not(.sticky) { }
#grid .row > .cell.sticky { border-right: 1px solid var(--line-2); }
.filler { flex: 1; }
.hcell { font-size: 12px; font-weight: 700; color: var(--ink-2); gap: 4px; user-select: none; }
.hcell .count { font-weight: 400; color: var(--muted); margin-left: 4px; }
.hcell.sortable { cursor: pointer; }
.hcell.sortable:hover { color: var(--accent); }
.hcell .sort-ic .ic { width: 14px; height: 14px; }
.hcell[aria-sort="ascending"], .hcell[aria-sort="descending"] { color: var(--accent); }
.col-total { border-left: 1px solid var(--line-2); }
.hl { overflow: hidden; text-overflow: ellipsis; }

/* name column */
.name { display: flex; align-items: center; gap: 4px; min-width: 0; width: 100%; }
.nm { overflow: hidden; text-overflow: ellipsis; }
.tw { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; border-radius: 4px; color: var(--ink-2); flex: none; cursor: pointer; }
.tw:hover { background: var(--accent-soft); color: var(--accent); }
.tw-gap { width: 20px; flex: none; }
.formula { font-size: 12px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.badge-remote { margin-left: 6px; display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--remote); background: var(--remote-bg); border-radius: 999px; padding: 1px 7px 1px 3px; }
.badge-remote .ic { width: 12px; height: 12px; }
.mini-status { margin-left: auto; padding-left: 6px; display: inline-flex; }
.mini-status.st-review { color: var(--review-ink); }
.mini-status.st-approved { color: var(--ok-ink); }
.mini-status.st-draft { color: var(--faint); }

/* Cell types. White = you can type. Everything else sits on grey. */
.row { background: var(--ro-bg); }
.cell { background: var(--ro-bg); color: var(--ink-2); }
.cell[role=rowheader] { color: var(--ink); }
.row-locked.kind-line .cell.num { color: #6b6b75; }
.row-locked.kind-line .cell[role=rowheader] { color: var(--ink-2); }
.cell.k-input { background: #fff; color: var(--ink); cursor: cell; }
.cell.k-input:hover { box-shadow: inset 0 0 0 1px var(--accent-line); }
.kind-group .cell, .kind-group { background: var(--group-bg); font-weight: 700; color: var(--ink); }
.kind-dept .cell, .kind-dept-sub .cell { background: var(--total-bg); font-weight: 700; color: var(--ink); }
.kind-result .cell { background: #fff; color: var(--ink); }
.kind-result { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.col-total { font-weight: 700; }
.col-ref { color: var(--muted); }
.cell.first-ref { border-left: 1px solid var(--line-2); }
.row-mine .cell[role=rowheader] { background: #fff; }
.row-mine.kind-dept .cell[role=rowheader] { background: var(--total-bg); }
.cell.is-empty .ph { position: absolute; inset: 6px 7px; border: 1.5px dashed #b9b0c9; border-radius: 3px; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; font-size: 12px; color: #8d84a0; font-style: normal; font-weight: 400; }
.cell.k-input.is-empty:hover .ph { border-color: var(--accent); color: var(--accent); }
.cell.target { box-shadow: inset 0 0 0 2px #e2c9f5; }
.cell.target.is-empty .ph { border-color: var(--accent); color: var(--accent); background: #faf5fe; }
.cell.warn { background: #fff7e6 !important; color: #7a4300; font-weight: 700; }
.mk-warn { position: absolute; left: 5px; color: #b26a00; display: inline-flex; }
.mk-warn .ic { width: 13px; height: 13px; }
.cmp { display: inline-flex; align-items: center; gap: 4px; }
.flag-check { color: #7a4300; font-weight: 700; }
.flag-check .ic { color: #b26a00; width: 14px; height: 14px; }
.cell.is-flagged { background: #fff7e6; }
.cell.sticky-r { position: sticky; z-index: 2; }
.hint-i { display: inline-flex; vertical-align: -3px; color: var(--muted); }
.hint-i .ic { width: 13px; height: 13px; }
.dept-tags { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding-left: 6px; }
.owner { font-size: 12px; font-weight: 400; color: var(--muted); }
.cell-hint { position: absolute; top: calc(100% + 3px); right: -1px; z-index: 9; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; font-style: normal; padding: 3px 8px; border-radius: 4px; white-space: nowrap; pointer-events: none; box-shadow: 0 3px 10px rgb(80 20 140 / .25); }
.cell-hint::before { content: ""; position: absolute; top: -4px; right: 14px; border: 4px solid transparent; border-top: 0; border-bottom-color: var(--accent); }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px 0 6px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid; line-height: 1; }
.pill .ic { width: 14px; height: 14px; }
.st-draft { color: var(--draft-ink); background: var(--draft-bg); border-color: var(--draft-line); }
.st-review { color: var(--review-ink); background: var(--review-bg); border-color: var(--review-line); }
.st-approved { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-line); }
.status-cell { cursor: pointer; gap: 2px; }
.pill-caret { color: var(--muted); opacity: 0; display: inline-flex; }
.status-cell:hover .pill-caret, .status-cell.active .pill-caret { opacity: 1; }

/* selection & focus */
.cell.sel { background: var(--sel) !important; box-shadow: inset 0 0 0 1px #d7c3ee; }
.cell.active { z-index: 3; }
.cell.active::before { content: ""; position: absolute; inset: -1px; border: 2px solid var(--accent); pointer-events: none; z-index: 2; border-radius: 1px; }
#grid-scroll:not(:focus-within) .cell.active::before { border-color: #b9a3cf; border-width: 1.5px; }
.cell.sticky.active { z-index: 3; }
.row-active .cell[role=rowheader] { box-shadow: inset 3px 0 0 var(--accent); }

/* teammate change & unsaved markers */
.cell.remote { background: var(--remote-bg) !important; }
.mk-remote { position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: 0 2px 2px 0; background: var(--remote); }
.remote-new .mk-remote { animation: pulse 1.6s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(11 110 138 / .5); } 100% { box-shadow: 0 0 0 8px rgb(11 110 138 / 0); } }
.cell.unsaved { color: var(--bad-ink); }
.mk-unsaved { position: absolute; left: 4px; color: var(--bad-ink); display: inline-flex; }
.mk-unsaved .ic { width: 13px; height: 13px; }

/* editor */
.cell.editing { padding: 0; z-index: 6; overflow: visible; }
.cell-input { width: 100%; height: 100%; border: 2px solid var(--accent); padding: 0 8px; text-align: right; background: #fff; outline: none; font-variant-numeric: tabular-nums; box-shadow: 0 2px 10px rgb(80 20 140 / .18); border-radius: 1px; font-style: normal; font-weight: 400; }
.cell-input[aria-invalid="true"] { border-color: var(--bad-ink); }
.cell-msg { position: absolute; top: calc(100% + 4px); right: 0; z-index: 10; width: max-content; max-width: 300px; white-space: normal; display: flex; gap: 6px; align-items: flex-start; padding: 7px 10px; border-radius: 6px; font-size: 12.5px; line-height: 1.35; font-weight: 400; font-style: normal; box-shadow: 0 6px 20px rgb(0 0 0 / .14); text-align: left; }
.cell.editing::before { display: none; }
.cell-msg.above { top: auto; bottom: calc(100% + 4px); }
.cell-msg.error { background: var(--bad-ink); color: #fff; }
.cell-msg.info { background: var(--remote); color: #fff; }
.cell-msg .ic { flex: none; margin-top: 1px; }
.cell-msg.error .ic circle { fill: #fff; } .cell-msg.error .ic path { stroke: var(--bad-ink); }

/* variance */
.v-var .cell.strong { font-weight: 700; }
.flag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; }
.flag.bad { color: var(--bad-ink); }
.flag.good { color: var(--ok-ink); }
.f-bad { box-shadow: inset 3px 0 0 var(--bad-ink); }

/* compact density */
#grid[style*="--rh: 28px"] .pill { height: 18px; font-size: 11px; }

/* ---------- state panel (loading, error, empty) ---------- */
.state-panel { position: absolute; inset: 0; background: #fff; z-index: 8; overflow: hidden; }
.grid-area.is-empty .state-panel { top: 41px; }
.state { max-width: 420px; margin: 64px auto; text-align: center; display: grid; gap: 10px; justify-items: center; padding: 0 16px; }
.state h2 { margin: 0; font-size: 20px; font-weight: 300; }
.state p { margin: 0; color: var(--ink-2); }
.state-ic { color: var(--bad-ink); }
.state-ic .ic { width: 28px; height: 28px; }
.skeleton { padding: 0; }
.sk-row { display: flex; gap: 16px; align-items: center; height: 36px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.sk-row span { display: block; height: 10px; border-radius: 3px; background: #eceaf1; flex: none; width: 30%; max-width: 260px; }
.sk-row i { display: block; height: 10px; flex: 1; border-radius: 3px; background: #f1f0f5; }
.sk-row:nth-child(odd) span, .sk-row:nth-child(odd) i { animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { 50% { opacity: .55; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 60; display: grid; gap: 8px; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #222; color: #fff; border-radius: 8px; padding: 10px 10px 10px 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .2); font-size: 13.5px; animation: up .18s ease-out; }
.toast-t { flex: 1; }
.toast-btn { border: 1px solid rgb(255 255 255 / .35); background: none; color: #fff; border-radius: 4px; padding: 4px 10px; font-weight: 700; }
.toast-btn:hover { border-color: #fff; background: rgb(255 255 255 / .1); }
.toast-x { border: 0; background: none; color: #bbb; padding: 4px; display: inline-flex; }
.toast-x:hover { color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- dialogs ---------- */
.dlg { border: 0; border-radius: var(--card); padding: 0; width: min(760px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgb(20 0 50 / .25); color: var(--ink); }
.dlg::backdrop { background: rgb(20 16 30 / .4); }
.dlg-sm { width: min(440px, calc(100vw - 32px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.dlg h2 { margin: 0; font-size: 20px; font-weight: 300; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; padding: 6px 20px 8px; }
.keys h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 10px 0 6px; }
.keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; font-size: 13px; }
.keys dt { white-space: nowrap; color: var(--ink-2); }
.keys dd { margin: 0; }
.dlg-foot, .dlg-text { padding: 4px 20px 18px; margin: 0; color: var(--ink-2); font-size: 13px; }
.rule-fields { display: grid; gap: 12px; padding: 0 20px 8px; }
.rule-fields label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.field { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; height: 36px; }
.field input { border: 0; width: 96px; text-align: right; outline: none; }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }

/* ---------- tablet / touch ---------- */
@media (max-width: 1099px), (pointer: coarse) {
  .brand-co, .lbl { display: none; }
  .views { margin-left: 4px; }
  .search input { width: 160px; }
  .hide-touch { display: none; }
  .btn, .seg-btn { min-height: 36px; }
  .seg-btn { height: 32px; }
  .tw { width: 28px; height: 28px; }
}
@media (max-width: 860px) {
  .savestate { display: none; }
  .unit { display: none; }
}

/* ---------- phone ---------- */
body.is-phone { background: var(--neutral); flex-direction: column; }
body.is-phone .skip { display: none !important; }
.mobile { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; font-size: 15px; }
.m-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 8px; flex-wrap: wrap; }
.m-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.m-brand svg { width: 22px; height: 22px; }
.m-co { font-weight: 400; color: var(--muted); font-size: 13px; }
.m-views { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px; width: 100%; }
.m-views button, .m-periods button { flex: 1; border: 0; background: none; min-height: 40px; border-radius: 4px; color: var(--ink-2); }
.m-views [aria-pressed="true"], .m-periods [aria-pressed="true"] { background: #222; color: #fff; font-weight: 700; }
.m-back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); min-height: 44px; padding: 0 8px 0 0; font-weight: 700; max-width: 100%; }
.m-back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-h1 { font-size: 26px; font-weight: 300; margin: 6px 0 12px; letter-spacing: -.01em; outline: none; line-height: 1.2; }
.m-h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.m-count { background: #222; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }
.m-sub, .m-progress, .m-rule { color: var(--ink-2); margin: 0 0 8px; font-size: 14px; }
.m-summary { background: #fff; border-radius: var(--card); padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; border: 1px solid var(--line); margin-bottom: 10px; }
.m-summary div { display: grid; gap: 2px; }
.m-summary span { font-size: 13px; color: var(--muted); }
.m-summary b { font-size: 18px; font-variant-numeric: tabular-nums; }
.m-noi { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
.m-noi b { font-size: 24px; font-weight: 300; }
.m-noi small { color: var(--ink-2); }
.m-periods { display: flex; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px; margin-bottom: 10px; }
.m-list { list-style: none; margin: 0; padding: 0; background: #fff; border-radius: var(--card); border: 1px solid var(--line); overflow: hidden; }
.m-list li + li { border-top: 1px solid var(--line); }
.m-row { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 12px 12px 12px 16px; min-height: 60px; }
.m-row:active { background: var(--band); }
.m-row-main { flex: 1; min-width: 0; display: grid; gap: 4px; justify-items: start; }
.m-name { font-weight: 700; }
.m-row-side { display: grid; justify-items: end; gap: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.m-row-side small, .m-row-main small { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.m-chev { color: var(--faint); display: inline-flex; }
.m-calc { color: var(--accent) !important; }
.m-miss { color: var(--review-ink) !important; }
.m-remote { color: var(--remote) !important; font-weight: 700; }
.m-dept-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--ink-2); font-size: 14px; }
.m-total { display: flex; justify-content: space-between; align-items: baseline; background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 12px 16px; margin: 12px 0; font-variant-numeric: tabular-nums; }
.m-total b { font-size: 20px; }
.m-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.m-actions .btn, .m-save .btn { min-height: 44px; flex: 1; justify-content: center; }
.m-note { display: flex; gap: 8px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 12px 14px; margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.m-months { background: #fff; border: 1px solid var(--line); border-radius: var(--card); overflow: hidden; }
.m-month { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 8px 12px 8px 16px; min-height: 56px; border-bottom: 1px solid var(--line); }
.m-month:last-child { border-bottom: 0; }
.m-month.ro { font-variant-numeric: tabular-nums; }
.m-month.is-remote { background: var(--remote-bg); }
.m-in { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0 10px; height: 44px; width: 150px; background: #fff; color: var(--muted); }
.m-in:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.m-in input { border: 0; outline: none; width: 100%; text-align: right; font-size: 16px; color: var(--ink); background: none; font-variant-numeric: tabular-nums; }
.m-in input::placeholder { color: #aaa; font-size: 14px; }
.m-in:has(input[aria-invalid="true"]) { border-color: var(--bad-ink); }
.m-err { grid-column: 1 / -1; color: var(--bad-ink); font-size: 13px; display: flex; gap: 5px; align-items: flex-start; }
.m-err:empty { display: none; }
.m-month .m-remote { grid-column: 1 / -1; font-size: 12.5px; display: flex; align-items: center; gap: 3px; }
.m-save { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--neutral) 30%); }
.m-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--card); overflow: hidden; font-variant-numeric: tabular-nums; font-size: 14px; }
.m-table th, .m-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.m-table th:first-child { text-align: left; }
.m-table thead th { font-size: 12px; color: var(--ink-2); background: #faf9fc; }
.m-table tr.in-per td, .m-table tr.in-per th { background: var(--accent-soft); }
.m-empty { background: #fff; border-radius: var(--card); padding: 16px; color: var(--ink-2); margin: 0; border: 1px solid var(--line); }
.m-foot { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); font-size: 13.5px; margin: 24px 0 0; padding: 14px 16px; border: 1px dashed var(--line-2); border-radius: var(--card); }
.m-foot .ic { margin-top: 2px; color: var(--accent); }
.m-skel { display: grid; gap: 10px; }
.m-skel div { height: 64px; background: #fff; border-radius: var(--card); animation: sk 1.4s infinite; }
.is-phone .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
.is-phone .state { margin-top: 32px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) {
  .cell.active::before { border-color: Highlight; }
  .cell.sel { outline: 1px solid Highlight; }
  .pill { border: 1px solid CanvasText; }
}

/* ---------- layout with task panel ---------- */
body { }
.workspace { flex: 1; min-height: 0; display: flex; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me { display: inline-flex; align-items: center; gap: 8px; padding-left: 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #9c1adb, #26c1e6); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.me-t { display: grid; line-height: 1.15; font-size: 13px; }
.me-t small { color: var(--muted); font-size: 12px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 26px; height: 18px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-2); }
.sw svg { width: 12px; height: 12px; }
.sw-input { background: #fff; }
.sw-calc { background: var(--ro-bg); }
.sw-lock { background: var(--ro-bg); color: var(--muted); }
.sw-warn { background: #fff7e6; color: #b26a00; border-color: #efc98a; }
.tb-right { margin-left: auto; }

.taskpanel { width: 340px; flex: none; border-left: 1px solid var(--line); background: var(--band); overflow: auto; display: flex; flex-direction: column; }
.tp-head { display: flex; justify-content: space-between; gap: 8px; padding: 18px 18px 10px; }
.tp-kick { margin: 0 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.taskpanel h2 { margin: 0; font-size: 19px; font-weight: 300; line-height: 1.25; }
.tp-toggle { display: none; border: 0; background: none; width: 36px; height: 36px; border-radius: 4px; align-items: center; justify-content: center; color: var(--ink-2); }
.tp-body { padding: 0 18px 18px; flex: 1; }
.tp-p { margin: 0 0 12px; color: var(--ink-2); }
.tp-progress { height: 4px; background: #e3dcec; border-radius: 2px; overflow: hidden; margin: 2px 0 14px; }
.tp-progress span { display: block; height: 100%; background: linear-gradient(90deg, #9c1adb, #26c1e6); transition: width .4s; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 12px 14px; }
.step.current { border-color: var(--accent-line); box-shadow: 0 4px 16px rgb(90 30 150 / .1); }
.step.todo { background: transparent; }
.step.todo h3 { color: var(--muted); }
.step-h { display: flex; align-items: center; gap: 10px; }
.step-h h3 { margin: 0; font-size: 14px; font-weight: 700; }
.step-n { width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 1.5px solid var(--line-2); color: var(--muted); }
.step.current .step-n { background: #222; border-color: #222; color: #fff; }
.step.done .step-n { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.step.tp-done h3 { color: var(--ink-2); font-weight: 400; text-decoration: line-through; text-decoration-color: #b8b8b8; }
.step-b { padding: 10px 0 0 34px; font-size: 13.5px; color: var(--ink-2); display: grid; gap: 10px; }
.step-b p { margin: 0; }
.step-b b { color: var(--ink); }
.how { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.tip { font-size: 12.5px; color: var(--muted); background: var(--neutral); border-radius: 6px; padding: 7px 9px; }
.prog { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.step-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.step-actions .btn .ic, .btn.sm .ic { width: 15px; height: 15px; }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.big { height: 44px; padding: 0 20px; font-size: 15px; }
.quote { overflow-x: auto; }
.quote table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; background: #fff; border: 1px solid var(--line); }
.quote caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.quote th, .quote td { padding: 4px 6px; border-right: 1px solid var(--line); text-align: right; white-space: nowrap; }
.quote th { background: var(--neutral); font-weight: 700; color: var(--ink-2); }
.blockers { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.blockers .link-btn { text-align: left; }
.tp-done { background: #fff; border: 1px solid var(--ok-line); border-radius: var(--card); padding: 16px; display: grid; gap: 8px; }
.tp-done h3 { margin: 0; font-size: 17px; font-weight: 700; }
.tp-done p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.done-ic { width: 34px; height: 34px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-ink); display: inline-flex; align-items: center; justify-content: center; }
.done-ic .ic { width: 20px; height: 20px; }
.tp-h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 18px 0 8px; }
.tp-next { margin: 0 0 14px; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.tp-proto { border-top: 1px solid var(--line); padding: 10px 18px 16px; font-size: 13px; color: var(--muted); }
.tp-proto summary { cursor: pointer; padding: 4px 0; }
.tp-proto-b { display: grid; gap: 6px; justify-items: start; padding-top: 6px; }
.taskpanel.step-pulse .step.current { animation: stepIn .6s ease-out; }
@keyframes stepIn { from { transform: translateY(6px); opacity: .4; } }

/* intro dialog */
.intro { width: min(560px, calc(100vw - 32px)); overflow: hidden; }
.intro-band { background: linear-gradient(135deg, #9c1adb, #26c1e6); color: #fff; padding: 26px 28px 22px; }
.intro-kick { margin: 0 0 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: rgb(255 255 255 / .9); }
.intro-band h2 { margin: 0; font-size: 28px; font-weight: 300; line-height: 1.15; color: #fff; }
.intro-body { padding: 20px 28px 24px; display: grid; gap: 14px; }
.intro-body p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.intro-body b { color: var(--ink); }
.intro-steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14.5px; }
.intro-legend { display: grid; gap: 8px; background: var(--neutral); border-radius: 8px; padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); }
.intro-legend > div { display: flex; align-items: center; gap: 12px; }
.demo-cell { width: 84px; height: 30px; flex: none; display: inline-flex; align-items: center; justify-content: flex-end; padding: 0 9px; font-variant-numeric: tabular-nums; border: 1px solid var(--line-2); font-size: 13px; }
.c-input { background: #fff; color: var(--ink); }
.c-empty { background: #fff; color: #8d84a0; border: 1.5px dashed #b9b0c9; font-size: 12px; }
.c-calc { background: var(--ro-bg); color: var(--ink-2); }
.intro-note { font-size: 13px !important; color: var(--muted) !important; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.dlg-md { width: min(520px, calc(100vw - 32px)); }
.sum-table { width: calc(100% - 40px); margin: 8px 20px 4px; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.sum-table th, .sum-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.sum-table th:first-child { text-align: left; }
.sum-table thead th { font-size: 12px; color: var(--muted); font-weight: 700; }
.note-field { display: grid; gap: 6px; margin: 0 20px; font-size: 13px; font-weight: 700; }
.note-field span { font-weight: 400; color: var(--muted); }
.note-field textarea { font: inherit; font-weight: 400; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; resize: vertical; }
.note-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inspector .t-warn { color: #7a4300; border-color: #efc98a; background: #fff7e6; }
.inspector.flash.warn { background: #fff4e0; color: #5c3300; }
.inspector.flash.warn .ic { color: #b26a00; }
.inspector.flash.info { background: var(--accent-soft); }

/* tablet: task panel becomes a bottom sheet */
@media (max-width: 1099px) {
  .workspace { position: relative; }
  .taskpanel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 52vh; border-left: 0; border-top: 1px solid var(--line-2); box-shadow: 0 -8px 30px rgb(30 10 60 / .14); z-index: 20; border-radius: 14px 14px 0 0; }
  .tp-toggle { display: inline-flex; }
  .tp-head { padding: 12px 16px 8px; }
  .tp-body { padding: 0 16px 14px; }
  .main-col { padding-bottom: 76px; }
  .legend { gap: 6px 10px; font-size: 12px; }
  .legend li:nth-child(4) { display: none; }
  .hide-narrow { display: none !important; }
  .me-t { display: none; }
  .toasts { bottom: 90px; }
}
/* phone */
.m-task { background: #fff; border: 1px solid var(--accent-line); border-radius: var(--card); padding: 16px; display: grid; gap: 10px; box-shadow: 0 4px 16px rgb(90 30 150 / .08); }
.m-task h2 { margin: 0; font-size: 20px; font-weight: 300; line-height: 1.25; }
.m-task p { margin: 0; color: var(--ink-2); }
.m-task .tp-progress { margin: 0; }
.m-task-top { display: grid; gap: 6px; }
.m-task.done { border-color: var(--ok-line); }
.m-wide { width: 100%; justify-content: center; min-height: 46px; }
.m-warn { color: #7a4300 !important; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.m-warn .ic { color: #b26a00; width: 14px; height: 14px; }
.m-month.is-warn { background: #fff7e6; }
.m-month.is-empty .m-in { border-style: dashed; border-color: #b9b0c9; }
.m-row.static { cursor: default; }
.m-top .avatar { width: 32px; height: 32px; }

@media (max-width: 1499px) { #btn-expand .lbl, #btn-collapse .lbl { display: none; } }
.toolbar { flex-wrap: nowrap; }
.legend { flex-wrap: nowrap; white-space: nowrap; }

/* legend made of real mini cells */
.legend { gap: 6px 18px; font-size: 12.5px; }
.legend li { gap: 7px; }
.legend b { color: var(--ink); font-weight: 700; }
.lg-cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; min-width: 54px; height: 24px; padding: 0 7px; border: 1px solid var(--line-2); border-radius: 2px; font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.lg-input { background: #fff; color: var(--ink); }
.lg-empty { background: #fff; color: #8d84a0; border: 1.5px dashed #b9b0c9; font-size: 11px; }
.lg-calc { background: var(--ro-bg); color: var(--ink-2); }
.lg-warn { background: #fff7e6; color: #7a4300; font-weight: 700; border-color: #efc98a; }
.lg-warn svg { width: 11px; height: 11px; color: #b26a00; }
.toolbar { flex-wrap: wrap; }
@media (max-width: 1499px) { .legend li span:last-child { max-width: none; } }
@media (max-width: 1099px) { .legend { font-size: 12px; gap: 6px 12px; } .legend li:nth-child(4) { display: inline-flex; } }

.fixlist, .stray { border-radius: 6px; padding: 8px 10px; font-size: 13px; display: grid; gap: 4px; }
.fixlist { background: #fff7e6; border: 1px solid #efc98a; color: #5c3300; }
.stray { background: var(--neutral); border: 1px solid var(--line); }
.fixlist ul, .stray ul { margin: 0; padding-left: 16px; display: grid; gap: 2px; }
.stray .btn { justify-self: start; margin-top: 4px; }
.toast.ok .toast-t b { color: #9be3b3; }

.step-next { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.dlg-warn { margin: 8px 20px 0; }

.step.skipped { background: transparent; }
.step.skipped h3 { color: var(--ink-2); font-weight: 400; }
.step.skipped .step-n { border-style: dashed; }
.skip-tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--review-ink); background: var(--review-bg); border: 1px solid var(--review-line); border-radius: 999px; padding: 1px 7px; }
.step-h .link-btn { font-size: 12.5px; white-space: nowrap; }

/* ================= app shell with several reports ================= */
.sidenav { width: 212px; flex: none; border-right: 1px solid var(--line); background: #fff; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-size: 14px; }
.sidenav a svg { width: 18px; height: 18px; flex: none; }
.sidenav a:hover { background: var(--neutral); color: var(--accent); }
.sidenav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-h { margin: 14px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.nav-badge:empty { display: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-report { overflow: auto; background: var(--neutral); }
.main-col { position: relative; }

/* report pages */
.rp { padding: 24px 28px 48px; max-width: 1180px; display: grid; gap: 14px; align-content: start; }
.rp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rp-kick { margin: 0 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.rp-h1 { margin: 0; font-size: 28px; font-weight: 300; letter-spacing: -.01em; outline: none; }
.rp-sub { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.rp-h2 { margin: 12px 0 0; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.rp-note { display: flex; gap: 8px; align-items: flex-start; color: var(--ink-2); font-size: 13px; margin: 0; }
.rp-hint { font-size: 12.5px; color: var(--muted); }
.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--card); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl thead th { font-size: 12px; color: var(--ink-2); background: #faf9fc; font-weight: 700; }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl .n { text-align: right; }
.tbl .acts { text-align: right; }
.tbl tr.is-new > * { background: #faf5fe; }
.tbl tr.hl-row > * { background: #fffaf0; }
.new-tag { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 7px; vertical-align: 1px; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); min-height: 36px; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.price-list { display: grid; gap: 10px; }
.pl { background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 14px 16px; display: grid; gap: 12px; }
.pl.is-new { border-color: var(--accent-line); }
.pl-head { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.pl-head > div:first-child { flex: 1; min-width: 220px; }
.pl h3 { margin: 0; font-size: 15px; }
.pl p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.pl-meta { display: grid; text-align: right; font-size: 13px; color: var(--ink-2); }
.pl-meta b { color: var(--ink); }
.pl-tbl th[scope=row] { background: #faf9fc; }
.pl-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.act-tbl .sticky-c { position: sticky; left: 0; background: #fff; z-index: 1; border-right: 1px solid var(--line); }
.act-tbl thead .sticky-c { background: #faf9fc; }
.act-tbl tr.hl-row .sticky-c { background: #fffaf0; }
.act-tbl th.fc, .act-tbl td.fc { color: var(--muted); }
.fc-tag { display: block; font-size: 10px; font-weight: 400; color: var(--muted); }
.f-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.f select, .f input, .f textarea, .f-inline select { font: inherit; height: 38px; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0 10px; background: #fff; }
.f textarea { height: auto; padding: 8px 10px; resize: vertical; }
.f select:focus, .f input:focus, .f textarea:focus, .f-inline select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f input[aria-invalid="true"] { border-color: var(--bad-ink); }

/* request form */
.req-form { background: #fff; border: 1px solid var(--accent-line); border-radius: var(--card); padding: 18px; display: grid; gap: 14px; box-shadow: 0 6px 20px rgb(90 30 150 / .08); }
.rf-head { display: flex; align-items: center; gap: 10px; }
.rf-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.unsaved-tag { font-size: 11.5px; font-weight: 700; color: var(--review-ink); background: var(--review-bg); border: 1px solid var(--review-line); border-radius: 999px; padding: 1px 8px; }
.rf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.f { display: grid; gap: 5px; font-size: 13px; font-weight: 700; color: var(--ink); }
.f .opt { font-weight: 400; color: var(--muted); }
.f-wide { grid-column: 1 / -1; }
.f-err { color: var(--bad-ink); font-weight: 400; display: flex; gap: 5px; align-items: flex-start; }
.rf-preview { margin: 0; display: flex; gap: 8px; align-items: flex-start; background: var(--accent-soft); border-radius: 6px; padding: 10px 12px; font-size: 13.5px; }
.rf-preview .ic { color: var(--accent); margin-top: 2px; }
.rf-actions { display: flex; gap: 8px; }

/* inbox */
.inbox-card { background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 18px 20px; display: grid; gap: 14px; max-width: 760px; }
.inbox-card.is-done { border-color: var(--ok-line); }
.ib-top { display: flex; gap: 12px; align-items: flex-start; }
.ib-top h2 { margin: 2px 0 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
.ib-top > div { flex: 1; }
.ib-from { margin: 0; font-size: 13px; color: var(--ink-2); }
.av-mara { background: linear-gradient(135deg, #26c1e6, #7a1fc2); }
.ib-due { font-size: 12px; font-weight: 700; color: var(--review-ink); background: var(--review-bg); border: 1px solid var(--review-line); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.ib-due.ok { color: var(--ok-ink); background: var(--ok-bg); border-color: var(--ok-line); }
.ib-msg { margin: 0; color: var(--ink-2); background: var(--neutral); border-radius: 8px; padding: 12px 14px; line-height: 1.5; }
.ib-steps, .ib-old { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ib-steps li, .ib-old li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ib-steps li.cur { font-weight: 700; }
.ib-steps li.ok > span:nth-child(2) { color: var(--ink-2); }
.ib-n { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.ib-steps li.ok .ib-n, .ib-n.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.ib-steps li.cur .ib-n { background: #222; border-color: #222; color: #fff; }
.ib-where { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.ib-actions { display: flex; align-items: center; gap: 14px; }
.ib-prog { font-size: 13px; color: var(--muted); }
.ib-old { max-width: 760px; color: var(--ink-2); }

/* task panel additions */
.where { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 12px; color: var(--muted); }
.where span { border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; background: #fff; }
.where span.is-here { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.note-card { background: #fffbea; border: 1px solid #f2e6b4; border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.note-card p { margin: 0; }
.nc-from { display: flex; align-items: center; gap: 5px; margin-bottom: 3px !important; color: var(--ink-2); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ck { display: flex; gap: 10px; align-items: flex-start; }
.ck p { margin: 0; color: var(--ink); font-size: 13.5px; }
.ck ul { margin: 3px 0 0; padding-left: 16px; display: grid; gap: 2px; font-size: 12.5px; }
.ck .link-btn { font-size: 12.5px; text-align: left; }
.ck-ic { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ck-ic .ic { width: 14px; height: 14px; }
.ck-ok .ck-ic { background: var(--ok-bg); color: var(--ok-ink); }
.ck-ok p { color: var(--ink-2); }
.ck-warn .ck-ic { background: #fff4e0; color: #b26a00; }
.ck-block .ck-ic { background: var(--bad-bg); color: var(--bad-ink); }
.ck-block .ck-ic .ic circle { fill: currentColor; }
.ck-sum { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); }
.dlg-check { margin: 8px 20px 0; padding: 12px 14px; background: var(--neutral); border-radius: 8px; display: grid; gap: 8px; }
.step-actions .btn .ic { width: 15px; height: 15px; }
.inspector .t-link { color: #0b6e8a; border-color: #9fd0dd; }
.formula.linked { display: inline-flex; align-items: center; gap: 3px; color: #0b6e8a; }
.formula.linked .ic { width: 13px; height: 13px; }
.cell.k-linked { background: #eef7fa; color: #0b6e8a; font-style: normal; }
.intro-steps li span { color: var(--muted); font-size: 12.5px; margin-left: 6px; }

/* tablet: narrow nav with icons only */
@media (max-width: 1099px) {
  .sidenav { width: 64px; padding: 10px 8px; }
  .sidenav a { justify-content: center; padding: 10px 0; position: relative; }
  .sidenav a span:not(.nav-badge), .nav-h { display: none; }
  .nav-badge { position: absolute; top: 2px; right: 4px; height: 16px; min-width: 16px; font-size: 10px; }
  .rp { padding: 18px 16px 120px; }
  .rf-grid { grid-template-columns: 1fr 1fr; }
}
/* phone: bottom navigation, every view phone-sized */
@media (max-width: 699px) {
  body.is-phone { height: 100dvh; overflow: hidden; display: flex; }
  body.is-phone .workspace { display: flex !important; flex-direction: column; }
  body.is-phone .topbar { display: flex !important; padding: 8px 16px; }
  body.is-phone .topbar .brand-co, body.is-phone .topbar .savestate, body.is-phone #btn-keys { display: none; }
  body.is-phone .main-col { order: 1; flex: 1; min-height: 0; padding-bottom: 0; }
  body.is-phone .sidenav { order: 3; width: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  body.is-phone .sidenav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 2px; flex: 1; min-height: 52px; }
  body.is-phone .sidenav a span:not(.nav-badge) { display: block; text-align: center; line-height: 1.1; }
  body.is-phone .nav-h { display: none; }
  body.is-phone .taskpanel { position: static; order: 2; max-height: 46vh; border-radius: 14px 14px 0 0; }
  body.is-phone .view-budget { overflow: auto; background: var(--neutral); }
  body.is-phone .view-budget > :not(#mobile) { display: none !important; }
  body.is-phone .view-budget #mobile { display: block; }
  body.is-phone .toasts { bottom: 150px; }
  .rp { padding: 16px 16px 24px; }
  .rp-h1 { font-size: 24px; }
  .rf-grid { grid-template-columns: 1fr; }
  .tbl th, .tbl td { padding: 8px 10px; }
  .ib-steps li { flex-wrap: wrap; }
  .ib-where { margin-left: 34px; width: 100%; }
  .inbox-card { padding: 14px; }
  .mobile { padding-bottom: 24px; }
}

/* reports in this task */
.trep { background: #fff; border: 1px solid var(--line); border-radius: var(--card); padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.trep summary { cursor: pointer; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; list-style-position: inside; padding: 2px 0; }
.trep summary span { font-weight: 400; color: var(--muted); }
.trep ul, .ib-reports ul { list-style: none; margin: 6px 0 2px; padding: 0; display: grid; gap: 6px; }
.trep li, .ib-reports li { display: flex; align-items: flex-start; gap: 8px; }
.trep li > div, .ib-reports li > div { flex: 1; display: grid; gap: 1px; min-width: 0; }
.trep small, .ib-reports small { color: var(--muted); font-size: 12px; }
.trep .link-btn, .ib-reports a { font-weight: 700; text-align: left; color: var(--accent); }
.tr-dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; margin-top: 2px; display: inline-flex; align-items: center; justify-content: center; }
.tr-dot .ic { width: 11px; height: 11px; }
.tr-opened .tr-dot { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 3px, transparent 3.5px); }
.tr-done .tr-dot { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.tr-st { font-size: 11.5px; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.tr-done .tr-st { color: var(--ok-ink); }
.tr-here { font-size: 11px; color: var(--accent); margin-left: 6px; }
.trep li.is-here { background: var(--accent-soft); border-radius: 6px; margin: 0 -6px; padding: 3px 6px; }
.ib-reports { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.ib-reports h3, .ib-h3 { margin: 0; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }

/* legend must never run under the task panel */
.main-col { overflow: hidden; }
.toolbar { flex-wrap: wrap !important; }
.legend { flex-wrap: wrap !important; white-space: normal !important; }
@media (max-width: 1699px) { .legend .lg-more { display: none; } }
