/* Components — docs/UI.md. Dense, hairline-bordered, tool-style. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs)/1.45 var(--font-sans);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
/* Dense tables and rails: ink links that turn red on hover (red stays for actions & state). */
.data-table a, .mini-table a, .rail-line a, .kv a, .file-name { color: var(--text); }
.data-table a:hover, .mini-table a:hover, .rail-line a:hover, .kv a:hover, .file-name:hover { color: var(--accent-ink); }
::selection { background: #ffd8ca; color: var(--brand-charcoal); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.005em; }
p { margin: 0 0 8px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .95em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.stack > * + * { margin-top: 10px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-text); padding: 6px 10px; z-index: 100; }
.skip-link:focus { left: 8px; }

.icon { width: 16px; height: 16px; flex: none; stroke-width: 1.75; }
.icon-xs { width: 12px; height: 12px; }

kbd {
  display: inline-block; min-width: 18px; padding: 0 4px; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--text-2); font-size: 10.5px; line-height: 16px; text-align: center;
}

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.is-collapsed { grid-template-columns: 52px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid #000;
  overflow-y: auto; overflow-x: hidden;
}
.brand { display: flex; align-items: center; gap: 8px; height: var(--topbar-h); padding: 0 12px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { display: inline-block; width: 13px; height: 22px; flex: none; color: var(--brand-red); }
.brand-name {
  color: #ffffff; white-space: nowrap; text-transform: uppercase;
  font: 800 19px/1 var(--font-sans); font-stretch: 75%; letter-spacing: .01em;
}
.brand-sub { color: var(--brand-red); font-weight: 700; font-stretch: 75%; margin-left: 2px; }
.nav { padding: 6px 6px 12px; flex: 1; }
.nav-group { margin: 12px 8px 4px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-item {
  display: flex; align-items: center; gap: 9px; height: 28px; padding: 0 8px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); white-space: nowrap; text-decoration: none; position: relative;
}
a.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.is-active .icon { color: var(--brand-red); }
.nav-item.is-planned { color: var(--sidebar-muted); cursor: default; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-kbd { opacity: 0; background: transparent; border-color: rgba(255,255,255,.14); color: var(--sidebar-muted); transition: opacity .1s; }
.nav-item:hover .nav-kbd { opacity: 1; }
.nav-phase { font: 500 10px/1 var(--font-mono); color: var(--sidebar-muted); border: 1px solid rgba(255,255,255,.1); border-radius: 2px; padding: 2px 3px; }
.sidebar-foot { padding: 6px; border-top: 1px solid rgba(255,255,255,.06); }
.shell.is-collapsed .nav-label, .shell.is-collapsed .nav-group, .shell.is-collapsed .brand-name,
.shell.is-collapsed .nav-kbd, .shell.is-collapsed .nav-phase { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  height: var(--topbar-h); padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: min(420px, 50vw); height: 30px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  color: var(--muted); font: inherit; cursor: text; text-align: left;
}
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--border-strong); }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent;
  border-radius: var(--radius); background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border); }
:root:not([data-theme="dark"]) .show-dark, :root[data-theme="dark"] .show-light { display: none; }
.env-pill { font: 600 10.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; padding: 4px 6px; border-radius: var(--radius-sm); border: 1px solid; }
.env-preview { color: var(--info); border-color: var(--info); background: var(--info-soft); }
.env-local { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.env-development { color: var(--neutral); border-color: var(--border-strong); background: var(--neutral-soft); }

.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border-radius: var(--radius); cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-3); }
.avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-charcoal); color: var(--brand-red); font-weight: 700; font-size: 11px; }
.usermenu-name { color: var(--text-2); }
.menu {
  position: absolute; right: 0; top: 36px; min-width: 220px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 30;
}
.menu-meta { padding: 6px 8px; color: var(--muted); font-size: var(--fs-sm); border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.menu a, .menu button {
  display: flex; width: 100%; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border: 0;
  border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); }

.main { padding: 14px 18px 40px; min-width: 0; }
.main:focus { outline: none; }

/* ---------------------------------------------------------------- page structure */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.page-header h1 { font-size: var(--fs-xl); }
.page-subtitle { margin: 2px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 6px; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 2px; }
.crumbs a { color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; text-decoration: none;
}
.tab:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.tab-count { font: 500 var(--fs-xs)/1 var(--font-mono); padding: 2px 5px; border-radius: 8px; background: var(--surface-3); color: var(--muted); }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 0 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.fact { padding: 7px 12px; border-right: 1px solid var(--divider); }
.fact:last-child { border-right: 0; }
.fact dt { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.fact dd { margin: 2px 0 0; font: 500 var(--fs-lg)/1.25 var(--font-mono); font-variant-numeric: tabular-nums; }
.fact-bad dd { color: var(--bad); } .fact-warn dd { color: var(--warn); } .fact-ok dd { color: var(--ok); }

.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.align-start { align-items: start; }

.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card { padding: 12px 14px; }
.card.narrow { max-width: 640px; }
.card-title { font-size: var(--fs-lg); margin-bottom: 8px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 12px; border-bottom: 1px solid var(--divider); background: var(--surface-2); }
.panel-header h2 { font-size: var(--fs); font-weight: 600; }
.panel-body { padding: 8px 12px; }
.link-action { font-size: var(--fs-sm); font-weight: 500; }
.dash-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }

.empty { margin: 4px 0; color: var(--muted); }

