/* ==================================================================
   "Phoenix" theme – same design tokens as the other Aria apps
   (cool grey canvas, white bordered cards, royal-blue #3874ff, Nunito Sans,
   6–8px radii, flat surfaces, subtle bordered badges), light + dark.
   Loaded after app.css / platform.css and maps their variables.
   ================================================================== */
@font-face {
  font-family: 'Nunito Sans Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url('../fonts/nunito-sans-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
  color-scheme: light;
  --bg: #f5f7fa; --panel: #ffffff; --surface: #ffffff; --surface-2: #eff2f6; --surface-3: #e3e6ed;
  --ink: #141824; --ink2: #31374a; --ink3: #525b75; --muted: #8a94ad; --muted-2: #6e7891;
  --line: #cbd0dd; --line2: #eff2f6; --hair: #e3e6ed; --card-border: rgba(203, 208, 221, .54);
  --brand: #3874ff; --brand2: #004dff; --brandSoft: #e5edff; --tint-ink: #003cc7; --tint-border: #adc5ff;
  --ok: #25b003; --okSoft: #d9fbd0; --ok-ink: #1c6c09; --ok-border: #bbfbaa;
  --warn: #e5780b; --warnSoft: #ffefca; --warn-ink: #bc3803; --warn-border: #ffcc85;
  --bad: #ec1f00; --badSoft: #ffe0db; --bad-ink: #b81800; --bad-border: #ffc6bd;
  --req: #ec1f00; --accent: #e5780b;
  --r: .5rem; --shadow: none;
  --shadow-pop: 0 4px 30px -4px rgba(36, 40, 46, .14), 0 0 0 1px rgba(203, 208, 221, .5);
  --nav-w: 15.875rem; --top-h: 4rem;
  --h-blue: #3874ff; --h-lavender: #7f56e8; --h-peach: #e5780b; --h-mint: #25b003; --h-rose: #ec1f00; --h-sky: #0097eb;
}
html.dark {
  color-scheme: dark;
  --bg: #0f111a; --panel: #141824; --surface: #141824; --surface-2: #222834; --surface-3: #31374a;
  --ink: #eff2f6; --ink2: #cbd0dd; --ink3: #9fa6bc; --muted: #8a94ad; --muted-2: #8a94ad;
  --line: #373e53; --line2: #222834; --hair: #2a3142; --card-border: #2a3142;
  --brand: #3874ff; --brand2: #6b97ff; --brandSoft: #1c2231; --tint-ink: #85a9ff; --tint-border: #2c3d6b;
  --ok: #90d67f; --okSoft: #1d2527; --ok-ink: #90d67f; --ok-border: #23421c;
  --warn: #f3a564; --warnSoft: #262527; --warn-ink: #f3a564; --warn-border: #4a3420;
  --bad: #f48270; --badSoft: #241f25; --bad-ink: #f48270; --bad-border: #4d2620;
  --req: #f48270;
  --shadow-pop: 0 4px 30px -4px rgba(0, 0, 0, .6), 0 0 0 1px #373e53;
}

