/* OHMS prototype — design tokens follow the OHMS solution sheet (teal primary, cool grey canvas). */
:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f6f9fb;
  --border: #dbe4ec;
  --border-strong: #c3d1dc;
  --text: #10222f;
  --text-2: #33495a;
  --muted: #5d6e7c;

  --primary: #1d6a8a;
  --primary-700: #134e66;
  --primary-50: #e2eff5;
  --primary-100: #cbe3ee;

  --fit: #23784a;
  --fit-50: #e3f3e9;
  --warn: #a8650f;
  --warn-50: #fbf0dc;
  --unfit: #b42d22;
  --unfit-50: #fbe7e4;
  --info: #3f5bb8;
  --info-50: #e7ecfa;
  --neutral-50: #edf1f4;

  /* Categorical series — validated (CVD ΔE ≥ 12, contrast ≥ 3:1 on white). Status colours stay reserved. */
  --series-1: #11729a;
  --series-2: #c27a1a;
  --series-3: #7a5fc0;
  --series-4: #3f9fbf;

  --font-head: "Poppins", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(16, 34, 47, 0.06);
  --shadow-2: 0 1px 2px rgba(16, 34, 47, 0.05), 0 8px 24px -12px rgba(16, 34, 47, 0.18);
  --shadow-3: 0 24px 60px -20px rgba(16, 34, 47, 0.35);

  --sidebar-w: 248px;
  --duration: 160ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.55 var(--font-body);
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.2vw, 2rem); font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font: 600 11px/1.4 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); }
.num { font-variant-numeric: tabular-nums; }
.accent { color: var(--primary); }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0;
  width: var(--sidebar-w); height: 100vh; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px; z-index: 40;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); position: relative; flex-shrink: 0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: #fff; border-radius: 2px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.brand-mark::before { width: 16px; height: 4px; }