.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { padding: 4px 0; border-bottom: 1px solid var(--divider); vertical-align: top; text-align: left; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.kv th { width: 42%; color: var(--muted); font-weight: 500; padding-right: 10px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th {
  position: sticky; top: 0; height: var(--row-h); padding: 0 10px; background: var(--surface-2); text-align: left;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { height: var(--row-h); padding: 0 10px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tr.is-empty td { color: var(--muted); height: 44px; }
.data-table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- badges & callouts */
.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--radius-sm);
  font: 600 10.5px/1 var(--font-sans); text-transform: uppercase; letter-spacing: .04em; border: 1px solid transparent;
}
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-muted { color: var(--neutral); background: var(--neutral-soft); }
.callout { padding: 8px 10px; border-radius: var(--radius); border: 1px solid; border-left-width: 3px; margin: 8px 0; }
.callout-info { color: var(--text); background: var(--info-soft); border-color: var(--info); }
.callout-warn { color: var(--text); background: var(--warn-soft); border-color: var(--warn); }
.callout-bad { color: var(--text); background: var(--bad-soft); border-color: var(--bad); }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; gap: 14px; }
.form-section { margin: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.form-section legend { float: left; width: 100%; padding: 0; margin-bottom: 2px; font-weight: 600; font-size: var(--fs-lg); }
.form-section-note { clear: both; color: var(--muted); margin-bottom: 10px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field + .field { margin-top: 8px; }
.grid > .field + .field { margin-top: 0; }
.field-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.field-control { display: flex; align-items: stretch; }
.input {
  width: 100%; min-height: var(--field-h); padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { resize: vertical; line-height: 1.4; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
.has-affix .input { border-radius: 0; }
.has-affix .input:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.has-affix .input:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.affix { display: inline-flex; align-items: center; padding: 0 8px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.affix:first-child { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.affix:last-child { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.field-hint { font-size: var(--fs-xs); color: var(--muted); }
.field-error { font-size: var(--fs-xs); color: var(--bad); font-weight: 500; }
.has-error .input { border-color: var(--bad); }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check-input { margin-top: 2px; accent-color: var(--accent); }
.input-code { font: 500 20px/1 var(--font-mono); letter-spacing: .28em; text-align: center; height: 44px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--field-h); padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: 500 var(--fs)/1 var(--font-sans); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 650; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; height: 36px; }

/* ---------------------------------------------------------------- auth screens */
body.auth { display: grid; place-items: center; min-height: 100vh; background: var(--sidebar); }
.auth-shell { width: 100%; max-width: 420px; padding: 24px 16px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px 18px; box-shadow: var(--shadow-pop); }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--divider); }
.auth-brand .brand-name { color: var(--text); }
.auth-brand .env-pill { margin-left: auto; }
.auth-title { font-size: var(--fs-xl); margin-bottom: 4px; }
.auth-lede { color: var(--muted); margin-bottom: 10px; }
.auth-note { margin: 12px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.auth-help { margin-top: 12px; color: var(--muted); font-size: var(--fs-sm); }
.auth-help summary { cursor: pointer; color: var(--text-2); }
.auth-foot { margin-top: 12px; text-align: center; color: var(--sidebar-muted); font-size: var(--fs-xs); }
.auth-shell:has(.steps) { max-width: 520px; }

.steps { margin: 8px 0 0; padding-left: 18px; }
.steps > li { margin-bottom: 14px; padding-left: 4px; }
.steps > li::marker { font-weight: 600; color: var(--muted); }
.qr-wrap { margin-top: 8px; display: inline-block; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.qr { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.secret { margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); font-size: 14px; letter-spacing: .06em; user-select: all; word-break: break-all; }
.recovery-codes { columns: 2; gap: 24px; margin: 10px 0 12px; padding: 10px 14px 10px 34px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.recovery-codes li { padding: 2px 0; letter-spacing: .05em; }

/* ---------------------------------------------------------------- overlays */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(10, 12, 16, .45); }
.palette {
  width: min(620px, 92vw); margin-top: 12vh; padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-pop);
}
.palette-input { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--divider); color: var(--muted); }
.palette-input input { flex: 1; height: 44px; border: 0; background: transparent; color: var(--text); font: 400 15px var(--font-sans); outline: none; }
.palette-list { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow-y: auto; }
.palette-list li { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-list li .hint { margin-left: auto; color: var(--faint); font-size: var(--fs-xs); }
.palette-list li.is-selected { background: var(--accent-soft); color: var(--text); }
.palette-list li.is-disabled { color: var(--faint); cursor: default; }
.palette-foot { display: flex; gap: 6px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--divider); color: var(--muted); font-size: var(--fs-xs); }
.shortcuts { width: min(520px, 92vw); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop); }
.shortcuts header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--divider); }
.shortcuts header h2 { font-size: var(--fs-lg); }
.shortcuts .kv { margin: 6px 12px 12px; width: calc(100% - 24px); }
.shortcuts .kv th { width: 50%; }

.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 50; display: flex; flex-direction: column; gap: 6px; max-width: min(440px, 92vw); }
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--info); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.toast span { flex: 1; }
.toast-success { border-left-color: var(--ok); } .toast-success .icon { color: var(--ok); }
.toast-error { border-left-color: var(--bad); } .toast-error .icon { color: var(--bad); }
.toast-warning { border-left-color: var(--warn); } .toast-warning .icon { color: var(--warn); }
.toast-info .icon { color: var(--info); }
.toast-close { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }

/* ---------------------------------------------------------------- lists: toolbar, chips, sorting, row nav (Phase 2) */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.toolbar-spacer { flex: 1; }
.toolbar-search { position: relative; display: flex; align-items: center; width: 280px; max-width: 100%; }
.toolbar-search .icon { position: absolute; left: 8px; color: var(--muted); pointer-events: none; }
.toolbar-search .input { width: 100%; padding-left: 28px; }
.toolbar-hint { color: var(--faint); font-size: var(--fs-xs); }
.chips { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: var(--field-h); padding: 0 10px; color: var(--text-2);
  background: var(--surface); border-right: 1px solid var(--border); font-weight: 500; text-decoration: none;
}
.chip:last-child { border-right: 0; }
.chip:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.chip.is-active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.chip-count { font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--muted); }
.btn-sm { height: 24px; padding: 0 8px; font-size: var(--fs-sm); }
.btn kbd { margin-left: 2px; opacity: .75; }
.sort-link { display: inline-flex; align-items: center; gap: 3px; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--text); text-decoration: none; }
.sort-link.is-sorted { color: var(--text); }
.sort-arrow { font-size: 8px; min-width: 8px; }
th.num .sort-link { justify-content: flex-end; }
.data-table.is-navigable tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.data-table tbody tr.is-dim td { color: var(--muted); }
.data-table td.cell-primary { font-weight: 500; }
.data-table td.cell-primary a { color: var(--text); }
.cell-sub { margin-left: 8px; color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }
.cell-mono, .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.cell-badges .badge + .badge { margin-left: 4px; }
.rate-custom { color: var(--warn); font-weight: 600; }
.rate-custom::after { content: " ●"; font-size: 8px; vertical-align: middle; }