html, body { background: var(--bg); }
body {
  color: var(--ink2);
  font-family: 'Nunito Sans Variable', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: .875rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { color: var(--ink); }
::selection { background: var(--brandSoft); color: var(--tint-ink); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
svg.icon { width: 1.125rem; height: 1.125rem; flex: none; }
svg.icon.sm { width: 1rem; height: 1rem; } svg.icon.xs { width: .875rem; height: .875rem; } svg.icon.lg { width: 1.5rem; height: 1.5rem; }
.cap { color: var(--muted-2); font-size: .64rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.sub, p.sub { color: var(--muted-2); }
a { color: var(--brand); }

/* ------------------------------------------------------------ shell: 64px top bar + 254px side menu */
.topbar { position: fixed; inset: 0 0 auto 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
@media (min-width: 1024px) { .topbar { padding: 0 2.5rem 0 1.5rem; } }
.topbar .brand { display: flex; align-items: center; gap: .6rem; min-width: 0; text-decoration: none; }
@media (min-width: 1024px) { .topbar .brand { width: calc(var(--nav-w) - 1.5rem); } }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; background: var(--brand); color: #fff; flex: none; }
.brand-name { font-size: 1.05rem; font-weight: 800; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumb { display: none; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink2); }
@media (min-width: 768px) { .topbar .crumb { display: flex; } }
.topbar .crumb i { width: .6rem; height: .6rem; border-radius: 99px; background: var(--reg, var(--brand)); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.icon-btn { position: relative; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 999px; color: var(--ink3);
  background: none; border: 0; cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
@media (min-width: 1024px) { .icon-btn.mobile { display: none; } }
.theme-btn { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 999px; background: var(--warnSoft); color: var(--warn);
  border: 1px solid var(--warn-border); cursor: pointer; }
.theme-btn .sun { display: none; } html.dark .theme-btn .sun { display: block; } html.dark .theme-btn .moon { display: none; }
.avatar { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 999px; background: var(--brandSoft); color: var(--tint-ink);
  font-size: .75rem; font-weight: 800; flex: none; border: 0; cursor: pointer; }
details.menu { position: relative; }
details.menu > summary { list-style: none; } details.menu > summary::-webkit-details-marker { display: none; }
.dropdown { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 50; min-width: 16rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: .5rem; box-shadow: var(--shadow-pop); padding: .5rem; }
.dropdown .who { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1rem .75rem; border-bottom: 1px solid var(--line); margin: -.5rem -.5rem .5rem; text-align: center; }
.dropdown .who .avatar { width: 3.5rem; height: 3.5rem; font-size: 1rem; cursor: default; }
.dropdown a, .dropdown button.item { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .45rem .75rem; border-radius: .375rem; font-size: .8rem;
  font-weight: 600; color: var(--ink2); text-align: left; text-decoration: none; background: none; border: 0; cursor: pointer; }
.dropdown a:hover, .dropdown button.item:hover { background: var(--surface-2); color: var(--ink); }

.sidenav { position: fixed; z-index: 35; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w); display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .25s ease, width .2s ease; }
.sidenav.open { transform: none; box-shadow: var(--shadow-pop); }
.sidenav .scroll { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; }
.sidenav .foot { border-top: 1px solid var(--line); padding: .5rem 1rem; display: none; }
.nav-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .3); display: none; }
.nav-backdrop.open { display: block; }
.company-card { display: block; margin: .5rem 0 .25rem; padding: .5rem .75rem; border-radius: .5rem; border: 1px solid var(--card-border); background: var(--surface-2);
  text-decoration: none; line-height: 1.25; }
.company-card b { display: block; font-size: .8rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-group { padding: 1rem .5rem .4rem; display: flex; align-items: center; gap: .4rem; }
.nav-group i { width: .45rem; height: .45rem; border-radius: 99px; flex: none; }
.nav-item { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem; border-radius: .5rem; color: var(--ink3); font-size: .8125rem;
  font-weight: 700; line-height: 1.4; text-decoration: none; transition: background .15s, color .15s; background: none; border: 0; cursor: pointer; width: 100%; }
.nav-item svg.icon { width: 1rem; height: 1rem; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current] { color: var(--brand); }
html.dark .nav-item[aria-current] { color: #85a9ff; }
.page { padding: calc(var(--top-h) + 1.75rem) 1rem 4rem; min-width: 0; max-width: none; margin: 0; transition: margin-left .2s ease; }
@media (min-width: 640px) { .page { padding-left: 1.5rem; padding-right: 1.5rem; } }
@media (min-width: 1024px) {
  .sidenav { transform: none; }
  .sidenav .foot { display: block; }
  .page { margin-left: var(--nav-w); padding-left: 2.5rem; padding-right: 2.5rem; }
  html.nav-collapsed .sidenav { width: 4rem; }
  html.nav-collapsed .sidenav .scroll { padding-left: .6rem; padding-right: .6rem; overflow-x: hidden; }
  html.nav-collapsed .sidenav .lbl, html.nav-collapsed .sidenav .nav-group, html.nav-collapsed .company-card { display: none; }
  html.nav-collapsed .sidenav .nav-item { justify-content: center; padding: .5rem; }
  html.nav-collapsed .page { margin-left: 4rem; }
}
.pagehead { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.pagehead h1 { margin: .1rem 0 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; }
.pagehead .cap i { display: inline-block; width: .5rem; height: .5rem; border-radius: 99px; background: var(--reg, var(--brand)); margin-right: .35rem; }

/* ------------------------------------------------------------ components (restyle of app.css classes) */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: .5rem; box-shadow: none; }
h2.pg { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
h3.sect { font-size: 1rem; font-weight: 800; }
.btn { height: 2.375rem; padding: 0 1.1rem; border-radius: .375rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink2);
  font-size: .8rem; font-weight: 700; white-space: nowrap; text-decoration: none; justify-content: center; transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand2); border-color: var(--brand2); color: #fff; }
.btn.soft { background: var(--brandSoft); border-color: var(--tint-border); color: var(--tint-ink); }
.btn.danger { background: var(--badSoft); border-color: var(--bad-border); color: var(--bad-ink); }
.btn.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--brand) 25%, transparent); }
.linkbtn { color: var(--brand); font-weight: 700; font-size: .8rem; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: .375rem; min-height: 2.375rem; padding: .4rem .85rem; font-size: .85rem; }
html.dark input[type=text], html.dark input[type=password], html.dark input[type=search], html.dark input[type=number], html.dark input[type=date],
html.dark input[type=datetime-local], html.dark select, html.dark textarea { background: var(--surface-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: #6e9bff; box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--brand) 18%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }

/* subtle bordered badges */
.pill { display: inline-flex; align-items: center; padding: .15rem .5rem; border-radius: .25rem; border: 1px solid var(--line); font-size: .64rem; font-weight: 800;
  letter-spacing: .02em; text-transform: uppercase; line-height: 1.3; background: var(--surface-2); color: var(--ink3); }
.pill.s0 { background: var(--warnSoft); border-color: var(--warn-border); color: var(--warn-ink); }
.pill.s1 { background: var(--brandSoft); border-color: var(--tint-border); color: var(--tint-ink); }
.pill.s2 { background: var(--okSoft); border-color: var(--ok-border); color: var(--ok-ink); }

/* tables */
table.grid { font-size: .8rem; border-collapse: separate; border-spacing: 0; }
table.grid th { background: var(--surface); color: var(--ink2); font-size: .68rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
table.grid td { padding: .7rem 1rem; border-bottom: 0; border-top: 1px solid var(--hair); vertical-align: middle; }
table.grid tbody tr:first-child td { border-top: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tbody tr:hover { background: none; }
table.grid.static tbody tr:hover td { background: none; }
table.grid td a { font-weight: 700; }

/* KPI tiles & charts */
.kpi { padding: 1.1rem 1.25rem; border-left: 1px solid var(--card-border); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--hair); }
.kpi.good::before { background: var(--ok); } .kpi.bad::before { background: var(--bad); }
.kpi .k { font-size: .75rem; font-weight: 700; color: var(--ink3); }
.kpi .v { font-size: 1.6rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; white-space: nowrap; }
/* trend line always under the value, full tile width – same position in every tile */
.kpi .vrow { flex-direction: column; align-items: stretch; gap: .35rem; }
.kpi .sparkwrap { line-height: 0; }
.kpi .sparkwrap svg { width: 100%; height: 30px; }
/* tiles share the row instead of leaving empty columns */
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.minichart { display: flex; flex-direction: column; }
.minichart svg.bars { flex: 1; }
.kpi .s { color: var(--muted-2); }
.kpi .t { font-weight: 700; }
.kpi .t.good { color: var(--ok-ink); } .kpi .t.bad { color: var(--bad-ink); }
.stat { padding: 1.1rem 1.25rem; }
.stat .k { font-weight: 700; color: var(--ink3); } .stat .v { font-weight: 800; color: var(--ink); }
.chart, .minichart { padding: 1.1rem 1.25rem; }
.chart h4, .minichart h4 { font-size: .9rem; font-weight: 800; color: var(--ink); }

.bar { background: var(--brand); }
.sparkwrap { color: var(--brand); }
.score { color: var(--ok-ink); font-weight: 800; }
.regcard { border-top: 1px solid var(--card-border); }
.regcard-head h3 { font-weight: 800; }
.regcard-head h3 i { background: var(--reg); }
.regcard-foot { background: var(--surface-2); }
.legendrow { border-bottom-color: var(--hair); }

/* filter bar */
details.fctl > summary { border-radius: .375rem; border: 1px solid var(--line); font-weight: 700; color: var(--ink3); background: var(--surface); }
details.fctl.on > summary { background: var(--brandSoft); border-color: var(--tint-border); color: var(--tint-ink); }
details.fctl.on > summary b { color: var(--tint-ink); }
.fpop { border-radius: .5rem; box-shadow: var(--shadow-pop); border-color: var(--line); }
a.chip { background: var(--brandSoft); border: 1px solid var(--tint-border); color: var(--tint-ink); border-radius: .375rem; font-weight: 700; }

/* forms, dialogs, misc */
section.fsec > h3 { font-weight: 800; font-size: .95rem; }
.secnav a { font-weight: 700; color: var(--ink3); }
.secnav .prog.done { color: var(--ok); }
.secnav a.na { opacity: .45; cursor: not-allowed; text-decoration: line-through; text-decoration-color: var(--ink3); }
.secnav a.na:hover { background: none; }
.calc { background: var(--surface-2); border-radius: .375rem; }
.seg label { border-color: var(--line); border-radius: .375rem; font-weight: 600; }
.seg label:has(input:checked) { background: var(--brand); border-color: var(--brand); }
.chips label { border-color: var(--line); }
.chips label:has(input:checked) { background: var(--brandSoft); border-color: var(--tint-border); color: var(--tint-ink); }
.savebar { margin: 0 -2.5rem -4rem; padding: .75rem 2.5rem; background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 1023px) { .savebar { margin: 0 -1rem -4rem; padding: .75rem 1rem; } }
dialog { border-radius: .5rem; border-color: var(--line); box-shadow: var(--shadow-pop); background: var(--surface); color: var(--ink2); }
dialog h3 { font-weight: 800; }
.toast { background: var(--ink); color: var(--bg); border-radius: .5rem; font-weight: 600; box-shadow: var(--shadow-pop); }
.banner.bad { background: var(--badSoft); color: var(--bad-ink); border: 1px solid var(--bad-border); }
.secret { background: var(--okSoft); color: var(--ok-ink); border: 1px solid var(--ok-border); border-radius: .5rem; }
.errlist { background: var(--badSoft); color: var(--bad-ink); border: 1px solid var(--bad-border); }
.warnings div { background: var(--warnSoft); color: var(--warn-ink); border: 1px solid var(--warn-border); }
.quick a { border-radius: .375rem; font-weight: 700; }
.recordhead h2 { font-weight: 800; }

/* role & permission screens, settings */
.rolegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.rolecard { padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.rolecard h3 { margin: 0; font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.rolecard .meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
.permgroup { padding: 1rem 1.25rem; border-top: 1px solid var(--hair); }
.permgroup:first-child { border-top: 0; }
.permgroup h4 { margin: 0 0 .5rem; }
.perm { display: flex; gap: .65rem; align-items: flex-start; padding: .45rem 0; cursor: pointer; }
.perm input { margin-top: .2rem; width: 1rem; height: 1rem; }
.perm b { display: block; color: var(--ink); font-weight: 700; font-size: .82rem; }
.perm code, .mcode { font-size: .68rem; color: var(--muted-2); }
table.matrix th.c, table.matrix td.c { text-align: center; }
table.matrix td.grp { background: var(--surface-2); }
.setrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 1rem 2rem; padding: 1rem 1.25rem; border-top: 1px solid var(--hair); align-items: center; }
.setrow:first-of-type { border-top: 0; }
.setrow b { display: block; color: var(--ink); }
@media (max-width: 700px) { .setrow { grid-template-columns: 1fr; } }
.switch { position: relative; display: inline-flex; width: 2.5rem; height: 1.4rem; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: .2rem; top: .2rem; width: 1rem; height: 1rem; border-radius: 99px; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(1.1rem); }

/* login */
.login-wrap { background: var(--bg); }
.login-card { padding: 2rem; }
.login-card h1 { font-weight: 800; }

/* ------------------------------------------------------------ registry builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }
.bsec { padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.bsec h3 { margin: 0 0 .25rem; font-size: 1rem; font-weight: 800; display: flex; align-items: center; gap: .6rem; }
.step { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 99px; background: var(--brandSoft); color: var(--tint-ink); font-size: .75rem; font-weight: 800; }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1rem; margin-top: .75rem; }
.bgrid .wide { grid-column: 1 / -1; }
.bgrid label, .bsec label { display: block; font-size: .75rem; font-weight: 800; color: var(--ink2); margin-bottom: .3rem; }
.bgrid label.checkline { font-weight: 600 !important; }
.btable td { padding: .45rem .5rem; } .btable th { padding: .5rem; }
.kpirows { display: flex; flex-direction: column; gap: .75rem; margin-top: .75rem; }
.kpirow { padding: .5rem 1rem 1rem; background: var(--surface-2); border-color: var(--hair); }
html.dark .kpirow { background: #181d2a; }
.kpirow-foot { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.bsave { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .75rem 1.25rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: .5rem; box-shadow: var(--shadow-pop); margin-bottom: 1rem; }
.warnbox { padding: 1rem 1.25rem; margin-bottom: 1rem; background: var(--warnSoft); border-color: var(--warn-border); color: var(--warn-ink); }
.warnbox ul { margin: .4rem 0 0 1.1rem; padding: 0; font-size: .8rem; }
.varref { position: sticky; top: calc(var(--top-h) + 1rem); padding: 1rem; max-height: calc(100vh - var(--top-h) - 2rem); display: flex; flex-direction: column; }
.varref h4 { margin: 0 0 .5rem; }
.varlist { overflow-y: auto; margin-top: .25rem; }
.vsec { font-size: .64rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); padding: .75rem 0 .25rem; }
.vitem { padding: .35rem 0; border-bottom: 1px solid var(--hair); font-size: .78rem; }
.vitem b { color: var(--ink); font-weight: 700; }
.vitem code, .vcodes button { cursor: pointer; }
.vitem code { color: var(--tint-ink); background: var(--brandSoft); padding: 0 .3rem; border-radius: .25rem; font-size: .7rem; }
.vcodes { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.vcodes button { border: 1px solid var(--line); background: var(--surface); color: var(--ink3); border-radius: .25rem; font-size: .68rem; padding: .1rem .4rem; }
.vcodes button:hover { border-color: var(--tint-border); color: var(--tint-ink); }

/* ------------------------------------------------------------ side menu: collapsible, colour-coded registry groups */
.nav-heading { padding: 1rem .5rem .35rem; font-size: .64rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.nav-reg { margin: .15rem 0 .35rem; border-radius: .6rem; }
.nav-reg.here { background: color-mix(in srgb, var(--c) 7%, transparent); }
.nav-reg-head { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .4rem .5rem; border: 0; border-radius: .6rem; background: none; cursor: pointer;
  color: var(--ink); font: inherit; font-size: .82rem; font-weight: 800; text-align: left; transition: background .15s; }
.nav-reg-head:hover { background: color-mix(in srgb, var(--c) 10%, transparent); }
.reg-tile { display: grid; place-items: center; width: 1.85rem; height: 1.85rem; border-radius: .5rem; flex: none; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 78%, #fff) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 75%, #000) 100%);
  box-shadow: 0 3px 10px -3px color-mix(in srgb, var(--c) 70%, transparent); }
.reg-tile svg.icon { width: 1rem; height: 1rem; }
.reg-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.chev { display: grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: .375rem; color: var(--muted-2); transition: transform .2s ease, background .15s; }
.nav-reg-head:hover .chev { background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.nav-reg.closed .chev { transform: rotate(-90deg); }
.nav-reg-items { margin: .1rem 0 .2rem 1.4rem; padding-left: .55rem; border-left: 2px solid color-mix(in srgb, var(--c) 35%, transparent);
  display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s ease; }
.nav-reg.closed .nav-reg-items { display: none; }
.nav-reg-items .nav-item[aria-current] { color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
html.dark .nav-reg-items .nav-item[aria-current] { color: color-mix(in srgb, var(--c) 70%, #fff); }
.nav-reg.admin .reg-tile { background: linear-gradient(135deg, #8a94ad, #525b75); }
@media (min-width: 1024px) {
  html.nav-collapsed .nav-reg-items { margin-left: 0; padding-left: 0; border-left: 0; }
  html.nav-collapsed .nav-reg-head { justify-content: center; padding: .4rem; }
  html.nav-collapsed .nav-heading { display: none; }
}

/* ------------------------------------------------------------ vibrant gradient charts */
svg.bars line.gridline { stroke: var(--hair); stroke-width: 1; stroke-dasharray: 3 4; }
svg.bars line.baseline { stroke: var(--line); stroke-width: 1; }
svg.bars text.bv { font-size: 11px; font-weight: 800; fill: var(--ink); }
svg.bars text.bl { font-size: 10px; font-weight: 600; fill: var(--muted-2); }
svg.bars rect { transition: opacity .15s; } svg.bars rect:hover { opacity: .8; }
.sparkwrap { color: var(--reg, var(--brand)); opacity: 1; }
.sparkwrap.good { color: var(--ok); } .sparkwrap.bad { color: var(--bad); }
.gtrack { height: .55rem; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: .3rem 0 .55rem; }
.gbar { height: .55rem; border-radius: 99px; background: linear-gradient(90deg, var(--brand) 0%, var(--reg, var(--brand)) 100%); }
.mixrow .legendrow { border-bottom: 0; padding-bottom: 0; }
.kpi { background: linear-gradient(180deg, color-mix(in srgb, var(--reg, var(--brand)) 4%, var(--surface)) 0%, var(--surface) 60%); }
.kpi.good { background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 7%, var(--surface)) 0%, var(--surface) 65%); }
.kpi.bad { background: linear-gradient(180deg, color-mix(in srgb, var(--bad) 6%, var(--surface)) 0%, var(--surface) 65%); }
.charthead { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.charthead h4 { margin: 0; flex: 1; }
.seg-switch { display: inline-flex; padding: .15rem; border-radius: .45rem; background: var(--surface-2); border: 1px solid var(--hair); }
.seg-switch button { border: 0; background: none; padding: .25rem .7rem; border-radius: .35rem; font: inherit; font-size: .72rem; font-weight: 700; color: var(--ink3); cursor: pointer; }
.seg-switch button.on { background: var(--surface); color: var(--brand); box-shadow: 0 1px 3px rgba(20, 24, 36, .12); }
table.mini-table td, table.mini-table th { padding: .45rem .75rem; }
table.mini-table td.num, table.mini-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mini-table tr.tot td { font-weight: 800; color: var(--ink); border-top: 1px solid var(--line); }
.secthead { display: flex; align-items: baseline; gap: .75rem; margin: 1.5rem 0 .75rem; flex-wrap: wrap; }
.secthead h3.sect { margin: 0; }
.rtable { margin-bottom: 1rem; }
.iconpick { display: flex; gap: .3rem; flex-wrap: wrap; }
.iconpick label { margin: 0 !important; cursor: pointer; }
.iconpick input { position: absolute; opacity: 0; pointer-events: none; }
.iconpick span { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .45rem; border: 1px solid var(--line); color: var(--ink3); }
.iconpick input:checked + span { border-color: var(--brand); background: var(--brandSoft); color: var(--tint-ink); }

/* ------------------------------------------------------------ top menu: one dropdown per registry */
.topmenu { display: none; align-items: center; gap: .15rem; min-width: 0; }
@media (min-width: 1200px) { .topmenu { display: flex; } .topbar .crumb { display: none; } }
.topmenu-item { display: inline-flex; align-items: center; gap: .4rem; height: 2.25rem; padding: 0 .65rem; border-radius: .45rem; font-size: .8rem; font-weight: 700;
  color: var(--ink2); white-space: nowrap; text-decoration: none; cursor: pointer; list-style: none; transition: background .15s, color .15s; }
.topmenu-item::-webkit-details-marker { display: none; }
.topmenu-item:hover, details.topdrop[open] > .topmenu-item { background: var(--surface-2); color: var(--ink); }
.topmenu-item[aria-current], .topmenu-item.here { color: var(--brand); background: var(--brandSoft); }
.topdrop .topmenu-item.here { color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.reg-dot { display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: .35rem; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c)); }
.reg-dot svg.icon { width: .75rem; height: .75rem; }
.dropdown.left { left: 0; right: auto; min-width: 17rem; }
.drop-head { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem .7rem; margin-bottom: .35rem; border-bottom: 1px solid var(--hair); }
.drop-head b { display: block; color: var(--ink); font-size: .82rem; }
.drop-head .sub { display: block; font-size: .7rem; line-height: 1.3; }
.drop-head .reg-tile { width: 2.1rem; height: 2.1rem; }
/* clickable charts */
a.barlink { cursor: pointer; }
a.barlink:hover rect { opacity: .78; }
a.barlink:hover text.bv { fill: var(--brand); }
a.kpi-link { display: block; text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
a.kpi-link:hover { transform: translateY(-2px); border-color: var(--tint-border); box-shadow: 0 8px 24px -10px rgba(36, 40, 46, .28); }
a.mixrow { display: block; text-decoration: none; color: inherit; border-radius: .375rem; padding: 0 .3rem; margin: 0 -.3rem; }
a.mixrow:hover { background: var(--surface-2); }
a.mixrow:hover .legendrow span:first-child { color: var(--brand); }
a.legendrow { text-decoration: none; color: inherit; border-radius: .25rem; }
a.legendrow:hover { background: var(--surface-2); }
a.pill { text-decoration: none; } a.pill:hover { filter: brightness(.96); }
table.sitecmp td a { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }

/* ------------------------------------------------------------ export: formats and custom export */
.expgrid h4 { display: flex; align-items: center; gap: .45rem; }
.extpill { margin-left: auto; font-size: .68rem; font-weight: 800; color: var(--tint-ink); background: var(--brandSoft); border: 1px solid var(--tint-border); border-radius: .25rem; padding: 0 .35rem; }
.customexp { padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.cx-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .cx-grid { grid-template-columns: 1fr; } }
.cx-step { display: flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--ink); margin: .25rem 0 .6rem; }
.cx-step:not(:first-child) { margin-top: 1.1rem; }
.fmtpick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.fmtpick label { cursor: pointer; }
.fmtpick input { position: absolute; opacity: 0; pointer-events: none; }
.fmtpick span { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .55rem .3rem; border: 1px solid var(--line); border-radius: .45rem;
  color: var(--ink3); text-align: center; transition: border-color .15s, background .15s; }
.fmtpick span b { font-size: .74rem; color: var(--ink); } .fmtpick span small { font-size: .65rem; }
.fmtpick input:checked + span { border-color: var(--brand); background: var(--brandSoft); color: var(--tint-ink); box-shadow: 0 0 0 1px var(--brand); }
.fmtpick input:focus-visible + span { outline: 2px solid var(--brand2); }
.cx-opts { display: flex; flex-direction: column; gap: .1rem; margin-bottom: 1rem; }
.varpick { max-height: 560px; overflow: auto; border: 1px solid var(--hair); border-radius: .5rem; padding: .25rem .75rem; }
.varpick fieldset { border: 0; border-bottom: 1px solid var(--hair); margin: 0; padding: .4rem 0 .6rem; }
.varpick fieldset:last-child { border-bottom: 0; }
.varpick legend { display: flex; align-items: center; gap: .5rem; padding: 0; font-weight: 800; color: var(--ink); }
.varpick legend .checkline { font-weight: 800 !important; }
.varcols { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1rem; padding-left: 1.4rem; }
.varcols .checkline { margin: .15rem 0 !important; font-size: .8rem; align-items: flex-start; }
.varcols .checkline input { margin-top: .2rem; }
.vp.off { opacity: .45; }
.vp .pill { margin-left: .25rem; font-size: .56rem; }

@media print {
  .topbar, .sidenav, .nav-backdrop, .noprint { display: none !important; }
  .page { margin: 0 !important; padding: 0 !important; }
}
.kpi .sparkwrap .spark-empty { display: block; line-height: 1.3; }

/* registry builder: built-in registries */
.btable .ok { color: var(--ok); font-weight: 800; } .btable .bad { color: var(--bad); font-weight: 800; }
.builtin-list { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .25rem 0 .5rem; font-size: .85rem; }
.builtin-list code { font-size: .75rem; }

/* dd/mm/yyyy date boxes (app.js dmy): text box + calendar button; the native input underneath only opens the calendar */
.dmy { position: relative; display: inline-flex; align-items: center; width: 100%; min-width: 9.5rem; }
.dmy.dt { min-width: 12rem; }
.dmy .dmy-text { width: 100%; padding-right: 2.3rem; font-variant-numeric: tabular-nums; }
.dmy .dmy-text.bad { border-color: var(--bad); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bad) 16%, transparent); }
.dmy .dmy-cal { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); z-index: 1; display: grid; place-items: center;
  width: 1.9rem; height: 1.9rem; border: 0; border-radius: .4rem; background: transparent; color: var(--muted); cursor: pointer; }
.dmy .dmy-cal:hover { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.dmy .dmy-cal:disabled { cursor: default; opacity: .5; }
.dmy input[data-dmy] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; padding: 0; border: 0; }
.frange .dmy { width: auto; flex: 1; }
.datefilter .dmy { width: 10.5rem; }
.dobhint { display: block; margin-top: .3rem; font-size: .78rem; color: var(--warn-ink, #b56b00); }

/* registry builder: calculated fields */
.calctable td { vertical-align: top; }
.calctable input[type=text] { width: 100%; }
.calctable input.needs { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
.calctable .calc-desc { margin-top: .3rem; max-width: 32rem; white-space: normal; }
.formula-help { margin: .25rem 0 .75rem; padding: .7rem .9rem; border-radius: .5rem; background: var(--surface-2, var(--surface)); border: 1px solid var(--hair); font-size: .82rem; line-height: 1.7; }
.vcond { color: var(--muted); margin-top: .15rem; overflow-wrap: anywhere; }
.vcond code { font-size: .72rem; }

/* registry builder: form layout */
.layoutlist { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; gap: .35rem; }
.layoutlist li { display: grid; grid-template-columns: 1.2rem 2rem minmax(12rem, 1fr) minmax(0, 18rem) auto; align-items: center; gap: .6rem;
  padding: .35rem .6rem; border: 1px solid var(--hair); border-radius: .5rem; background: var(--surface); }
.layoutlist li.moved { border-color: color-mix(in srgb, var(--brand) 45%, var(--hair)); }
.layoutlist li.dragging { opacity: .45; }
.layoutlist .grip { cursor: grab; color: var(--muted); letter-spacing: -.2em; user-select: none; }
.layoutlist .pos { font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.layoutlist input[type=text] { width: 100%; }
.layoutlist .layout-info { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layoutlist .layout-move { display: inline-flex; gap: .25rem; }
.layoutlist .layout-move .btn { min-height: 1.9rem; padding: .1rem .55rem; }
@media (max-width: 760px) { .layoutlist li { grid-template-columns: 1.2rem 1.6rem 1fr auto; } .layoutlist .layout-info { display: none; } }

/* record form: required questions still empty after "Save as complete" */
.field.missing { outline: 2px solid var(--warn); outline-offset: 4px; border-radius: .4rem; }
.field.missing > label::after { content: " – required"; color: var(--warn-ink); font-weight: 700; font-size: .75rem; }
#dlgB { white-space: pre-line; }

/* new registry: core dataset choice and outline */
.corechoice { display: grid; gap: .5rem; }
.corechoice .choice { display: grid; grid-template-columns: auto 1fr; gap: .6rem; align-items: start; padding: .7rem .85rem; border: 1px solid var(--hair); border-radius: .5rem; cursor: pointer; font-weight: 400; }
.corechoice .choice:has(input:checked) { border-color: var(--brand); background: var(--brandSoft); }
.corechoice .choice input { margin-top: .25rem; }
.corechoice .choice .sub { display: block; margin-top: .2rem; }
.coreoutline { margin: 0; padding-left: 1.3rem; display: grid; gap: .45rem; }
.coreoutline li { padding: .4rem .6rem; border: 1px solid var(--hair); border-radius: .4rem; display: grid; gap: .2rem; }
.coreoutline li.slot { border-style: dashed; }
.coreoutline .corevars { display: flex; flex-wrap: wrap; gap: .25rem; }
.coreoutline code { font-size: .72rem; padding: .05rem .35rem; border-radius: .25rem; background: var(--surface-2); }

/* record form: one section at a time */
#formBody .fsec.step-out { display: none; }
.stephead { padding: .8rem 1.1rem; margin-bottom: 1rem; display: grid; gap: .55rem; }
.stepline { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.stepline .stepcount { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }
.stepline b { color: var(--ink); font-size: 1rem; }
.stepline .grow { flex: 1; }
.stepbar { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.stepbar i { display: block; height: 100%; background: var(--brand); transition: width .25s ease; }
.stepfoot { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: -.25rem 0 1.25rem; }
.stepfoot .grow { flex: 1; min-width: 12rem; }
.secnav a.current { background: var(--brandSoft); color: var(--tint-ink); box-shadow: inset 3px 0 0 var(--brand); border-radius: 0 7px 7px 0; }
.modebtn { font-size: .78rem; padding: .3rem .7rem; min-height: 0; }
@media (prefers-reduced-motion: reduce) { .stepbar i { transition: none; } }

/* Administration → Core dataset */
.coresections { display: grid; gap: .9rem; }
.coresec { padding: .9rem 1.1rem; display: grid; gap: .6rem; }
.coresec.slot { border-style: dashed; background: var(--surface-2); }
.corehead { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.corehead .grip { color: var(--muted); letter-spacing: -.2em; }
.corehead .secname { font-weight: 800; min-width: 16rem; flex: 1 1 16rem; }
.corehead .matchlbl { display: flex; align-items: center; gap: .4rem; flex: 1 1 22rem; }
.corehead .matchlbl input { flex: 1; min-width: 10rem; }
.corehead .grow { flex: 1; }
.coretable td { vertical-align: middle; }
.coretable input[type=text] { width: 100%; min-width: 6rem; }
.coretable tr.sysrow code { color: var(--tint-ink); }
.actions-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.actions-row .grow { flex: 1; }

/* record form: sub-headings inside a step (questions grouped by the dictionary) */
.fields > .subhead { grid-column: 1 / -1; margin: .6rem 0 -.2rem; padding-bottom: .3rem; border-bottom: 1px solid var(--hair);
  font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--tint-ink); }
.fields > .subhead:first-child { margin-top: 0; }
/* record form: narrower columns so short questions sit side by side (e.g. MR No., names, date of birth, age, sex in one row) */
.fsec .fields { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 16px; }