.brand-mark::after { width: 4px; height: 16px; }
.brand-name { font: 700 17px/1.1 var(--font-head); letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; line-height: 1.3; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { margin: 14px 8px 6px; font: 600 10.5px/1 var(--font-body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-50); color: var(--primary-700); }
.nav a[aria-current="page"] svg { color: var(--primary); }
.nav a.sub { padding-left: 38px; font-weight: 400; font-size: 13.5px; }
.nav a.locked { opacity: 0.45; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav .count { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--unfit); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: rgba(238, 243, 247, 0.86); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; min-width: 0; flex: 1; }
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-switch { display: flex; align-items: center; gap: 8px; }
.role-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.role-switch select {
  appearance: none; padding: 7px 34px 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6e7c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-weight: 600; font-size: 13px; color: var(--primary-700); cursor: pointer;
}
.topbar .menu-btn { display: none; }
/* Content uses the full width next to the sidebar. */
.view { padding: clamp(18px, 1.6vw, 32px) clamp(16px, 2vw, 40px) 60px; width: 100%; outline: none; }
.scrim { display: none; }

/* ---------- Page heading ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head .lede { margin-top: 6px; color: var(--muted); max-width: 64ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 14px 18px 18px; }
.card-body.flush { padding: 10px 0 4px; }
.card.raised { box-shadow: var(--shadow-2); }

.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: grid; gap: 16px; align-content: start; }
.section { margin-top: 16px; }

/* ---------- KPI ---------- */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font: 600 28px/1.15 var(--font-head); margin-top: 8px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--border-strong); }
.kpi.tone-fit::before { background: var(--fit); }
.kpi.tone-warn::before { background: var(--warn); }
.kpi.tone-unfit::before { background: var(--unfit); }
.kpi.tone-primary::before { background: var(--primary); }
.kpi.hero { background: linear-gradient(140deg, var(--primary) 0%, var(--primary-700) 100%); border-color: transparent; color: #fff; }
.kpi.hero::before { display: none; }
.kpi.hero .kpi-label, .kpi.hero .kpi-sub, .kpi.hero .kpi-value small { color: rgba(255, 255, 255, 0.8); }
.kpi.hero .kpi-value { font-size: 34px; color: #fff; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--neutral-50); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge.fit { background: var(--fit-50); color: var(--fit); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.unfit { background: var(--unfit-50); color: var(--unfit); }
.badge.info { background: var(--info-50); color: var(--info); }
.badge.primary { background: var(--primary-50); color: var(--primary-700); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
.btn-danger { background: var(--unfit); border-color: var(--unfit); color: #fff; }
.btn-danger:hover { background: #8f2219; border-color: #8f2219; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Tabs & filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button {
  padding: 10px 14px; border: 0; background: none; cursor: pointer;
  font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs [aria-selected="true"] { color: var(--primary-700); border-bottom-color: var(--primary); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .select { width: auto; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--surface-2); color: var(--muted); }
.textarea { min-height: 64px; resize: vertical; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 32px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0; display: grid; gap: 12px; min-width: 0; }
.fieldset legend { padding: 0 6px; font: 600 11.5px/1 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); }
.seg-control { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; flex-wrap: wrap; }
.seg-control label { padding: 7px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600; border-right: 1px solid var(--border); position: relative; }
.seg-control label:last-child { border-right: 0; }
.seg-control input { position: absolute; opacity: 0; pointer-events: none; }
.seg-control label:has(input:checked) { background: var(--primary); color: #fff; }
.seg-control label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--duration) var(--ease); }
table.data tbody tr[data-href] { cursor: pointer; }
table.data tbody tr[data-href]:hover { background: var(--surface-2); }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; background: var(--muted); }
.dot.unfit { background: var(--unfit); box-shadow: 0 0 0 4px var(--unfit-50); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-50); }
.dot.fit { background: var(--fit); box-shadow: 0 0 0 4px var(--fit-50); }
.bullets { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bullets li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); }
.bullets li::before { content: ""; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--fit); box-shadow: 0 0 0 3px var(--fit-50); flex-shrink: 0; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13px; }
.callout svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.callout.unfit { background: var(--unfit-50); border-color: #f0c3bd; color: #7d1f17; }
.callout.warn { background: var(--warn-50); border-color: #efd5a6; color: #6e430b; }
.callout.fit { background: var(--fit-50); border-color: #b9dfc8; color: #17502f; }
.callout.info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-700); }
.callout strong { display: block; }
.lock { display: grid; place-items: center; gap: 10px; text-align: center; padding: 56px 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.lock svg { width: 34px; height: 34px; color: var(--muted); }
.lock p { color: var(--muted); max-width: 46ch; }

/* ---------- OHMS home ---------- */
.hero-head { margin-bottom: 26px; }
.hero-head h1 { font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.5rem); font-weight: 600; max-width: 18ch; }
.hero-head .lede { margin-top: 10px; color: var(--muted); max-width: 60ch; font-size: 15px; }
.module-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.module-card { display: flex; flex-direction: column; gap: 10px; padding: 20px; color: inherit; transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease); }
a.module-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--primary-100); }
.module-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.module-icon svg { width: 22px; height: 22px; }
.module-card .sub { font-size: 12.5px; color: var(--primary-700); margin-top: -6px; }
.module-card .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; }
.module-card.locked { opacity: 0.6; }
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.flow-item { padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.flow-item b { display: block; font: 600 12.5px/1.3 var(--font-head); margin-bottom: 4px; color: var(--primary-700); }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border-top: 1px solid var(--border); }
.roles > div { padding: 18px 18px 6px; border-right: 1px solid var(--border); }
.roles > div:last-child { border-right: 0; }
.roles h3 { font: 600 12px/1.3 var(--font-head); letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary-700); margin-bottom: 8px; }
.roles p { color: var(--muted); font-size: 13px; }
.roles > div[aria-current="true"] { background: var(--primary-50); border-radius: var(--radius); }