/* ---------------------------------------------------------------- detail pages */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--gap); align-items: start; }
.detail-main, .detail-rail { display: grid; gap: var(--gap); }
.panel-note { margin: 8px 0 2px; color: var(--muted); font-size: var(--fs-xs); }
.prose { white-space: pre-line; line-height: 1.5; }
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li { padding: 5px 0; border-bottom: 1px solid var(--divider); }
.rail-list li:last-child { border-bottom: 0; }
.rail-line { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.rail-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 1px; }
.tab.is-planned { color: var(--faint); cursor: default; }
.tab.is-planned:hover { background: none; color: var(--faint); }
.tab-phase { font: 500 9.5px/1 var(--font-mono); border: 1px solid var(--border); border-radius: 3px; padding: 2px 3px; color: var(--faint); }
.kv-compact th, .kv-compact td { padding: 3px 0; }
.span-2 { grid-column: span 2; }
.callout-actions { margin-top: 6px; }
.plain-list { margin: 0; padding-left: 18px; line-height: 1.5; }
.plain-list li + li { margin-top: 6px; }

/* ---------------------------------------------------------------- client import */
.stepper { display: flex; list-style: none; margin: 0 0 10px; padding: 0; counter-reset: step; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stepper li { flex: 1; padding: 6px 12px; color: var(--muted); font-weight: 500; border-right: 1px solid var(--divider); counter-increment: step; }
.stepper li:last-child { border-right: 0; }
.stepper li::before { content: counter(step); display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 6px; border-radius: 50%; border: 1px solid currentColor; font: 600 10px/1 var(--font-mono); }
.stepper li.is-current { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.stepper li.is-done { color: var(--ok); }
.input-file { height: auto; padding: 5px; }
.input-sm { height: 24px; font-size: var(--fs-sm); }
details.mapping { padding: 0; }
details.mapping > summary { padding: 9px 14px; cursor: pointer; list-style: none; }
details.mapping > summary::-webkit-details-marker { display: none; }
details.mapping > summary .legend { font-weight: 600; }
details.mapping[open] > summary { border-bottom: 1px solid var(--divider); }
details.mapping .table-wrap { border: 0; border-radius: 0; }
details.mapping .form-actions { padding: 0 14px 12px; }
.import-grid td { vertical-align: middle; }
.import-grid td.cell-check, .import-grid th.cell-check { width: 56px; text-align: center; }
.import-grid td.cell-checks { white-space: normal; min-width: 260px; padding-top: 3px; padding-bottom: 3px; font-size: var(--fs-sm); }
.import-grid tr.is-error { background: var(--bad-soft); }
.import-grid tr.is-warn { background: var(--warn-soft); }
.import-grid tr.is-skipped td:not(.cell-check):not(.cell-checks) { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.import-grid .rate-input { justify-content: flex-end; }
.import-grid .rate-input .input { width: 84px; text-align: right; font-family: var(--font-mono); }
.import-grid .rate-input .affix { height: 24px; }
.input.is-custom { border-color: var(--warn); color: var(--warn); font-weight: 600; }
.check-line { display: flex; align-items: baseline; gap: 4px; line-height: 1.35; }
.check-line.is-bad { color: var(--bad); font-weight: 500; }
.check-line.is-warn { color: var(--warn); }
.sticky-actions { position: sticky; bottom: 0; padding: 8px 0; background: var(--bg); border-top: 1px solid var(--border); z-index: 2; }

/* ---------------------------------------------------------------- dashboard (Phase 2) */
.rate-buckets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rate-bucket { font: 500 var(--fs-sm)/1 var(--font-mono); padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------------------------------------------------------------- deals (Phase 3) */
.board { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.board-col-head { padding: 7px 9px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.board-won .board-col-head { box-shadow: inset 0 2px 0 var(--ok); }
.board-lost .board-col-head { box-shadow: inset 0 2px 0 var(--neutral); }
.board-col-title { display: flex; justify-content: space-between; font-weight: 600; }
.board-prob { font: 500 var(--fs-xs)/1.6 var(--font-mono); color: var(--muted); }
.board-col-meta { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
.board-cards { display: flex; flex-direction: column; gap: 6px; padding: 6px; flex: 1; min-height: 120px; }
.board-cards.is-drop-target { background: var(--accent-soft); outline: 1px dashed var(--accent); outline-offset: -3px; }
.board-empty { margin: 8px 2px; color: var(--faint); font-size: var(--fs-sm); text-align: center; }
.deal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 8px; cursor: grab; }
.deal-card:hover { border-color: var(--border-strong); }
.deal-card.is-dragging { opacity: .45; }
.deal-card.is-saving { opacity: .6; pointer-events: none; }
.deal-card.is-overdue { box-shadow: inset 2px 0 0 var(--bad); }
.deal-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.deal-title { font-weight: 600; color: var(--text); line-height: 1.3; }
.deal-amount { font-family: var(--font-mono); font-size: var(--fs-sm); white-space: nowrap; }
.deal-card-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
.deal-card-sub a { color: var(--text-2); }
.deal-card-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: var(--fs-xs); margin-top: 4px; }
.is-bad { color: var(--bad); font-weight: 600; }
.tag { font: 500 10px/1 var(--font-mono); padding: 2px 4px; border: 1px solid var(--border); border-radius: 3px; color: var(--muted); text-transform: uppercase; }
.deal-move { margin-top: 4px; font-size: var(--fs-xs); }
.deal-move summary { cursor: pointer; color: var(--muted); list-style: none; display: inline; }
.deal-move summary::-webkit-details-marker { display: none; }
.deal-move[open] summary { color: var(--text); }
.deal-move-form { display: grid; gap: 4px; margin-top: 4px; }
.stage-track { display: flex; list-style: none; padding: 0; margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stage-track li { flex: 1; padding: 5px 10px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); border-right: 1px solid var(--divider); }
.stage-track li:last-child { border-right: 0; }
.stage-track li.is-done { color: var(--text-2); background: var(--surface-2); }
.stage-track li.is-current { color: var(--accent-text); background: var(--accent); }
.stage-track li.stage-lost.is-current { background: var(--neutral); color: #fff; }
.inline-form { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.inline-form .field + .field { margin-top: 0; }
.rail-right { margin-left: auto; }
.mini-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: var(--fs-sm); }
.mini-table th, .mini-table td { padding: 2px 0; border-bottom: 1px solid var(--divider); }
.mini-table th { text-align: left; color: var(--muted); font-weight: 500; }
.panel-subhead { margin: 10px 0 2px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.modal { width: min(440px, 92vw); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
.modal::backdrop { background: rgba(10, 14, 20, .45); }
.modal-body { padding: 14px; }
.modal-body h2 { font-size: var(--fs-lg); margin-bottom: 4px; }

/* ---------------------------------------------------------------- problems & retainers (Phase 4) */
.js .js-hide { display: none; }
.cell-wrap { white-space: normal; min-width: 220px; }
.inline-status { display: flex; gap: 4px; align-items: center; }
.status-select { width: 140px; font-weight: 500; }
.status-select.status-open { color: var(--info); }
.status-select.status-in_progress { color: var(--accent-ink); }
.status-select.status-waiting_client { color: var(--warn); }
.status-select.status-resolved { color: var(--ok); }
.status-select.status-closed { color: var(--muted); }
.status-select.status-waiting { color: var(--warn); }
.status-select.status-solved { color: var(--ok); }
/* P-001012-OPEN: number + status at a glance */
.problem-tag { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.problem-tag.tag-open { color: var(--info); }
.problem-tag.tag-waiting { color: var(--warn); }
.problem-tag.tag-solved { color: var(--ok); }
.problem-tag-lg { padding: 3px 8px; border: 1px solid currentColor; border-radius: var(--radius); }
.problem-summary { margin: 0 0 8px; }
.problem-sort-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.prose-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.data-table tr.prio-urgent td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.data-table tr.prio-high td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.badge-urgent-row { color: var(--bad); }
.status-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.section-title { font-size: var(--fs); font-weight: 600; margin: 14px 0 6px; }
.section-title .muted { font-weight: 500; margin-left: 4px; }
.burn { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.burn-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.burn-fill { height: 100%; background: var(--ok); }
.burn-warn .burn-fill { background: var(--warn); }
.burn-bad .burn-fill { background: var(--bad); }
.burn-muted .burn-fill { background: var(--neutral); }
.burn-label { font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--text-2); white-space: nowrap; }
.burn-strip { margin: -4px 0 12px; }
.burn-strip .burn-track { height: 8px; }
.prio-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; }
.prio-cell { display: flex; flex-direction: column; padding: 5px 8px; border-right: 1px solid var(--divider); color: var(--text); text-decoration: none; }
.prio-cell:last-child { border-right: 0; }
.prio-cell:hover { background: var(--surface-2); text-decoration: none; }
.prio-n { font: 600 var(--fs-lg)/1.2 var(--font-mono); }
.prio-l { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.prio-urgent .prio-n { color: var(--bad); }
.prio-high .prio-n { color: var(--warn); }
.burn-w-0 { width: 0%; }
.burn-w-5 { width: 5%; }
.burn-w-10 { width: 10%; }
.burn-w-15 { width: 15%; }
.burn-w-20 { width: 20%; }
.burn-w-25 { width: 25%; }
.burn-w-30 { width: 30%; }
.burn-w-35 { width: 35%; }
.burn-w-40 { width: 40%; }
.burn-w-45 { width: 45%; }
.burn-w-50 { width: 50%; }
.burn-w-55 { width: 55%; }
.burn-w-60 { width: 60%; }
.burn-w-65 { width: 65%; }
.burn-w-70 { width: 70%; }
.burn-w-75 { width: 75%; }
.burn-w-80 { width: 80%; }
.burn-w-85 { width: 85%; }
.burn-w-90 { width: 90%; }
.burn-w-95 { width: 95%; }
.burn-w-100 { width: 100%; }

/* ---------------------------------------------------------------- prospecting (Phase 5) */
.nav-badge { min-width: 18px; height: 16px; padding: 0 5px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font: 600 10px/16px var(--font-mono); text-align: center; }
.shell.is-collapsed .nav-badge { position: absolute; margin-left: 18px; margin-top: -12px; min-width: 14px; height: 14px; line-height: 14px; padding: 0 3px; }
.split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.split-list { max-height: calc(100vh - 210px); overflow-y: auto; }
.split-pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 320px; }
.split-pane.standalone { max-width: 980px; }
.lead-list td { height: auto; padding: 0; white-space: normal; }
.lead-row-link { display: block; padding: 7px 10px; color: var(--text); text-decoration: none; }
.lead-row-link:hover { text-decoration: none; }
.lead-row-top { display: flex; justify-content: space-between; gap: 8px; }
.lead-row-name { font-weight: 500; }
.lead-list tr.is-unread .lead-row-name { font-weight: 700; }
.lead-list tr.is-unread .lead-row-link { box-shadow: inset 3px 0 0 var(--accent); }
.lead-row-date { font: 500 var(--fs-xs)/1.6 var(--font-mono); color: var(--muted); white-space: nowrap; }
.lead-row-sub { display: block; font-size: var(--fs-sm); color: var(--text-2); }
.lead-row-msg { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: 1px; }
.lead-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.lead-name { font-size: var(--fs-xl); }
.lead-head-actions { display: flex; gap: 6px; align-items: center; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.disqualify-form { display: flex; gap: 6px; margin-bottom: 12px; }
.disqualify-form .input { flex: 1; }
.lead-message { margin: 12px 0; }
.lead-message h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.lead-message .prose { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--radius); font-size: 14px; }
.code-block { margin: 4px 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font: 500 var(--fs-sm)/1.4 var(--font-mono); white-space: pre-wrap; word-break: break-all; }
.table-wrap.flush { border: 0; border-radius: 0; margin: -8px -12px 0; }

/* ---------------------------------------------------------------- timeline (Phase 6) */
.nav-badge-overdue_invoices { background: var(--bad); color: #fff; }
.tag-bad { color: var(--bad); border-color: var(--bad); }
.input-date { width: 140px; }
.input-time { width: 110px; }
.input-prio { width: 96px; }
.mini-chips { display: flex; gap: 2px; }
.mini-chips a { padding: 2px 7px; border-radius: var(--radius-sm); font-size: var(--fs-xs); color: var(--muted); text-decoration: none; }
.mini-chips a:hover { background: var(--surface-3); color: var(--text); }
.mini-chips a.is-active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.note-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: end; margin-bottom: 10px; }
.note-add textarea { min-height: 52px; resize: vertical; height: auto; padding-top: 6px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 1px solid var(--border); }
.tl-item { position: relative; padding: 4px 0 8px 10px; }
.tl-dot { position: absolute; left: -19px; top: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--neutral); }
.tl-note .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-item.is-pinned .tl-dot { border-color: var(--warn); background: var(--warn); }
.tl-deal_stage_changed .tl-dot, .tl-problem_status_changed .tl-dot { border-color: var(--info); }
.tl-lead_converted .tl-dot { border-color: var(--ok); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: var(--fs-sm); }
.tl-actor { font-weight: 600; }
.tl-kind { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tl-source { font-size: var(--fs-xs); }
.tl-time { margin-left: auto; font: 500 var(--fs-xs)/1.4 var(--font-mono); color: var(--muted); }
.tl-pin { display: inline; }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.link-btn:hover { color: var(--accent-ink); text-decoration: underline; }
.tl-text { color: var(--text-2); margin-top: 1px; }
.tl-note { margin-top: 3px; padding: 6px 9px; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--radius); line-height: 1.5; }
.tl-note p, .pinned-note p { margin: 0 0 4px; } .tl-note p:last-child, .pinned-note p:last-child { margin-bottom: 0; }
.tl-note ul, .pinned-note ul { margin: 0 0 4px; padding-left: 18px; }
.tl-note code, .pinned-note code { font: 500 var(--fs-sm)/1 var(--font-mono); padding: 1px 3px; background: var(--surface-3); border-radius: 3px; }
.pinned-notes { display: grid; gap: 6px; margin: 0 0 10px; }
.pinned-note { padding: 7px 10px; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius); line-height: 1.5; }
.pinned-label { float: right; font-size: var(--fs-xs); font-weight: 600; color: var(--warn); text-transform: uppercase; letter-spacing: .04em; margin-left: 8px; }
.lead-activity { display: grid; gap: var(--gap); margin: 12px 0; }

/* ---------------------------------------------------------------- billing (Phase 7) */
.time-add { padding: 8px 10px; margin-bottom: 10px; }
.time-add-grid { display: grid; grid-template-columns: minmax(200px, 1.3fr) minmax(170px, 1fr) 140px 100px minmax(200px, 2fr) 120px auto; gap: 8px; align-items: end; }
.time-add-actions { flex-direction: row; align-items: center; gap: 10px; }
.time-grid .day-head th, .time-grid .day-head td { background: var(--surface-2); font-weight: 600; height: 26px; }
.time-grid .day-group.is-today .day-head th { color: var(--accent-ink); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: 8px; }
.material-add { padding: 8px 10px; margin-bottom: 10px; }
.material-add-row { display: grid; grid-template-columns: 1fr 1fr 90px 130px 100px minmax(170px, 1fr) auto; gap: 8px; align-items: end; margin-top: 8px; }
.price-preview-value { height: var(--field-h); display: flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: var(--fs-sm); }
.bill-summary { margin-top: 12px; display: grid; gap: 10px; }
.kv.totals { max-width: 380px; margin-left: auto; }
.kv.totals th { width: auto; }
.kv.totals td { text-align: right; font-family: var(--font-mono); }
.kv.totals tr.grand th, .kv.totals tr.grand td, .doc-lines tfoot tr.grand td { font-weight: 700; font-size: var(--fs-lg); border-top: 1px solid var(--border-strong); }
.doc-lines tfoot td { background: var(--surface); font-weight: 500; }
.line-add { padding: 8px 10px; margin-top: 10px; }
.line-add-row { display: grid; grid-template-columns: 120px minmax(220px, 3fr) 80px 120px 120px 100px auto; gap: 8px; align-items: end; }
.line-add-row .field + .field { margin-top: 0; }
.js [data-for-kind].is-hidden { display: none; }
.aging { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
.aging > div { display: flex; flex-direction: column; padding: 7px 12px; border-right: 1px solid var(--divider); }
.aging > div:last-child { border-right: 0; }
.aging-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.aging-amount { font: 500 var(--fs-lg)/1.3 var(--font-mono); }
.aging-total .aging-amount { font-size: var(--fs-xl); }
.aging-1_30 .aging-amount { color: var(--warn); }
.aging-31_60 .aging-amount, .aging-61_90 .aging-amount, .aging-90_plus .aging-amount { color: var(--bad); }
.inline-form-4 { grid-template-columns: 160px 160px minmax(0, 1fr) auto; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) { .cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1200px) { .detail-layout { grid-template-columns: minmax(0, 1fr) 280px; } }
@media (max-width: 1024px) {
  .detail-layout { grid-template-columns: 1fr; }
  .time-add-grid, .material-add-row, .line-add-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aging { grid-template-columns: repeat(3, 1fr); }
  .split { grid-template-columns: 1fr; }
  .split-list { max-height: 40vh; }
  .inline-form { grid-template-columns: 1fr; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 52px 1fr; }
  .shell .nav-label, .shell .nav-group, .shell .brand-name, .shell .nav-kbd, .shell .nav-phase { display: none; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .sidebar .nav { display: flex; padding: 4px; } .sidebar .nav-group, .brand { display: none; }
  .cols-2, .cols-3, .cols-4, .cols-5 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .toolbar-search { width: 100%; }
  .toolbar-hint, .stepper li { font-size: var(--fs-xs); }
  .main { padding: 10px 10px 30px; }
  .usermenu-name, .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { width: auto; }
}
@media print {
  .sidebar, .topbar, .toasts, .form-actions, [data-action] { display: none !important; }
  body, body.auth { background: #fff; }
  .shell { display: block; }
  .auth-card { box-shadow: none; border: 0; }
}

/* ---------------------------------------------------------------- email (Module 08) */
.email-filing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0 10px; border-bottom: 1px solid var(--divider); margin-bottom: 10px; }
.email-file-picker { display: flex; gap: 4px; }
.email-file-picker select { max-width: 260px; height: 24px; font-size: var(--fs-sm); }
.email-messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.email-msg { border: 1px solid var(--divider); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); }
.email-msg.email-outbound { background: var(--surface-2); border-left: 3px solid var(--accent); }
.email-msg-head { display: flex; justify-content: space-between; gap: 8px; }
.email-from { font-weight: 600; }
.email-time { font: 500 var(--fs-xs)/1.6 var(--font-mono); color: var(--muted); white-space: nowrap; }
.email-meta { margin: 1px 0 6px; overflow-wrap: anywhere; }
.email-body { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; max-height: 520px; overflow-y: auto; }
.email-html p { margin: 0 0 .6em; }
.email-html blockquote { margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--border); color: var(--text-2); }
.email-html table { border-collapse: collapse; max-width: 100%; }
.email-attachments { list-style: none; margin: 8px 0 0; padding: 6px 0 0; border-top: 1px dashed var(--divider); display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--fs-sm); }
.email-reply { margin-top: 12px; }
.email-preview .email-body { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--divider); border-radius: var(--radius); background: var(--surface-2); max-height: none; }
.reminder-list li.is-done { color: var(--muted); }

/* ---------------------------------------------------------------- payments (Module 09) */
.inline-form-5 { grid-template-columns: 150px 140px 150px minmax(0, 1fr) auto; margin-top: 10px; }
.is-warn { color: var(--warn); font-weight: 600; }
.copy-field { display: flex; gap: 6px; margin-bottom: 6px; }
.copy-field .input { flex: 1; min-width: 0; }
.recurring-lines .input { width: 100%; }
.recurring-lines td { padding: 3px 4px; }
.recurring-lines .col-kind { width: 110px; }
.recurring-lines .col-qty { width: 80px; }
.recurring-lines .col-price { width: 120px; }
.pay-card { max-width: 440px; }
.pay-amount { font: 600 32px/1.2 var(--font-mono); margin: 4px 0 2px; }
.pay-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.pay-legal { font-size: var(--fs-xs); color: var(--muted); margin-top: -4px; }
.pay-facts { width: 100%; margin: 14px 0; }
.pay-actions { display: flex; flex-direction: column; gap: 8px; }
.pay-actions .btn { justify-content: center; height: 38px; font-size: var(--fs-lg); }
.pay-note { font-size: var(--fs-sm); color: var(--muted); margin-top: 10px; }
/* Public quote page (/quote/<token>) */
.auth-shell:has(.quote-card) { max-width: 680px; }
.pay-card:has(.quote-card) { max-width: none; }
.quote-lines { width: 100%; border-collapse: collapse; margin: 14px 0 8px; }
.quote-lines th, .quote-lines td { padding: 5px 0 5px 10px; border-bottom: 1px solid var(--divider); vertical-align: top; text-align: left; }
.quote-lines th:first-child, .quote-lines td:first-child { padding-left: 0; }
.quote-lines th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.quote-lines th.num, .quote-lines td.num { text-align: right; white-space: nowrap; }
.quote-kind { display: inline-block; font-size: var(--fs-xs); color: var(--muted); min-width: 52px; }
/* Client portal (/portal) */
body.portal { background: var(--bg); }
.portal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 48px; padding: 0 20px; background: var(--sidebar); color: #fff; border-bottom: 3px solid var(--accent); }
.portal-brand { display: flex; align-items: center; gap: 10px; }
.portal-brand .brand-mark { height: 24px; width: auto; color: var(--accent); }
.portal-name { font-weight: 800; text-transform: uppercase; font-stretch: 75%; font-size: 18px; letter-spacing: .02em; }
.portal-sub { color: var(--sidebar-muted); font-size: var(--fs-sm); }
.portal-user { display: flex; align-items: center; gap: 10px; }
.portal-user .muted { color: var(--sidebar-muted); }
.portal-main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 32px; }
.portal-section { margin-top: 16px; }
.portal-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; height: var(--row-h); }
.portal-wrap { white-space: normal; }
.portal-foot { margin-top: 20px; color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 720px) { .portal-sub, .portal-user .muted { display: none; } .portal-main { padding: 12px; } }
.deposit-form { grid-template-columns: auto 96px auto; align-items: center; margin-top: 10px; }
.quote-terms { margin: 10px 0; font-size: var(--fs-sm); color: var(--text-2); }
.quote-terms summary { cursor: pointer; font-weight: 600; color: var(--text); }
.quote-terms ol { margin: 6px 0 0; padding-left: 18px; }
.quote-terms li { margin: 2px 0; }
.quote-notes { margin: 10px 0; white-space: pre-line; color: var(--text-2); font-size: var(--fs-sm); }
@media (max-width: 1024px) { .inline-form-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- files (Module 10) */
.file-list { list-style: none; margin: 0 0 8px; padding: 0; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--divider); }
.file-row:last-child { border-bottom: 0; }
.file-thumb, .file-ext { flex: none; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius); display: grid; place-items: center; overflow: hidden; background: var(--surface-2, var(--surface)); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font: 600 var(--fs-xs)/1 var(--font-mono); text-transform: uppercase; color: var(--muted); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { position: relative; border: 1px dashed var(--border); border-radius: var(--radius); padding: 8px 10px; }
.dropzone.is-dragover { border-color: var(--accent, var(--info)); background: var(--info-soft); }
.dropzone-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: var(--fs-sm); }
.dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-label:focus-within { outline: 2px solid var(--info); outline-offset: 2px; }
.dropzone .panel-note { margin: 4px 0 0; }
.receipt-cell { white-space: nowrap; }
.receipt-cell form { display: inline; }
.receipt-pick { font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
.receipt-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.receipt-pick:hover { color: var(--text); }
.inline-action { display: inline; margin-left: 6px; }

/* ---------------------------------------------------------------- reports (Module 11) */
.report-filters { flex-wrap: wrap; gap: 8px; }
.report-filters .chips { margin-right: 4px; }
.report-jump { width: auto; }
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.report-card { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.report-card:hover { border-color: var(--accent); }
.report-card-title { font-weight: 600; }
.report-card-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 0; }
.report-card-facts dt { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-card-facts dd { margin: 0; font: 500 var(--fs-sm)/1.3 var(--font-mono); }
.report-charts { display: grid; gap: 10px; margin: 10px 0; }
.report-charts.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart { margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.chart-title { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 4px; }
.chart-legend { display: flex; gap: 10px; font-weight: 400; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--divider); stroke-width: 1; }
.chart-tick, .chart-label { fill: var(--muted); font: 10px var(--font-mono); }
.chart-bar.tone-0, .legend-swatch.tone-0 { fill: var(--accent); background: var(--accent); }
.chart-bar.tone-1, .legend-swatch.tone-1 { fill: var(--text); background: var(--text); opacity: .8; }
.chart-bar.tone-2, .legend-swatch.tone-2 { fill: var(--warn); background: var(--warn); }
.chart-bar:hover { opacity: .8; }
.report-table { margin-top: 14px; }
.report-table-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.report-table tfoot td { font-weight: 600; }
@media (max-width: 1024px) { .report-charts.cols-2 { grid-template-columns: 1fr; } }

/* ================================================================ usability pass (design only)
   Benchmarks: Linear / Stripe Dashboard / Harvest / HubSpot forms. Clear label hierarchy, visible
   required markers, one obvious primary action that stays in reach, generous hit targets,
   immediate feedback on submit, and errors that are impossible to miss. */

/* ---- labels, hints, required */
.field { gap: 4px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text); letter-spacing: .005em; }
.req { color: var(--accent-ink); margin-left: 2px; font-weight: 700; }
.field-hint { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.field-error { font-size: 11.5px; line-height: 1.35; display: flex; gap: 4px; align-items: baseline; }
.field-error::before { content: "!"; display: inline-grid; place-items: center; width: 13px; height: 13px; flex: none; border-radius: 50%; background: var(--bad); color: #fff; font: 700 9px/1 var(--font-sans); transform: translateY(1px); }
.has-error .field-label { color: var(--bad); }
.has-error .input { border-color: var(--bad); background: color-mix(in srgb, var(--bad-soft) 45%, var(--surface)); }

/* ---- inputs */
.input { transition: border-color .12s, box-shadow .12s, background-color .12s; }
.input::placeholder { color: var(--faint); opacity: 1; }
.input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input[readonly] { cursor: text; }
.input[inputmode="decimal"], .input[inputmode="numeric"] { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.input[type="date"], .input[type="time"] { font-family: var(--font-mono); font-size: 12.5px; }
textarea.input { padding-top: 6px; padding-bottom: 6px; min-height: 64px; }
/* Native selects get a consistent chevron and room for it. */
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b6566' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 10px 6px;
}
select.input[multiple] { background-image: none; padding-right: 8px; }
.has-affix .input:focus { position: relative; z-index: 1; }
.affix { font-family: var(--font-mono); font-size: 11.5px; }
.field-control:focus-within .affix { border-color: var(--focus); color: var(--text-2); }

/* ---- checkboxes & radios: bigger, brand-colored, whole label clickable */
.check { align-items: flex-start; gap: 8px; padding: 2px 0; line-height: 1.35; }
.check-input { width: 15px; height: 15px; margin: 1px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.check-text { display: flex; flex-direction: column; gap: 2px; }
.check:hover .check-text { color: var(--text); }

/* ---- page forms: readable width, sections with breathing room, sticky action bar */
.form-grid { max-width: 1120px; gap: 12px; }
.form-section { padding: 14px 16px 16px; }
.form-section legend { font-size: 14px; font-weight: 700; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--divider); }
.form-section .grid { row-gap: 14px; }
.form-section .grid + .grid, .form-section .grid + .field, .form-section .field + .grid { margin-top: 14px; }
.form-grid > .form-actions {
  position: sticky; bottom: 0; z-index: 5; margin: 0; padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 14px rgba(31, 29, 30, .06);
}
.form-actions .muted { font-size: var(--fs-sm); }
/* If any field has an error, say so above the form (no backend change: pure CSS). */
.form-grid:has(.has-error)::before {
  content: "Please fix the highlighted fields below."; display: block; padding: 8px 12px;
  border: 1px solid var(--bad); border-left-width: 3px; border-radius: var(--radius);
  background: var(--bad-soft); color: var(--text); font-weight: 600;
}

/* ---- buttons: clearer states, bigger targets, busy feedback */
.btn { font-weight: 550; transition: background-color .12s, border-color .12s, box-shadow .12s; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary { box-shadow: 0 1px 0 rgba(31, 29, 30, .25); }
.btn-primary .icon { stroke-width: 2.25; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; pointer-events: none; }
.btn.is-busy::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: np-spin .7s linear infinite;
}
@keyframes np-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.is-busy::after { animation: none; } .btn:active { transform: none; } }
.kbd-hint { margin-left: auto; color: var(--faint); font-size: var(--fs-xs); white-space: nowrap; }
.kbd-hint kbd { font-size: 10px; }

/* ---- inline entry bars (log time, add material, add line, record payment): read as one unit */
.time-add, .material-add, .line-add, .inline-form, .inline-form-4, .inline-form-5 { --entry-gap: 10px; }
.time-add, .material-add, .line-add { border-left: 3px solid var(--accent); background: var(--surface); }
.time-add-grid, .material-add-row, .line-add-row { column-gap: 10px; row-gap: 10px; }
.time-add-actions { padding-bottom: 1px; }
.time-add .btn-primary, .material-add .btn-primary, .line-add .btn-primary { min-width: 84px; }

/* ---- small text actions (Edit / Delete / Remove) were 11px with no hit area */
.link-btn { font-size: var(--fs-sm); padding: 3px 4px; margin: -3px 0; border-radius: var(--radius-sm); color: var(--text-2); }
.link-btn:hover { background: var(--surface-3); text-decoration: none; color: var(--accent-ink); }
.row-actions > * + *, .row-actions form + form { margin-left: 4px; }
.data-table tbody tr .row-actions { opacity: .7; transition: opacity .1s; }
.data-table tbody tr:hover .row-actions, .data-table tbody tr:focus-within .row-actions { opacity: 1; }

/* ---- tables: easier scanning */
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface-2)); }
.data-table td.num, .data-table th.num { padding-right: 12px; }
.data-table tbody tr[data-href] { cursor: pointer; }

