/* Layout: fixed left rail (nav) + scrolling work area; rail becomes a top strip under 860px.
   Ink neutrals with a faint red bias; Sysrek red is the single accent, SCAHI cyan marks the R&D division. */
:root {
  --bg: #f6f5f5;
  --surface: #ffffff;
  --surface-2: #f0eeee;
  --line: #e3dfdf;
  --line-strong: #cfc9c9;
  --fg: #17161a;
  --muted: #6b6569;
  --faint: #9a9397;
  --accent: #d32637;
  --accent-soft: #fbe8ea;
  --accent-ink: #ffffff;
  --scahi: #0b8fa3;
  --scahi-soft: #e2f4f6;
  --ok: #1f8a4c;
  --ok-soft: #e4f4ea;
  --warn: #b26a00;
  --warn-soft: #fbf0dc;
  --bad: #c0262d;
  --bad-soft: #fbe5e5;
  --info: #3657c8;
  --info-soft: #e7ecfb;
  --shadow: 0 1px 2px rgba(23, 22, 26, .06), 0 8px 24px rgba(23, 22, 26, .06);
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 8px;
  --accent-2: #2e9e5b;
  --rail-bg: #17151a; --rail-fg: #f1eef0; --rail-muted: #9c959a; --rail-hover: rgba(255,255,255,.07);
  --rail-active-bg: var(--accent); --rail-active-fg: #ffffff; --rail-line: rgba(255,255,255,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131215; --surface: #1c1b1f; --surface-2: #242227; --line: #2f2d33; --line-strong: #3d3a41;
    --fg: #efedf0; --muted: #a39da3; --faint: #75707a;
    --accent: #f0505e; --accent-soft: #3a1b20; --accent-ink: #1a0b0d;
    --scahi: #3cc3d6; --scahi-soft: #12333a;
    --ok: #4cc27d; --ok-soft: #15301f; --warn: #e5a23a; --warn-soft: #34270f; --bad: #f06a6f; --bad-soft: #3a1a1c; --info: #8ea6ff; --info-soft: #1d2442;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131215; --surface: #1c1b1f; --surface-2: #242227; --line: #2f2d33; --line-strong: #3d3a41;
  --fg: #efedf0; --muted: #a39da3; --faint: #75707a;
  --accent: #f0505e; --accent-soft: #3a1b20; --accent-ink: #1a0b0d;
  --scahi: #3cc3d6; --scahi-soft: #12333a;
  --ok: #4cc27d; --ok-soft: #15301f; --warn: #e5a23a; --warn-soft: #34270f; --bad: #f06a6f; --bad-soft: #3a1a1c; --info: #8ea6ff; --info-soft: #1d2442;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--rail-bg); color: var(--rail-fg); border-right: 1px solid var(--rail-line);
  padding-block: 18px 16px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: 14px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: .02em; display: flex; align-items: center; line-height: 1; }