/* ---------- Profile ---------- */
.profile { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 18px; }
.avatar { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-50); color: var(--primary-700); font: 600 18px/1 var(--font-head); }
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.profile .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- Timeline (SOAP visits) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline > li { position: relative; padding: 0 0 18px 28px; }
.timeline > li::before { content: ""; position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline > li.auto::before { border-color: var(--unfit); }
.soap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.soap div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }
.soap b { display: inline-block; width: 18px; height: 18px; border-radius: 5px; background: var(--primary); color: #fff; text-align: center; font-size: 11px; line-height: 18px; margin-right: 6px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 500 11px var(--font-body); fill: var(--muted); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart .axis { stroke: var(--border-strong); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; flex-shrink: 0; }
.donut-wrap .legend { flex-direction: column; gap: 8px; margin: 0; flex: 1; min-width: 150px; }
.donut-wrap .legend span { display: flex; }
.donut-wrap .legend b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 52px; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; }
.bar-row .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; background: var(--neutral-50); border-radius: 999px; overflow: hidden; display: flex; }
.bar-track span { display: block; height: 100%; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: rgba(16, 34, 47, 0.04); }
.chart .bar-hit { cursor: pointer; }
.chart .bar-hit:hover rect { opacity: 0.85; }
.tip {
  position: fixed; z-index: 150; pointer-events: none; max-width: 260px;
  padding: 8px 10px; border-radius: 8px; background: var(--text); color: #fff;
  font-size: 12px; line-height: 1.45; box-shadow: var(--shadow-3); white-space: pre-line;
  font-variant-numeric: tabular-nums;
}
.meter { height: 6px; background: var(--neutral-50); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* Risk matrix */
.matrix { display: grid; grid-template-columns: 22px repeat(5, minmax(0, 1fr)); gap: 4px; font-size: 11.5px; }
.matrix .cell { aspect-ratio: 1.6; border-radius: 6px; display: grid; place-items: center; font: 600 15px/1 var(--font-head); color: rgba(16, 34, 47, 0.35); }
.matrix .cell.has { color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45); }
.matrix .ax { display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.risk-low { background: #d7ede0; } .risk-low.has { background: var(--fit); }
.risk-med { background: #f6e7c4; } .risk-med.has { background: #c28a1c; }
.risk-high { background: #f6d6bf; } .risk-high.has { background: #d0631f; }
.risk-ext { background: #f3cdc8; } .risk-ext.has { background: var(--unfit); }

/* Crew board (DCU) */
.crew { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.crew-card { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); border-left-width: 4px; }
.crew-card.fit { border-left-color: var(--fit); }
.crew-card.unfit { border-left-color: var(--unfit); background: linear-gradient(90deg, var(--unfit-50), var(--surface) 75%); }
.crew-card.pending { border-left-color: var(--border-strong); border-style: dashed; border-left-style: solid; }
.crew-card .grow { flex: 1; min-width: 0; }
.crew-card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Live evaluation (DCU form) */
.verdict { border-radius: var(--radius); padding: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.verdict-title { font: 700 20px/1.2 var(--font-head); letter-spacing: 0.02em; }
.verdict.fit { background: var(--fit-50); border-color: #b9dfc8; }
.verdict.fit .verdict-title { color: var(--fit); }
.verdict.unfit { background: var(--unfit-50); border-color: #f0c3bd; }
.verdict.unfit .verdict-title { color: var(--unfit); }
.verdict ul { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; }
.verdict-slot #dcu-verdict { position: sticky; top: 0; }
@media (max-width: 860px) {
  /* Keep the gatekeeper decision visible while the screener types on a phone. */
  .verdict-slot { order: -1; position: sticky; top: -18px; z-index: 2; margin: -18px -20px 0; padding: 10px 20px; background: var(--surface); box-shadow: 0 6px 12px -10px rgba(16, 34, 47, 0.4); }
  .verdict-slot .verdict { padding: 10px 12px; }
  .verdict-slot .verdict-title { font-size: 16px; }
  .verdict-slot .verdict .muted { display: none; }
}

/* ---------- Access control (RBAC) ---------- */
.scope-chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral-50); color: var(--text-2); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.scope-chip.scoped { background: var(--warn-50); color: var(--warn); }
.scope-chip::before { content: "◎ "; }
.rbac-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rbac-flow > div { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); position: relative; }
.rbac-flow b { display: block; font: 600 13px/1.3 var(--font-head); color: var(--primary-700); margin-bottom: 2px; }
.perm-matrix th, .perm-matrix td { white-space: nowrap; }
.perm-matrix th:first-child, .perm-matrix td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; }
.perm-matrix thead th:first-child { background: var(--surface-2); }
.perm-matrix .area-row td { background: var(--surface-2); font: 600 10.5px/1 var(--font-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-top: 10px; padding-bottom: 8px; }
.perm-matrix .role-head { display: grid; gap: 4px; text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--text); min-width: 170px; }
.perm-matrix .role-head .small { color: var(--muted); font-weight: 400; }
.perm-select { padding: 6px 28px 6px 10px; font-size: 12.5px; width: auto; min-width: 210px; }
.perm-select.none { color: var(--muted); background-color: var(--surface-2); }
.perm-cell-none { color: var(--muted); }

/* ---------- Masterdata navigation & overview ---------- */
.nav-toggle { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 16px); padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.nav-toggle svg { width: 14px; height: 14px; transition: transform var(--duration) var(--ease); }
.nav-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.nav-toggle:hover { color: var(--text); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group[hidden] { display: none; }
.nav-subhead { margin: 10px 10px 2px 38px; font-size: 11px; font-weight: 600; color: var(--muted); }
.nav .nav-group a.sub { padding-top: 7px; padding-bottom: 7px; font-size: 13px; }
.md-group-title { font-size: 0.95rem; margin-bottom: 10px; color: var(--text-2); }
.md-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.md-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; color: inherit; transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease); }
a.md-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--primary-100); }
.md-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.md-count { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: var(--neutral-50); font-size: 11.5px; text-align: center; color: var(--muted); }
.md-actions { white-space: nowrap; text-align: right; }
tr.md-inactive td { color: var(--muted); }
tr.md-inactive .cell-main { color: var(--muted); text-decoration: line-through; }
.chips-check { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 6px 0; }

/* ---------- Modal & toast ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(16, 34, 47, 0.45); animation: fade var(--duration) var(--ease); }
.modal-root[hidden] { display: none; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); animation: rise 220ms var(--ease); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: var(--radius); background: var(--text); color: #fff; box-shadow: var(--shadow-3); font-size: 13px; animation: rise 220ms var(--ease); border-left: 4px solid var(--primary-100); }
.toast.unfit { border-left-color: #ff8a7d; }
.toast.fit { border-left-color: #7fd3a1; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Print (Report → PDF) ---------- */
@media print {
  .sidebar, .topbar, .no-print, .toast-root { display: none !important; }
  body { background: #fff; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body.printing-modal .app { display: none; }
  body.printing-modal .modal-root { position: static; background: none; padding: 0; display: block; }
  body.printing-modal .modal { box-shadow: none; max-height: none; width: 100%; }
  body.printing-modal .modal-foot, body.printing-modal .modal-head button { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roles > div { border-bottom: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; transform: translateX(-100%); transition: transform 240ms var(--ease); box-shadow: var(--shadow-3); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(16, 34, 47, 0.4); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .view { padding: 18px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid-3, .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-label { display: none; }
  .scope-chip { display: none; }
  .rbac-flow { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .module-grid, .flow { grid-template-columns: minmax(0, 1fr); }
  .roles { grid-template-columns: minmax(0, 1fr); }
  .roles > div { border-right: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid.form-grid-3, .form-grid.form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi.hero .kpi-value { font-size: 28px; }
  .soap { grid-template-columns: minmax(0, 1fr); }
  .crumbs > :not(:last-child) { display: none; }
  .role-switch select { max-width: 160px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .bar-row { grid-template-columns: 92px 1fr 44px; }
  .toolbar .select { flex: 1; }

  /* Tables collapse into stacked cards on phones */
  table.data.stackable thead { display: none; }
  table.data.stackable, table.data.stackable tbody, table.data.stackable tr, table.data.stackable td { display: block; width: 100%; }
  table.data.stackable tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.data.stackable tr:last-child { border-bottom: 0; }
  table.data.stackable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  table.data.stackable td::before { content: attr(data-label); font-size: 11.5px; color: var(--muted); font-weight: 600; text-align: left; flex-shrink: 0; }
  table.data.stackable td > .cv { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
  table.data.stackable td.primary-cell > .cv { display: block; }
  table.data.stackable td.primary-cell { display: block; text-align: left; padding-bottom: 6px; }
  table.data.stackable td.md-actions { justify-content: flex-end; gap: 4px; }
  table.data.stackable td.primary-cell::before { display: none; }
  .modal-root { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .toast-root { left: 16px; right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
.session { padding: 2px 4px 6px; line-height: 1.4; }

/* ---------- Line lists (e.g. MCU package examinations) ---------- */
.reflist-rows { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; counter-reset: line; }
.reflist-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; gap: 6px; align-items: center; counter-increment: line; }
.reflist-no::before { content: counter(line) "."; font-size: 12px; font-weight: 600; color: var(--muted); }
.reflist-row .icon-btn { width: 32px; height: 32px; }
.reflist-row [data-action="reflist-up"] svg { transform: rotate(-90deg); }
.reflist-row:first-child [data-action="reflist-up"] { visibility: hidden; }

/* ---------- Attachments ---------- */
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px 4px 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; color: var(--primary-700); cursor: pointer; text-align: left; }
.file-chip:hover { border-color: var(--primary); background: var(--primary-50); }
.file-chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.file-chip small { color: var(--muted); white-space: nowrap; }
input[type=file].input { padding: 6px 8px; }