/* ---- panels & page headers: stronger hierarchy */
.page-header { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--divider); }
.page-header h1 { font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
.panel-header h2 { font-weight: 700; }
.panel-note { font-size: 11.5px; line-height: 1.4; }

/* ---- focus visibility everywhere (keyboard users) */
a:focus-visible, .chip:focus-visible, .nav-item:focus-visible, .link-btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm);
}
.form-grid > .form-actions::after { content: "⌘ ↵ saves"; margin-left: auto; color: var(--faint); font: 500 var(--fs-xs) var(--font-mono); }
/* Floated legends: whatever follows starts on its own line (prevents the title overlapping the
   first row in every browser). */
.form-section > legend + * { clear: both; }

/* ---------------------------------------------------------------- timesheets */
.nav-badge-timesheet_attention { background: var(--warn); color: #fff; }
.ts-table .ts-desc strong { display: block; font-weight: 650; }
.ts-detail { display: block; color: var(--text-2); font-size: var(--fs-sm); white-space: pre-line; }
.ts-table td { vertical-align: top; padding-top: 6px; padding-bottom: 6px; height: auto; }
.ts-table .ts-date { white-space: nowrap; }
.ts-check { width: 28px; }
.ts-table tfoot td { font-weight: 500; }
.ts-table tfoot .ts-grand td { font-weight: 700; font-size: var(--fs-lg); }
.ts-ready { margin-bottom: 14px; }
.ts-flat { border: 0; border-radius: 0; }
.ts-comment { margin: 6px 0; padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); white-space: pre-line; }
.ts-steps li { margin-bottom: 6px; }
.ts-public-lines { margin: 12px 0; border-top: 1px solid var(--divider); }
.ts-line { padding: 8px 0; border-bottom: 1px solid var(--divider); }
.ts-line-head { display: flex; justify-content: space-between; gap: 10px; }
.ts-line-head .num { font-family: var(--font-mono); font-size: var(--fs-sm); white-space: nowrap; }
.ts-changes { margin-top: 12px; }
.ts-changes summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); }
.ts-changes form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ts-action-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px auto auto; gap: 10px; align-items: center; }
.ts-actions td { padding-top: 6px; padding-bottom: 6px; height: auto; }
.pay-card:has(.ts-public-lines) { max-width: 640px; }
.time-locked { font-size: var(--fs-xs); color: var(--warn); white-space: nowrap; }
.line-title { font-weight: 600; }