.wordmark .e { display: inline-flex; flex-direction: column; justify-content: space-between; width: 13px; height: 16px; margin: 0 1px 0 2px; }
.wordmark .e i { display: block; height: 3.4px; background: var(--accent); border-radius: 1px; }
.brand small { color: var(--rail-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--rail-muted); padding: 0 10px 4px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--rail-muted); font-weight: 500; }
.nav button:hover { background: var(--rail-hover); color: var(--rail-fg); }
.nav button.on { background: var(--rail-active-bg); color: var(--rail-active-fg); }
.nav button:focus-visible { outline: 2px solid var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--rail-muted); font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; font-size: 12px; color: var(--rail-muted); padding: 0 10px; display: flex; flex-direction: column; gap: 6px; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); width: fit-content; }
.mode-pill.live { background: var(--ok-soft); color: var(--ok); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding-block: 10px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); flex-wrap: wrap; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.topbar h1 { font-family: var(--display); font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.crumb { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.crumb button { all: unset; cursor: pointer; color: var(--muted); }
.crumb button:hover { color: var(--fg); text-decoration: underline; }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { all: unset; cursor: pointer; padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg button:focus-visible { outline: 2px solid var(--accent); }
.content { padding-block: 22px 60px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 20px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--fg); background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn svg { width: 14px; height: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 7px; padding: 7px 10px; min-width: 0; }
textarea.in { min-height: 76px; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.search { max-width: 260px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .in { width: auto; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel > header h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: .01em; }
.panel > header .sub { color: var(--muted); font-size: 12px; }
.panel .body { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.kpi { padding: 14px 18px; display: flex; flex-direction: column; gap: 3px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.kpi .value { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .note { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi:nth-child(3) { border-left: 0; } .kpi:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.strong { font-weight: 500; }
table.t tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.plain::before { display: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.div-tag { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--muted); }
.div-tag.scahi { border-color: color-mix(in srgb, var(--scahi) 50%, transparent); color: var(--scahi); background: var(--scahi-soft); }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); font-size: 10.5px; font-weight: 600; color: var(--muted); flex: none; }
.who { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.pri { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 4px; }
.pri.P1 { color: var(--bad); background: var(--bad-soft); }
.pri.P2 { color: var(--warn); background: var(--warn-soft); }
.pri.P3, .pri.P4 { color: var(--muted); background: var(--surface-2); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--fg); border-radius: 99px; }
.bar.over > i { background: var(--bad); }
.bar.scahi > i { background: var(--scahi); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.click { cursor: pointer; }
.list-item.click:hover { background: var(--surface-2); }
.stripe { width: 3px; align-self: stretch; border-radius: 2px; background: var(--line-strong); flex: none; }
.stripe.bad { background: var(--bad); } .stripe.warn { background: var(--warn); } .stripe.ok { background: var(--ok); }

/* ---------- kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-2); border-radius: var(--r); display: flex; flex-direction: column; min-height: 200px; border: 1px solid transparent; }
.col.drop { border-color: var(--accent); background: var(--accent-soft); }
.col > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; font-weight: 600; font-size: 12.5px; }
.col > header .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.col > header .sum { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 6px 8px 10px; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 10px 11px; cursor: grab; display: flex; flex-direction: column; gap: 7px; }
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: .45; }
.card .t { font-weight: 500; line-height: 1.35; }
.card .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.card .meta .r { margin-left: auto; }
.late { color: var(--bad); font-weight: 500; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--body); }
.chart .grid line { stroke: var(--line); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- modal & toast ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 9, 12, .45); z-index: 40; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 12px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal.wide { width: min(900px, 100%); }
.modal > header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal > header h3 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 700; }
.modal .mbody { padding: 18px 20px; overflow-y: auto; }
.modal > footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form .f.full { grid-column: 1 / -1; }
.form label { font-size: 12px; font-weight: 500; color: var(--muted); }
.form .check { flex-direction: row; align-items: center; gap: 8px; }
@media (max-width: 560px) { .form { grid-template-columns: minmax(0, 1fr); } }
.toast { position: fixed; bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px)); left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; z-index: 50; font-weight: 500; box-shadow: var(--shadow); }
.confirm-line { display: flex; gap: 8px; align-items: center; margin-right: auto; color: var(--bad); font-size: 13px; }

/* ---------- invoice ---------- */
.inv { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; display: flex; flex-direction: column; gap: 22px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.inv h2 { font-family: var(--display); margin: 0; font-size: 24px; letter-spacing: -.01em; }
.inv .kv { display: grid; grid-template-columns: auto auto; gap: 2px 14px; font-size: 13px; }
.inv .kv span:nth-child(odd) { color: var(--muted); }
.inv-totals { margin-left: auto; width: min(320px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.inv-totals .grand { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line-strong); padding-top: 6px; }
.lines td .in { padding: 5px 8px; }
.words { font-size: 12.5px; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { font-family: var(--display); margin: 6px 0 0; font-size: 22px; }
.err { color: var(--bad); font-size: 13px; }

/* ---------- timesheet ---------- */
.week td.cell { text-align: center; font-variant-numeric: tabular-nums; }
.week td.cell.zero { color: var(--faint); }
.week td.cell.today, .week th.today { background: var(--accent-soft); }
.integr { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.integr:last-child { border-bottom: 0; }
.integr .grow { flex: 1; min-width: 0; }
.integr code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- responsive shell ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding-block: 10px; padding-right: max(14px, env(safe-area-inset-right, 0px)); gap: 14px; border-right: 0; border-bottom: 1px solid var(--rail-line); }
  .brand small, .rail-foot, .nav-group > span, .nav .count { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-group { flex-direction: row; gap: 2px; }
  .nav button { white-space: nowrap; padding: 6px 9px; }
  .topbar { top: env(safe-area-inset-top, 0px); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .inv { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .rail, .topbar, .noprint { display: none !important; }
  .app { display: block; } .content { padding: 0; } .inv { border: 0; }
}

/* ---------- HRMS ---------- */
.kvgrid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; font-size: 13px; }
.kvgrid > span:nth-child(odd) { color: var(--muted); }
.kvgrid > span { min-width: 0; overflow-wrap: anywhere; }
.linkish { all: unset; cursor: pointer; font-weight: 500; }
.linkish:hover { text-decoration: underline; }
.linkish:focus-visible { outline: 2px solid var(--accent); }
.code { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 3px; border-radius: 4px; font: 600 10.5px/1 var(--mono); cursor: pointer; background: var(--surface-2); color: var(--faint); }
.code:focus-visible { outline: 2px solid var(--accent); }
.code.adj { outline: 1px dashed currentColor; outline-offset: -2px; }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-scahi { background: var(--scahi-soft); color: var(--scahi); }
.t-off { background: transparent; color: var(--faint); }
.legend .code { cursor: default; margin-right: 3px; }
table.reg { font-size: 12px; }
table.reg th, table.reg td { padding: 6px 4px; }
table.reg th.dcol { text-align: center; font-size: 10.5px; letter-spacing: 0; padding: 6px 2px; min-width: 30px; }
table.reg th.dcol div { font-weight: 400; color: var(--faint); }
table.reg th.we { color: var(--faint); }
table.reg th.today { background: var(--accent-soft); color: var(--accent); }
table.reg td.dcell { text-align: center; padding: 3px 1px; }
table.reg .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 150px; padding-left: 12px; border-right: 1px solid var(--line); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: center; }
.cal-cell { all: unset; box-sizing: border-box; cursor: pointer; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; min-height: 58px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cal-cell .d { font-size: 11px; color: var(--muted); }
.cal-cell .c { font: 600 12px var(--mono); }
.cal-cell .tm { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-cell.t-off { background: var(--surface-2); color: inherit; }
.cal-cell.t-ok .c { color: var(--ok); } .cal-cell.t-warn .c { color: var(--warn); } .cal-cell.t-bad .c { color: var(--bad); } .cal-cell.t-info .c { color: var(--info); } .cal-cell.t-scahi .c { color: var(--scahi); }
.cal-cell.t-bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.cal-cell.is-today { border-color: var(--accent); }
.cal-cell:focus-visible { outline: 2px solid var(--accent); }
@media (max-width: 560px) { .cal-cell .tm { display: none; } .cal-cell { min-height: 44px; padding: 4px; } }
.checklist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; }
.ck { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ck:last-child { border-bottom: 0; }
.ck input { margin-top: 3px; accent-color: var(--accent); }
.ck.done .grow { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.ck .owner { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.letter { max-width: 760px; font-size: 14.5px; line-height: 1.65; }
.letter p { margin: 0; max-width: 68ch; }


/* ---------- skins (brand themes) ----------
   Skins change accent and sidebar only; light/dark surfaces come from the base tokens. */
.rail .wordmark { color: var(--rail-fg); }
.rail .btn.ghost { color: var(--rail-muted); }
.rail .btn.ghost:hover { color: var(--rail-fg); background: var(--rail-hover); }
:root[data-skin="nest"] { --rail-bg: #111714; --rail-active-bg: #2e9e5b; --accent-2: #2e9e5b; }
:root[data-skin="scahi"] { --accent: #0b8fa3; --accent-soft: #e2f4f6; --accent-ink: #ffffff; --accent-2: #1f5fa8; --rail-bg: #0e2a47; --rail-fg: #eef5fb; --rail-muted: #9db4c9; --rail-active-bg: #0b8fa3; }
:root[data-skin="graphite"] { --rail-bg: var(--surface); --rail-fg: var(--fg); --rail-muted: var(--muted); --rail-hover: var(--surface-2); --rail-active-bg: var(--accent-soft); --rail-active-fg: var(--accent); --rail-line: var(--line); --accent: #c62f3c; --accent-2: #4a6fa5; }
@media (prefers-color-scheme: dark) {
  :root[data-skin="sysrek"]:not([data-theme="light"]), :root:not([data-skin]):not([data-theme="light"]) { --rail-bg: #0d0c0f; --accent-2: #4cc27d; }
  :root[data-skin="nest"]:not([data-theme="light"]) { --rail-bg: #0b0f0d; --accent-2: #4cc27d; --rail-active-bg: #23774a; }
  :root[data-skin="scahi"]:not([data-theme="light"]) { --accent: #3cc3d6; --accent-soft: #12333a; --accent-ink: #06191c; --accent-2: #7fa8e0; --rail-bg: #0a1a2c; --rail-active-bg: #0b6f80; }
  :root[data-skin="graphite"]:not([data-theme="light"]) { --accent: #f0505e; --accent-2: #8ea6ff; }
}
:root[data-skin="sysrek"][data-theme="dark"] { --rail-bg: #0d0c0f; --accent-2: #4cc27d; }
:root[data-skin="nest"][data-theme="dark"] { --rail-bg: #0b0f0d; --accent-2: #4cc27d; --rail-active-bg: #23774a; }
:root[data-skin="scahi"][data-theme="dark"] { --accent: #3cc3d6; --accent-soft: #12333a; --accent-ink: #06191c; --accent-2: #7fa8e0; --rail-bg: #0a1a2c; --rail-active-bg: #0b6f80; }
:root[data-skin="graphite"][data-theme="dark"] { --accent: #f0505e; --accent-2: #8ea6ff; }

/* colour touches */
.panel > header { background: color-mix(in srgb, var(--accent) 3.5%, var(--surface)); border-radius: var(--r) var(--r) 0 0; }
.kpi .label { display: flex; align-items: center; gap: 7px; }
.kpi .label::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); flex: none; }
.kpi:nth-child(2) .label::before { background: var(--accent-2); }
.kpi:nth-child(3) .label::before { background: var(--info); }
.kpi:nth-child(4) .label::before { background: var(--warn); }
.kpis-nest { background: color-mix(in srgb, var(--accent-2) 7%, var(--surface)); border-color: color-mix(in srgb, var(--accent-2) 30%, var(--line)); }
.kpis-nest .kpi { border-color: color-mix(in srgb, var(--accent-2) 25%, var(--line)); }
.topbar h1 { position: relative; }
.col > header { border-bottom: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); margin-bottom: 4px; }
.seg-lg button { padding: 6px 14px; font-size: 13px; }
.seg-lg button.on { background: var(--accent); color: var(--accent-ink); }

/* CRM */
.plan-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); color: var(--accent-2); white-space: nowrap; }
.stagebar { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.stagebar .st { all: unset; cursor: pointer; flex: 1 0 auto; text-align: center; font-size: 12.5px; font-weight: 500; padding: 8px 14px; background: var(--surface-2); color: var(--muted); border-radius: 6px; white-space: nowrap; }
.stagebar .st.past { background: color-mix(in srgb, var(--accent-2) 16%, var(--surface)); color: var(--accent-2); }
.stagebar .st.cur { background: var(--accent); color: var(--accent-ink); }
.stagebar .st.lost.cur { background: var(--bad); color: #fff; }
.stagebar .st:hover:not(.cur) { color: var(--fg); }
.stagebar .st:focus-visible { outline: 2px solid var(--accent); }
.stagebar .st[disabled] { cursor: default; }
.act-types { flex-wrap: wrap; }
.act-types label { cursor: pointer; }
.act-types input { position: absolute; opacity: 0; pointer-events: none; }
.act-types span { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.act-types input:checked + span { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.act-types input:focus-visible + span { outline: 2px solid var(--accent); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.tl-item:last-child { border-bottom: 0; }
.tl-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 13px; flex: none; }
.tl-item .grow { flex: 1; min-width: 0; }
.tl-notes { margin-top: 3px; max-width: 70ch; overflow-wrap: anywhere; }
.small-btn { padding: 3px 8px; font-size: 12px; }
.bar.dual { position: relative; }
.bar.dual > i { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); position: absolute; left: 0; top: 0; }
.bar.dual > b { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; position: absolute; left: 0; top: 0; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-bar { flex: 1; height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2))); border-radius: 4px; }
.code-block { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 0; white-space: pre; max-width: 100%; }
.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.skin { all: unset; box-sizing: border-box; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.skin:hover { border-color: var(--line-strong); }
.skin.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.skin:focus-visible { outline: 2px solid var(--accent); }
.skin .sw { display: flex; height: 26px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 4px; }
.skin .sw i { flex: 1; }

/* ---------- Gantt ---------- */
.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 680px; font-size: 12.5px; }
.gr { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; align-items: center; min-height: 30px; }
.gr .gl { padding: 3px 10px 3px 0; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.gr .gl > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr .gl.grp { font-weight: 600; }
.gt { position: relative; height: 30px; }
.gh .gt { height: 22px; border-bottom: 1px solid var(--line); }
.gm { position: absolute; top: 3px; font-size: 11px; color: var(--muted); white-space: nowrap; transform: translateX(2px); }
.gbody { position: relative; }
.ggrid { position: absolute; left: min(230px, 30%); right: 0; top: 0; bottom: 0; pointer-events: none; }
.gbody .ggrid { left: 0; margin-left: clamp(150px, 25%, 230px); }
.ggrid i { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--line); }
.ggrid em { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--bad); opacity: .7; }
.gb { position: absolute; top: 8px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); overflow: hidden; }
.gb b { display: block; height: 100%; background: var(--accent); }
.gb.info { background: color-mix(in srgb, var(--info) 22%, var(--surface-2)); } .gb.info b { background: var(--info); }
.gb.muted { background: var(--surface-2); } .gb.muted b { background: var(--faint); }
.gb.warn { background: color-mix(in srgb, var(--warn) 25%, var(--surface-2)); } .gb.warn b { background: var(--warn); }
.gb.bad { background: color-mix(in srgb, var(--bad) 22%, var(--surface-2)); } .gb.bad b { background: var(--bad); }
.gb.scahi { background: color-mix(in srgb, var(--scahi) 22%, var(--surface-2)); } .gb.scahi b { background: var(--scahi); }
.gd { position: absolute; top: 9px; width: 12px; height: 12px; transform: translateX(-6px) rotate(45deg); background: var(--fg); border-radius: 2px; }
.gd.ok { background: var(--ok); } .gd.bad { background: var(--bad); } .gd.info { background: var(--info); }

/* RAID, approvals, permissions */
.sev { font-size: 12px; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.sev.s3 { background: var(--bad-soft); color: var(--bad); } .sev.s2 { background: var(--warn-soft); color: var(--warn); } .sev.s1 { background: var(--surface-2); color: var(--muted); }
.steps { display: inline-flex; gap: 4px; }
.steps i { width: 18px; height: 6px; border-radius: 3px; background: var(--line-strong); }
.steps i.ok { background: var(--ok); } .steps i.bad { background: var(--bad); } .steps i.skip { background: var(--surface-2); }
table.pmx td, table.pmx th { padding: 7px 8px; }
.pm { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.pm.e { background: var(--ok-soft); color: var(--ok); } .pm.v { background: var(--info-soft); color: var(--info); } .pm.n { color: var(--faint); }
.tpl { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 14px; flex-wrap: wrap; }
.tpl .grow { flex: 1; min-width: 220px; }

/* quality */
.doc-body .body { max-width: 75ch; line-height: 1.65; font-size: 14.5px; }
.doc-body h2, .doc-body h3 { font-family: var(--display); margin: 18px 0 6px; }
.doc-body h3 { font-size: 16px; }
.doc-body h3:first-child, .doc-body h2:first-child { margin-top: 0; }
.doc-body p { margin: 0 0 8px; }
.doc-body ul, .doc-body ol { margin: 0 0 10px; padding-left: 22px; }
.quiz { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.quiz legend { font-weight: 600; padding: 0 4px; }
.quiz label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.vert { writing-mode: vertical-rl; transform: rotate(180deg); font-family: var(--mono); font-size: 10.5px; white-space: nowrap; }
