/* ==========================================================
   SPM Build Tracker — visual system
   Surface: engineering drawing sheet. Nav: control-panel bezel.
   Discipline colour code: blueprint blue = mechanical,
   copper = electrical, graphite = everything else.
   ========================================================== */

:root {
  --ink:      #0F1519;
  --slate:    #39454F;
  --muted:    #6B7A85;
  --paper:    #E9EDEF;
  --panel:    #FFFFFF;
  --rule:     #CDD6DC;
  --rule-soft:#E3E9EC;

  --blue:     #1F5FA8;
  --blue-50:  #E7EFF8;
  --copper:   #B36F06;
  --copper-50:#FAF0DC;
  --green:    #1B6F4D;
  --green-50: #E2F0EA;
  --red:      #AE2E27;
  --red-50:   #FAE7E5;
  --amber:    #8A6100;
  --amber-50: #FBF0D5;

  --r: 3px;
  --shadow: 0 1px 0 rgba(15,21,25,.04), 0 2px 10px rgba(15,21,25,.05);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --disp: "Barlow Condensed", "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--slate);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(31,95,168,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,95,168,.045) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--disp);
  color: var(--ink);
  letter-spacing: .01em;
  margin: 0;
  font-weight: 600;
}
h1 { font-size: 30px; line-height: 1.1; text-transform: uppercase; letter-spacing: .02em; }
h2 { font-size: 19px; text-transform: uppercase; letter-spacing: .05em; }
h3 { font-size: 16px; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 99;
  background: var(--ink); color: #fff; padding: 10px 14px;
}
.skip:focus { left: 0; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: 214px; flex: 0 0 214px;
  background: var(--ink);
  color: #96A5B0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 3px solid #000;
}
.rail-brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.rail-mark {
  display: block; font-family: var(--disp); font-weight: 700; font-size: 27px;
  letter-spacing: .16em; color: #fff; line-height: 1;
}
.rail-word {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--copper); margin-top: 5px;
}
.rail-nav { list-style: none; margin: 10px 0 auto; padding: 0; }
.rail-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 18px; color: #A8B6C0; text-decoration: none;
  font-family: var(--disp); font-size: 16px; letter-spacing: .06em; text-transform: uppercase;
  border-left: 3px solid transparent;
}
.rail-nav svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.rail-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.rail-nav a.on { color: #fff; background: rgba(31,95,168,.22); border-left-color: var(--copper); }

.rail-user { border-top: 1px solid rgba(255,255,255,.08); padding: 12px 14px; }
.rail-me { display: flex; align-items: center; gap: 10px; color: #C6D2DA; text-decoration: none; }
.rail-me b { display: block; font-size: 13px; color: #fff; font-weight: 500; }
.rail-me i { display: block; font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #7E8F9B; }
.rail-out {
  display: inline-block; margin-top: 10px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: #7E8F9B;
}

.main { flex: 1 1 auto; min-width: 0; padding: 26px 30px 60px; }
.rail-toggle { display: none; }

/* ---------- Title block header ---------- */
.tblock {
  background: var(--panel); border: 1px solid var(--rule);
  display: grid; grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: stretch; margin-bottom: 22px; box-shadow: var(--shadow);
}
.tblock-id { padding: 16px 20px; border-right: 1px solid var(--rule); }
.eyebrow {
  margin: 0 0 4px; font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--copper);
}
.tblock-cells { display: flex; margin: 0; }
.tblock-cells > div {
  padding: 14px 18px; border-right: 1px solid var(--rule); min-width: 104px;
}
.tblock-cells dt {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.tblock-cells dd {
  margin: 0; font-family: var(--disp); font-size: 19px; color: var(--ink); font-weight: 600;
}
.tblock-act { padding: 14px 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--rule); box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--rule);
}
.panel-head h2 { font-size: 14px; letter-spacing: .12em; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--panel); border: 1px solid var(--rule); padding: 14px 16px;
  box-shadow: var(--shadow); display: block; color: inherit; text-decoration: none;
  border-top: 3px solid var(--slate);
}
.stat:hover { text-decoration: none; border-color: var(--blue); border-top-color: var(--blue); }
.stat b { display: block; font-family: var(--disp); font-size: 38px; line-height: 1; color: var(--ink); }
.stat span {
  display: block; margin-top: 6px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
}
.stat-late { border-top-color: var(--red); }
.stat-late b { color: var(--red); }
.stat-soon { border-top-color: var(--amber); }
.stat-ok { border-top-color: var(--green); }
.stat-blue { border-top-color: var(--blue); }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-family: var(--mono); font-size: 9.5px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  padding: 10px 14px; border-bottom: 1px solid var(--rule); background: #F7F9FA; white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #F6F9FB; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
.code { font-family: var(--mono); font-size: 12px; color: var(--ink); letter-spacing: .02em; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 12px; }

/* ---------- Tags / chips ---------- */
.tag, .pri, .disc {
  display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 7px; border: 1px solid; border-radius: var(--r); white-space: nowrap;
}
.tag-not_started { color: var(--muted); border-color: var(--rule); background: #F4F7F8; }
.tag-in_progress { color: var(--blue); border-color: #BCD3EC; background: var(--blue-50); }
.tag-on_hold, .tag-planning { color: var(--amber); border-color: #E6D3A0; background: var(--amber-50); }
.tag-blocked, .tag-cancelled { color: var(--red); border-color: #EDBFBB; background: var(--red-50); }
.tag-completed, .tag-delivered { color: var(--green); border-color: #B6DBCA; background: var(--green-50); }

.pri { border-color: var(--rule); color: var(--muted); background: #F4F7F8; }
.pri-high { color: var(--copper); border-color: #E3CB99; background: var(--copper-50); }
.pri-critical { color: #fff; background: var(--red); border-color: var(--red); }

.disc { border-color: var(--rule); background: #F4F7F8; color: var(--slate); }
.disc-mechanical { color: var(--blue); border-color: #BCD3EC; background: var(--blue-50); }
.disc-electrical { color: var(--copper); border-color: #E3CB99; background: var(--copper-50); }
.disc-software   { color: #5B3E9B; border-color: #D0C6EA; background: #F0ECFA; }
.disc-quality    { color: var(--green); border-color: #B6DBCA; background: var(--green-50); }

.health { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.health::before { content: "●"; margin-right: 5px; }
.health-late { color: var(--red); }
.health-soon { color: var(--amber); }
.health-ok   { color: var(--green); }
.health-done { color: var(--muted); }
.health-hold { color: var(--copper); }
.health-none { color: var(--muted); }

/* ---------- Progress bar ---------- */
.bar { height: 6px; background: #E4EAED; border-radius: 20px; overflow: hidden; min-width: 70px; }
.bar-fill { display: block; height: 100%; border-radius: 20px; }
.bar-low { background: var(--copper); }
.bar-mid { background: var(--blue); }
.bar-done { background: var(--green); }
.pctwrap { display: flex; align-items: center; gap: 9px; }
.pct { font-family: var(--mono); font-size: 12px; color: var(--ink); min-width: 34px; text-align: right; }

/* ---------- Avatars ---------- */
.ava {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 50%; background: var(--slate); color: #fff;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; flex: 0 0 auto;
}
.ava-lg { width: 40px; height: 40px; font-size: 14px; }
.stack { display: inline-flex; }
.stack .ava { margin-right: -7px; border: 2px solid var(--panel); }
.stack .ava:last-child { margin-right: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-family: var(--disp); font-size: 14px; letter-spacing: .09em; text-transform: uppercase;
  padding: 8px 15px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
  border-radius: var(--r); text-decoration: none; line-height: 1.3;
}
.btn:hover { border-color: var(--slate); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #17497f; border-color: #17497f; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { color: var(--red); border-color: #E4BDBA; background: var(--red-50); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field > label, .lbl {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--rule); border-radius: var(--r);
  font-family: var(--sans); font-size: 14px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(31,95,168,.12); }
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.checks label {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border: 1px solid var(--rule-soft); border-radius: var(--r); cursor: pointer; font-size: 13px;
}
.checks label:hover { background: #F6F9FB; }
.checks input { accent-color: var(--blue); }

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  padding: 12px 18px; border-bottom: 1px solid var(--rule); background: #F7F9FA;
}
.filters .field { margin: 0; min-width: 140px; }
.filters select, .filters input { padding: 6px 9px; font-size: 13px; }

/* ---------- Flash ---------- */
.flash {
  padding: 11px 16px; margin-bottom: 16px; border: 1px solid; border-radius: var(--r);
  font-size: 13.5px;
}
.flash-ok { background: var(--green-50); border-color: #B6DBCA; color: var(--green); }
.flash-error { background: var(--red-50); border-color: #EDBFBB; color: var(--red); }
.flash-info { background: var(--blue-50); border-color: #BCD3EC; color: var(--blue); }

/* ---------- Gantt ---------- */
.gantt { overflow-x: auto; }
.gantt-inner { min-width: 760px; position: relative; }
.gantt-row { display: grid; grid-template-columns: 246px 1fr; border-bottom: 1px solid var(--rule-soft); }
.gantt-row:hover { background: #F6F9FB; }
.gantt-lab { padding: 8px 14px; border-right: 1px solid var(--rule); min-width: 0; }
.gantt-lab b { display: block; font-weight: 500; font-size: 13px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-lab span { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.gantt-track { position: relative; height: 38px; }
.gantt-scale { display: grid; grid-template-columns: 246px 1fr; border-bottom: 1px solid var(--rule); background: #F7F9FA; }
.gantt-ticks { position: relative; height: 30px; }
.gantt-tick {
  position: absolute; top: 0; height: 100%; border-left: 1px solid var(--rule-soft);
  font-family: var(--mono); font-size: 9.5px; color: var(--muted); padding: 8px 0 0 5px; white-space: nowrap;
}
.gbar {
  position: absolute; top: 9px; height: 20px; border-radius: 2px; overflow: hidden;
  background: #DCE3E7; border: 1px solid rgba(0,0,0,.08); min-width: 4px;
}
.gbar i {
  display: block; height: 100%; background: var(--slate); opacity: .85;
}
.gbar-mechanical i { background: var(--blue); }
.gbar-electrical i { background: var(--copper); }
.gbar-software i   { background: #5B3E9B; }
.gbar-quality i    { background: var(--green); }
.gbar-late { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.gbar-txt {
  position: absolute; top: 11px; font-family: var(--mono); font-size: 10px; color: var(--muted);
  white-space: nowrap; pointer-events: none;
}
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: .7; z-index: 2; }
.gantt-track .today-line::after { content: none; }
.gantt-ticks .today-line::after {
  content: "TODAY"; position: absolute; top: -22px; left: -18px; font-family: var(--mono);
  font-size: 9px; letter-spacing: .1em; color: var(--red);
}

/* ---------- Timeline / updates ---------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule-soft); }
.tl li:last-child { border-bottom: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.tl-note { margin: 4px 0 0; white-space: pre-wrap; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 372px; background: var(--panel); border: 1px solid var(--rule); box-shadow: var(--shadow); }
.auth-top { background: var(--ink); color: #fff; padding: 22px 24px; }
.auth-top .rail-mark { font-size: 30px; }
.auth-body { padding: 24px; }

/* ---------- Misc ---------- */
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack-sm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.rule { height: 1px; background: var(--rule-soft); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink); }
.load-bar { height: 22px; background: #E4EAED; border-radius: 2px; overflow: hidden; position: relative; }
.load-bar i { display: block; height: 100%; background: var(--blue); }
.load-bar.over i { background: var(--red); }
.load-bar span { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 8px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .rail {
    position: sticky; top: 0; z-index: 20; width: 100%; height: auto; flex: none;
    border-right: 0; border-bottom: 3px solid #000;
  }
  .rail-nav, .rail-user { display: none; }
  .rail.open .rail-nav, .rail.open .rail-user { display: block; }
  .rail-brand { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; }
  .rail-word { margin: 0; }
  .rail-toggle {
    display: inline-block; margin-bottom: 14px; background: var(--panel); border: 1px solid var(--rule);
    font-family: var(--disp); text-transform: uppercase; letter-spacing: .1em; padding: 7px 13px; border-radius: var(--r);
  }
  .main { padding: 18px 16px 50px; }
  .tblock { grid-template-columns: 1fr; }
  .tblock-id { border-right: 0; border-bottom: 1px solid var(--rule); }
  .tblock-cells { flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
  .tblock-cells > div { flex: 1 1 44%; }
  .g2, .g3, .g4, .row-2, .row-3 { grid-template-columns: 1fr; }
  h1 { font-size: 24px; }
  .table-scroll { overflow-x: auto; }
  table.data { min-width: 620px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .rail, .tblock-act, .btn, .filters { display: none !important; }
  body { background: #fff; }
  .panel, .tblock { box-shadow: none; }
}

/* ==========================================================
   v2 — dashboard, charts, permission matrix, dark theme
   ========================================================== */

/* ---------- Dark theme ---------- */
html[data-theme="dark"] {
  --ink: #E6EDF2;
  --slate: #C2CEd8;
  --muted: #8A98A4;
  --paper: #12181D;
  --panel: #1A2229;
  --rule: #2C3841;
  --rule-soft: #232D35;
  --blue-50: #16283C;
  --copper-50: #2E2410;
  --green-50: #14291F;
  --red-50: #2E1917;
  --amber-50: #2A2312;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 2px 12px rgba(0,0,0,.35);
}
html[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(120,170,220,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,170,220,.05) 1px, transparent 1px);
}
html[data-theme="dark"] table.data th { background: #202A32; }
html[data-theme="dark"] table.data tbody tr:hover { background: #202A32; }
html[data-theme="dark"] .filters { background: #202A32; }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: #131A20; color: var(--ink); border-color: var(--rule);
}
html[data-theme="dark"] .bar { background: #2A343D; }
html[data-theme="dark"] .load-bar { background: #2A343D; }
html[data-theme="dark"] .btn { background: #202A32; color: var(--ink); }
html[data-theme="dark"] .checks label:hover { background: #202A32; }
html[data-theme="dark"] .codeblock { background: #0E1418; }

/* ---------- Dashboard grid ---------- */
.dash { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; align-items: start; }
.dash-cell { min-width: 0; }
.dash-full  { grid-column: span 6; }
.dash-half  { grid-column: span 3; }
.dash-third { grid-column: span 2; }
.dash .panel { margin-bottom: 0; }

/* ---------- Colourful KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi {
  display: block; padding: 16px 16px 14px; border-radius: var(--r); text-decoration: none;
  color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.12);
}
.kpi:hover { text-decoration: none; filter: brightness(1.07); }
.kpi b { display: block; font-family: var(--disp); font-size: 42px; line-height: .95; color: #fff; }
.kpi span {
  display: block; margin-top: 7px; font-family: var(--mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.88);
}
.kpi::after {
  content: ""; position: absolute; right: -18px; bottom: -22px; width: 74px; height: 74px;
  border-radius: 50%; background: rgba(255,255,255,.12);
}
.kpi-red   { background: linear-gradient(145deg, #C0392E, #8F211B); }
.kpi-amber { background: linear-gradient(145deg, #D08700, #9A6100); }
.kpi-green { background: linear-gradient(145deg, #1F8258, #14603F); }
.kpi-blue  { background: linear-gradient(145deg, #2A6FBC, #17497F); }
.kpi-teal  { background: linear-gradient(145deg, #10808F, #0A5A66); }
.kpi-slate { background: linear-gradient(145deg, #47535E, #2E3941); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.chart-sm { height: 140px; width: 140px; flex: 0 0 140px; }
.gauge-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.gauge-num b { display: block; font-family: var(--disp); font-size: 46px; line-height: 1; }
.gauge-num b.good { color: var(--green); }
.gauge-num b.warn { color: var(--amber); }
.gauge-num b.bad  { color: var(--red); }
.gauge-num span { display: block; font-size: 13px; color: var(--muted); }

/* ---------- Row tinting for red/amber/green tables ---------- */
tr.row-late  { background: linear-gradient(90deg, var(--red-50), transparent 55%); }
tr.row-soon  { background: linear-gradient(90deg, var(--amber-50), transparent 55%); }
tr.row-watch { background: linear-gradient(90deg, var(--copper-50), transparent 55%); }
tr.row-late td:first-child  { box-shadow: inset 3px 0 0 var(--red); }
tr.row-soon td:first-child  { box-shadow: inset 3px 0 0 var(--amber); }
tr.row-watch td:first-child { box-shadow: inset 3px 0 0 var(--copper); }
.health-watch { color: var(--copper); }
.txt-red { color: var(--red); }
.txt-green { color: var(--green); }
.txt-amber { color: var(--amber); }

/* ---------- Grouped nav rail ---------- */
.rail-nav { margin: 8px 0 auto; padding: 0; }
.rail-nav ul { list-style: none; margin: 0 0 10px; padding: 0; }
.rail-group {
  margin: 12px 0 4px; padding: 0 18px; font-family: var(--mono); font-size: 9px;
  letter-spacing: .18em; text-transform: uppercase; color: #64757F;
}

/* ---------- Permission matrix ---------- */
.permgroup { border: 1px solid var(--rule-soft); border-radius: var(--r); margin-bottom: 16px; }
.permgroup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--rule-soft); background: #F7F9FA;
}
html[data-theme="dark"] .permgroup-head { background: #202A32; }
.permgroup-head h3 { font-size: 14px; letter-spacing: .06em; text-transform: uppercase; }
.permgroup .checks { padding: 12px; }
.perm span { line-height: 1.35; }
.rolepick { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.rolepick label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.segmented a {
  padding: 7px 14px; font-family: var(--disp); font-size: 14px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--slate); text-decoration: none; border-right: 1px solid var(--rule);
}
.segmented a:last-child { border-right: 0; }
.segmented a.on { background: var(--blue); color: #fff; }
.segmented a:hover { text-decoration: none; background: rgba(31,95,168,.1); }
.segmented a.on:hover { background: var(--blue); }

/* ---------- Code block ---------- */
.codeblock {
  background: #0F1519; color: #C6D2DA; padding: 14px 16px; border-radius: var(--r);
  font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre; margin: 0;
}

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-third { grid-column: span 3; }
}
@media (max-width: 820px) {
  .dash { grid-template-columns: 1fr; }
  .dash-full, .dash-half, .dash-third { grid-column: span 1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 34px; }
}