/* ---------------------------------------------------------------- inline line editing */
.line-edit-row > td { background: var(--accent-soft); padding: 10px 12px; height: auto; white-space: normal; }
.line-edit-grid { display: grid; grid-template-columns: 120px minmax(260px, 3fr) 90px 130px repeat(2, minmax(0, 120px)) auto; gap: 10px; align-items: start; }
.line-edit-grid .field + .field { margin-top: 0; }
.line-edit-desc textarea { min-height: 56px; }
.line-edit-actions { display: flex; gap: 6px; align-self: end; padding-bottom: 18px; }
.line-edit .panel-note { margin-top: 6px; }
@media (max-width: 1024px) { .line-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .line-edit-desc { grid-column: 1 / -1; } }
.ts-edit-grid { display: grid; grid-template-columns: 150px minmax(170px, 1fr) 90px minmax(240px, 2.2fr) auto; gap: 10px; align-items: start; }
.ts-edit-grid:has(#new-target) { grid-template-columns: minmax(170px, 1fr) 150px minmax(170px, 1fr) 90px minmax(220px, 2fr) auto; }
.ts-edit-grid .field + .field { margin-top: 0; }
.ts-add { margin-top: 14px; }
.ts-add-existing { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--divider); }
.ts-add-existing .plain-list { margin: 6px 0 8px; }
.ts-line-total { border-bottom: 0; border-top: 2px solid var(--text); }
@media (max-width: 1024px) { .ts-edit-grid, .ts-edit-grid:has(#new-target) { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ts-edit-desc { grid-column: 1 / -1; } }
.nav-badge-unsorted_problems { background: var(--warn); color: #fff; }
