/*
 * Citadel dashboard application: component stylesheet (CITADEL-DESIGN-SYSTEM.md, section 3).
 * Values come from tokens.css. Strict CSP (style-src 'self', no inline styles). Everything works without script: menus
 * are <details>, the phone drawer is a checkbox, the sidebar collapse state is a cookie set by a POST, the details panel is
 * a URL. The one first-party script (js/app.js) only enhances: menus close on outside click / Escape, the panel opens in
 * place, list navigation keeps the scroll position, the sidebar collapses without a reload.
 * Stability: the scrollbar gutter is always reserved and every app page starts with a breadcrumb row of fixed height,
 * so the top bar, menu, breadcrumb and page title never move between pages.
 * Order: base, shell (top bar, sidebar, drawer), page frame, controls, menus, lists, records, forms, feedback, auth,
 * print, responsive.
 */

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; min-height: 100vh; font: 400 var(--t-14)/1.5 var(--f-sans); color: var(--c-text); background: var(--c-bg); font-feature-settings: "cv11", "ss03"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--c-ink); line-height: 1.3; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.012em; }
h2 { font-size: var(--t-16); font-weight: 600; }
h3 { font-size: var(--t-14); font-weight: 600; }
p { margin: 0; }
a { color: var(--c-accent); text-decoration: none; }
a:hover { color: var(--c-accent-hover); text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
img { max-width: 100%; }
table { border-collapse: collapse; }
code, .mono { font-family: var(--f-mono); font-size: var(--t-13); }
h1.mono { font-size: var(--t-20); }
h2.mono { font-size: var(--t-16); }
hr { border: 0; border-top: 1px solid var(--c-line); margin: var(--s-2) 0; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s-2); top: -60px; z-index: 100; padding: var(--s-2) var(--s-3); background: var(--c-surface); color: var(--c-accent); border-radius: var(--r-md); box-shadow: var(--e-2); }
.skip:focus { top: var(--s-2); }
/* Skip link target: focus lands on main (no ring on the region itself); the next Tab shows the ring on the first control. */
main.page:focus { outline: none; box-shadow: none; }
/* Rings stay visible inside clipping containers (breadcrumb row) and above neighbouring toolbar controls. */
.crumbs a:focus-visible { box-shadow: inset 0 0 0 2px var(--c-accent); }
.cmd:focus-visible, .btn:focus-visible, summary:focus-visible, .topbar-btn:focus-visible { position: relative; z-index: 1; box-shadow: var(--focus); }
.muted { color: var(--c-text-2); }
.faint { color: var(--c-text-3); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.dash { color: var(--c-text-3); }

svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.i.i-20 { width: 20px; height: 20px; }
svg.i.i-14 { width: 14px; height: 14px; }
/* external links (Ui/Ext.cs): a small trailing external-link icon; "(opens in a new tab)" is in hidden text */
svg.i.ext { width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; opacity: .8; }

summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }

/* ============================================================ shell: top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s-3); height: 52px; padding: 0 var(--s-4) 0 var(--s-3); background: var(--c-navy-950); background-image: var(--g-topbar); color: var(--c-on-dark); }
/* product accent rule under the top bar (hub = brand accent); the administration workspace has an amber top rule */
/* a fine highlight line at the top edge (§9) and the product accent rule at the bottom */
.app.accent-hub .topbar { box-shadow: inset 0 1px 0 rgba(127, 176, 255, .22), inset 0 -3px 0 var(--c-accent); }
.app.accent-gate .topbar { box-shadow: inset 0 -3px 0 var(--c-gate); }
.app.accent-frame .topbar { box-shadow: inset 0 -3px 0 var(--c-frame); }
.app.accent-lite .topbar { box-shadow: inset 0 -3px 0 var(--c-lite); }
.app.accent-pen .topbar { box-shadow: inset 0 -3px 0 var(--c-pen); }
.app.is-admin .topbar { box-shadow: inset 0 2px 0 #d9a514; }
.topbar a { color: var(--c-on-dark); }
.topbar a:hover { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-2); border-radius: var(--r-md); font-size: var(--t-16); font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.brand svg.i { width: 22px; height: 22px; color: var(--c-accent-on-dark); }
.brand:hover { background: var(--c-navy-800); }
.topbar > .brand .workspace { margin-left: var(--s-1); }
.app-launcher { justify-content: center; width: 40px; padding: 0; }
.topbar .app-launcher svg.i { color: var(--c-on-dark); }
.menu.menu-products { min-width: 320px; }
.menu-products .mi-text { display: grid; gap: 1px; min-width: 0; white-space: normal; }
.menu-products .mi-text small { color: var(--c-text-3); font-size: var(--t-12); font-weight: 400; }
.menu-products a, .menu-products .menu-item { align-items: flex-start; padding-top: var(--s-2); padding-bottom: var(--s-2); }
.menu-products svg.i { margin-top: 2px; }
.menu .menu-item.is-off { color: var(--c-text-3); cursor: default; }
.menu .menu-item.is-off .mi-text > span { color: var(--c-text-2); }
.menu .menu-item.is-current .mi-text > span { color: var(--c-ink); font-weight: 600; }
.menu .menu-item .check { margin-left: auto; color: var(--c-accent); }
.menu .ext { margin-left: auto; color: var(--c-text-3); }
.workspace { display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s-2); border-left: 1px solid var(--c-navy-700); color: var(--c-on-dark-2); font-size: var(--t-13); font-weight: 500; white-space: nowrap; }
.app.is-admin .workspace { color: #f2c94c; }
.topbar-spacer { flex: 1; }
.topbar-btn, .topbar summary { display: inline-flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-2); border: 0; border-radius: var(--r-md); background: none; color: var(--c-on-dark); font: inherit; font-size: var(--t-13); white-space: nowrap; cursor: pointer; }
.topbar-btn:hover, .topbar summary:hover, .topbar details[open] > summary { background: var(--c-navy-800); }
.topbar-btn svg.i, .topbar summary svg.i { color: var(--c-on-dark-2); }
.topbar .menu-toggle { display: none; }
.org-switch .org-name, .org-current .org-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.topbar .org-current { cursor: default; }
.topbar .org-current:hover { background: none; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--c-navy-700); color: var(--c-on-dark); font-size: var(--t-12); font-weight: 600; flex: none; letter-spacing: .02em; }
/* deterministic avatar hues (Fmt.AvatarTone): calm, brand-adjacent, white text at >= 4.5:1 */
.avatar.av-0 { background: #1d5fd1; } .avatar.av-1 { background: #0f766e; } .avatar.av-2 { background: #6d28d9; } .avatar.av-3 { background: #b45309; }
.avatar.av-4 { background: #be185d; } .avatar.av-5 { background: #1e3a8a; } .avatar.av-6 { background: #047857; } .avatar.av-7 { background: #9a3412; }
.user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================ shell: frame and sidebar (light, CITADEL-DESIGN-SYSTEM §8) */
.frame { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.app.nav-collapsed .frame { grid-template-columns: 60px minmax(0, 1fr); }
.sidebar { background: var(--c-sidebar); color: var(--c-text); border-right: 1px solid var(--c-band-line); }
.sidebar-inner { position: sticky; top: 52px; height: calc(100vh - 52px); display: flex; flex-direction: column; }
.sidebar-toggle { margin: 0; padding: var(--s-2) var(--s-2) var(--s-1); }
.nav-toggle { display: grid; place-items: center; width: 44px; height: 40px; border: 0; border-radius: var(--r-md); background: none; color: var(--c-text); cursor: pointer; }
.nav-toggle:hover { background: #e5e7eb; color: var(--c-ink); }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 0 var(--s-4); scrollbar-color: var(--c-line-2) transparent; }
.nav-item { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: 40px; margin: 1px var(--s-2); padding: 0 var(--s-3); border-radius: var(--r-md); color: var(--c-text); font-size: var(--t-14); line-height: 1.3; }
.nav-item svg.i { width: 20px; height: 20px; color: var(--c-text-2); }
.nav-item > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar a.nav-item:hover, .sidebar summary.nav-item:hover { background: #e8ecf5; color: var(--c-ink); text-decoration: none; }
.nav-item, .btn, .cmd, .table td, .task-list a, .section, .chip, .tabs a { transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-fast) ease; }
.nav-item.is-current { background: var(--c-surface); color: var(--c-ink); font-weight: 600; box-shadow: var(--e-1); }
.nav-item.is-current::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--c-accent); }
.nav-item.is-current svg.i { color: var(--c-accent); }
.nav-item .ext { margin-left: auto; width: 14px; height: 14px; }
.nav-parent .chev { margin-left: auto; width: 16px; height: 16px; transition: transform .15s ease; }
.nav-group[open] > .nav-parent .chev { transform: rotate(180deg); }
.nav-parent.has-current { color: var(--c-ink); font-weight: 600; }
.nav-child { padding-left: 44px; }
.nav-child svg.i:first-child { display: none; }

/* collapsed rail: icons only; the server renders every group open, sub-items show their own icons */
.app.nav-collapsed .sidebar-toggle { padding-left: var(--s-2); }
.app.nav-collapsed .nav-item { justify-content: center; padding: 0; }
.app.nav-collapsed .nav-item > span, .app.nav-collapsed .nav-item .ext, .app.nav-collapsed .nav-parent .chev { display: none; }
.app.nav-collapsed .nav-parent { min-height: 12px; height: 12px; pointer-events: none; }
.app.nav-collapsed .nav-parent svg.i { display: none; }
.app.nav-collapsed .nav-parent::after { content: ""; width: 24px; border-top: 1px solid var(--c-line-2); }
.app.nav-collapsed .nav-child svg.i:first-child { display: block; }

.drawer-toggle { position: absolute; opacity: 0; pointer-events: none; }
.drawer-backdrop { display: none; }

/* ============================================================ page frame */
.page { min-width: 0; padding: var(--s-4) var(--s-6) var(--s-12); }
.page-narrow { max-width: 880px; }
.crumbs { min-height: 28px; }
.crumbs ol { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--s-1); height: 20px; margin: 0 0 var(--s-2); padding: 0; overflow: hidden; list-style: none; color: var(--c-text-3); font-size: var(--t-13); line-height: 20px; white-space: nowrap; }
.crumbs li { display: inline-flex; align-items: center; gap: var(--s-1); min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--c-line-2); margin-right: var(--s-1); }
.crumbs a { color: var(--c-text-2); }
.crumbs [aria-current] { color: var(--c-text); max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* page header band (§9): a very subtle tinted band with a crisp edge */
.page-head { display: flex; align-items: flex-start; gap: var(--s-4); min-height: 48px; margin-bottom: var(--s-4); padding: var(--s-4) var(--s-5); background: linear-gradient(120deg, #ffffff 0%, #f4f7fd 55%, #ebf1fc 100%); border: 1px solid #dde5f2; border-left: 3px solid var(--c-accent); border-radius: var(--r-lg); box-shadow: var(--e-1); }
main[aria-busy="true"] { cursor: progress; }
.page-head-text { flex: 1; min-width: 0; }
.page-head h1 { overflow-wrap: anywhere; }
.page-head p { margin-top: 2px; color: var(--c-text-2); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2); }
.page-actions form { margin: 0; }
.stack { display: grid; gap: var(--s-4); }
.cols { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.cols-main { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.cols > *, .cols-main > * { min-width: 0; }

/* ============================================================ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: var(--ctl-h); padding: 0 var(--s-3); border: 1px solid var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: 500 var(--t-14)/1 var(--f-sans); white-space: nowrap; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--c-surface-2); border-color: #b8bec8; color: var(--c-ink); text-decoration: none; }
.btn svg.i { color: currentColor; }
.btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: #fff; }
.btn-danger { background: var(--c-surface); border-color: #e6a39d; color: var(--c-bad); }
.btn-danger:hover { background: var(--c-bad-bg); border-color: var(--c-bad); color: var(--c-bad); }
.btn-danger.is-solid { background: var(--c-bad); border-color: var(--c-bad); color: #fff; }
.btn-danger.is-solid:hover { background: #912018; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--c-muted-bg); border-color: transparent; }
.btn-sm { height: 28px; padding: 0 var(--s-2); font-size: var(--t-13); }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-link { padding: 0; border: 0; background: none; color: var(--c-accent); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-block { width: 100%; height: auto; min-height: var(--ctl-h); padding-top: 6px; padding-bottom: 6px; white-space: normal; text-align: center; line-height: 1.3; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: 11px; background: var(--c-muted-bg); color: var(--c-muted); font-size: var(--t-12); font-weight: 600; line-height: 1; white-space: nowrap; box-shadow: inset 0 0 0 1px rgba(16, 24, 40, .06); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.is-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.chip.is-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.chip.is-bad { background: var(--c-bad-bg); color: var(--c-bad); }
.chip.is-info { background: var(--c-info-bg); color: var(--c-info); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--c-line-2); border-radius: var(--r-sm); color: var(--c-text-2); font-size: var(--t-12); font-weight: 500; white-space: nowrap; }

/* ============================================================ menus (<details> dropdowns) */
details.dd { position: relative; display: inline-block; }
details.dd > summary { display: inline-flex; }
.menu { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 200px; max-width: min(340px, calc(100vw - 24px)); padding: var(--s-1) 0; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-3); color: var(--c-text); text-align: left; white-space: normal; }
.menu.is-right { left: auto; right: 0; }
.menu a:not(.btn), .menu button:not(.btn), .menu .menu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 34px; padding: var(--s-1) var(--s-3); border: 0; background: none; color: var(--c-text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap; }
.menu a:not(.btn):hover, .menu button:not(.btn):hover { background: var(--c-surface-2); color: var(--c-ink); text-decoration: none; }
.menu a:not(.btn) svg.i, .menu button:not(.btn) svg.i { color: var(--c-text-3); }
.menu a[aria-current], .menu a.is-on { font-weight: 600; }
.menu a .check { margin-left: auto; color: var(--c-accent); }
.menu .is-danger, .menu .is-danger svg.i { color: var(--c-bad); }
.menu form { margin: 0; }
.menu-label { padding: var(--s-2) var(--s-3) var(--s-1); color: var(--c-text-3); font-size: var(--t-12); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.menu-head { display: grid; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--c-line); margin-bottom: var(--s-1); }
.menu-head strong { color: var(--c-ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.menu-head small { color: var(--c-text-2); font-size: var(--t-13); overflow: hidden; text-overflow: ellipsis; }
.menu .menu-note { padding: var(--s-1) var(--s-3) var(--s-2); color: var(--c-text-3); font-size: var(--t-13); white-space: normal; }
.menu-panel { padding: var(--s-3); min-width: 300px; }

/* ============================================================ sections and lists */
.section { background: var(--c-surface); border: 1px solid #e3e7ef; border-radius: var(--r-lg); box-shadow: var(--e-1); min-width: 0; }
/* section icons sit in soft brand-tinted tiles (§9) */

.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s-3); min-height: 48px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.section-head h2 { flex: 1 1 auto; min-width: min(100%, 160px); }
.section-head .sub { color: var(--c-text-3); font-size: var(--t-13); font-weight: 400; }
.section-head .link { font-size: var(--t-13); white-space: nowrap; }
.section-body { padding: var(--s-4); }
.section-body > * + * { margin-top: var(--s-3); }
.section-body > .stack + .stack { padding-top: var(--s-3); border-top: 1px solid var(--c-line); }
.section-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-line); color: var(--c-text-2); font-size: var(--t-13); }
.section.is-danger { border-color: #f1c4bf; }
.section.is-danger .section-head { border-bottom-color: #f1c4bf; }
.section.is-danger .section-head h2 { color: var(--c-bad); }

.kv { display: grid; grid-template-columns: minmax(140px, 34%) minmax(0, 1fr); margin: 0; }
.kv > dt, .kv > dd { margin: 0; padding: 10px var(--s-4); border-top: 1px solid var(--c-line); }
.kv > dt:first-of-type, .kv > dt:first-of-type + dd { border-top: 0; }
.kv > dt { color: var(--c-text-2); font-size: var(--t-13); font-weight: 500; }
.kv > dd { color: var(--c-text); overflow-wrap: anywhere; }
.section-body .kv > dt, .section-body .kv > dd { padding-left: 0; padding-right: 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.toolbar form { margin: 0; }
.toolbar .grow { flex: 1; }
.search { position: relative; display: flex; align-items: center; flex: 0 1 320px; min-width: 200px; }
.search svg.i { position: absolute; left: 10px; color: var(--c-text-3); pointer-events: none; }
.search input { width: 100%; height: var(--ctl-h); padding: 0 var(--s-3) 0 32px; border: 1px solid var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: inherit; }
.search input:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.toolbar-form { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--c-line); background: var(--c-surface-2); font-size: var(--t-13); }
.filters-label { color: var(--c-text-3); }
.fchip { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 2px 0 var(--s-2); border: 1px solid #b9cdf3; border-radius: 13px; background: var(--c-accent-soft); color: var(--c-ink); }
.fchip b { font-weight: 600; }
.fchip a { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--c-text-2); }
.fchip a:hover { background: #cfdcf6; color: var(--c-ink); }
.fchip svg.i { width: 14px; height: 14px; vertical-align: 0; }

.table-wrap { position: relative; min-width: 0; } /* contains absolutely positioned descendants (e.g. .sr) inside the scroll region */
.table { width: 100%; background: var(--c-surface); }
.table th, .table td { height: var(--row-h); padding: 6px var(--s-3); border-bottom: 1px solid var(--c-line); text-align: left; vertical-align: middle; }
.table th { position: sticky; top: 52px; z-index: 5; height: 38px; background: var(--c-surface-2); color: var(--c-text-2); font-size: var(--t-13); font-weight: 600; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: var(--s-4); }
.table th:last-child, .table td:last-child { padding-right: var(--s-4); }
.table tbody tr:hover td { background: var(--c-row-hover); }
.table td { font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th a { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.table th a:hover { color: var(--c-ink); text-decoration: none; }
.table th a svg.i { width: 14px; height: 14px; color: var(--c-text-3); }
.table th[aria-sort] { color: var(--c-ink); }
.table th[aria-sort] a svg.i { color: var(--c-accent); }
.table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.is-num a { flex-direction: row-reverse; }
.table .cell-main { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.table .cell-main > div { min-width: 0; }
.table .cell-sub { display: block; color: var(--c-text-3); font-size: var(--t-13); }
.table .col-actions { width: 52px; text-align: right; }
.table td.wrap { white-space: normal; min-width: 200px; max-width: 420px; overflow-wrap: anywhere; }
.table .nowrap { white-space: nowrap; }
.table a.row-link { font-weight: 500; }
.row-menu > summary { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-md); color: var(--c-text-2); }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--c-muted-bg); color: var(--c-ink); }
.table-empty td { height: auto; padding: 0; }

.list-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--c-line); color: var(--c-text-2); font-size: var(--t-13); }
.list-foot .grow { flex: 1; }
.pager { display: inline-flex; align-items: center; gap: var(--s-1); }
.page-size { display: inline-flex; align-items: center; gap: 2px; }
.page-size a, .page-size span { display: inline-grid; place-items: center; min-width: 32px; height: 26px; padding: 0 6px; border-radius: var(--r-sm); color: var(--c-text-2); }
.page-size a:hover { background: var(--c-muted-bg); text-decoration: none; }
.page-size [aria-current] { background: var(--c-accent-soft); color: var(--c-accent); font-weight: 600; }

.activity { margin: 0; padding: 0; list-style: none; }
.activity li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: var(--s-3); align-items: start; padding: 10px var(--s-4); border-top: 1px solid var(--c-line); }
.activity li:first-child { border-top: 0; }
.activity-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--c-muted-bg); color: var(--c-text-2); }
.activity-icon.is-bad { background: var(--c-bad-bg); color: var(--c-bad); }
.activity-icon.is-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.activity-title { color: var(--c-ink); font-weight: 500; overflow-wrap: anywhere; }
.activity-meta { color: var(--c-text-3); font-size: var(--t-13); overflow-wrap: anywhere; }
.activity time { color: var(--c-text-3); font-size: var(--t-13); white-space: nowrap; }

/* command bar above a list (§8): icon+text commands, More, filter and search on the right */
.cmdbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); min-height: 52px; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--c-line); }
.cmdbar form { margin: 0; }
.cmdbar-fill { flex: 1; }
.cmd { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-h); padding: 0 var(--s-2); border: 0; border-radius: var(--r-md); background: none; color: var(--c-text); font: 500 var(--t-14)/1 var(--f-sans); white-space: nowrap; cursor: pointer; text-decoration: none; }
.cmd svg.i { width: 18px; height: 18px; color: var(--c-accent); }
.cmd:hover, details[open] > summary.cmd { background: var(--c-muted-bg); color: var(--c-ink); text-decoration: none; }
.cmd.is-danger, .cmd.is-danger svg.i { color: var(--c-bad); }
.cmd-search { position: relative; display: flex; align-items: center; flex: 0 1 280px; min-width: 200px; }
.cmd-search svg.i { position: absolute; left: 10px; color: var(--c-text-3); pointer-events: none; }
.cmd-search input { width: 100%; height: var(--ctl-h); padding: 0 var(--s-3) 0 32px; border: 1px solid var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: inherit; }
.cmd-search input:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.table tr.is-selected td { background: var(--c-accent-soft); }

/* right-side details panel (§8): server-rendered from ?panel=<id>, closes back to the list URL */
/* the backdrop covers the content area only: a click on the left menu navigates at once (not "close the panel first") */
.panel-backdrop { position: fixed; inset: 52px 0 0 248px; z-index: 55; background: rgba(16, 24, 40, .18); }
.app.nav-collapsed .panel-backdrop { left: 60px; }
@media (max-width: 1023px) { .panel-backdrop, .app.nav-collapsed .panel-backdrop { left: 0; } }
.panel { position: fixed; top: 52px; right: 0; bottom: 0; z-index: 60; display: flex; flex-direction: column; width: min(560px, 100vw); overflow-y: auto; background: var(--c-surface); border-left: 1px solid var(--c-line); box-shadow: var(--e-3); }
.panel:focus { outline: none; }
.panel-top { display: flex; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--c-line); }
.panel-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5) var(--s-3); }
.panel-id { min-width: 0; }
.panel-head h2 { font-size: var(--t-20); overflow-wrap: anywhere; }
.panel-avatar { width: 44px; height: 44px; font-size: var(--t-16); background: var(--c-accent-soft); color: var(--c-accent); }
.panel-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-3); margin: 0; padding: 0 var(--s-5) var(--s-3); }
.panel-facts dt { color: var(--c-text-3); font-size: var(--t-12); font-weight: 500; }
.panel-facts dd { margin: 2px 0 0; color: var(--c-ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* full value in the title */
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0 var(--s-5) var(--s-3); }
.panel-actions form { margin: 0; }
.panel-tabs { margin: 0; padding: 0 var(--s-4); }
.panel-body { flex: 1; padding: var(--s-4) var(--s-5) var(--s-8); }
.panel-body > * + * { margin-top: var(--s-4); }
.panel-body .kv > dt, .panel-body .kv > dd { padding-left: 0; padding-right: 0; }

/* overview: work queue rows (what needs doing, linking into filtered lists) */
.queue { margin: 0; padding: 0; list-style: none; }
.queue li { border-top: 1px solid var(--c-line); }
.queue li:first-child { border-top: 0; }
.queue a, .queue .queue-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 16px; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); color: var(--c-text); }
.queue a:hover { background: var(--c-surface-2); text-decoration: none; }
.queue .queue-row { grid-template-columns: 20px minmax(0, 1fr) auto; }
.queue-title { color: var(--c-ink); font-weight: 500; }
.queue-text { display: block; color: var(--c-text-2); font-size: var(--t-13); }
.queue .queue-icon { color: var(--c-text-3); }
.queue .is-warn .queue-icon { color: var(--c-warn); }
.queue .is-bad .queue-icon { color: var(--c-bad); }
.queue .is-ok .queue-icon { color: var(--c-ok); }
.queue .chev-r { color: var(--c-text-3); }

/* usage bar (seats used of the quota), drawn in SVG so no inline width style is needed */
.usage { display: grid; gap: 6px; }
.usage-line { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--t-13); color: var(--c-text-2); }
.usage-line b { color: var(--c-ink); font-weight: 600; }
.usage svg { width: 100%; height: 8px; }
.usage .track { fill: var(--c-muted-bg); }
.usage .fill { fill: var(--c-accent); }
.usage .fill.is-warn { fill: #c98a00; }
.usage .fill.is-bad { fill: var(--c-bad); }

/* ============================================================ records */
.record-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-3); padding: var(--s-4) var(--s-5); background: linear-gradient(120deg, #ffffff 0%, #f4f7fd 55%, #ebf1fc 100%); border: 1px solid #dde5f2; border-left: 3px solid var(--c-accent); border-radius: var(--r-lg); box-shadow: var(--e-1); }
.record-id { display: flex; align-items: center; gap: var(--s-3); flex: 1 1 320px; min-width: 0; }
.record-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-lg); background: var(--c-accent-soft); color: var(--c-accent); flex: none; }
.record-icon svg.i { width: 22px; height: 22px; }
.record-type { color: var(--c-text-3); font-size: var(--t-13); }
.record-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.record-title h1 { overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 var(--s-4); padding: var(--s-3) 0; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); }
.facts > div { min-width: 140px; padding: 0 var(--s-4); border-left: 1px solid var(--c-line); }
.facts > div:first-child { border-left: 0; }
.facts dt { color: var(--c-text-3); font-size: var(--t-12); font-weight: 500; }
.facts dd { margin: 2px 0 0; color: var(--c-ink); font-weight: 600; white-space: nowrap; }
.tabs { display: flex; gap: var(--s-1); margin: 0 0 var(--s-4); border-bottom: 1px solid var(--c-line); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 var(--s-3); border-bottom: 2px solid transparent; color: var(--c-text-2); font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--c-ink); text-decoration: none; border-bottom-color: var(--c-line-2); }
.tabs a[aria-current] { color: var(--c-ink); border-bottom-color: var(--c-accent); font-weight: 600; }
.tabs .count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--c-muted-bg); color: var(--c-text-2); font-size: var(--t-12); line-height: 18px; text-align: center; }

.secret-box { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid #b9cdf3; border-radius: var(--r-md); background: var(--c-accent-soft); }
.secret { width: fit-content; max-width: 100%; margin: 0; padding: var(--s-2) var(--s-3); border: 1px dashed var(--c-line-2); border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-ink); font: 600 var(--t-16)/1.4 var(--f-mono); letter-spacing: .04em; overflow-wrap: anywhere; user-select: all; }
.reveal > summary { display: inline-flex; align-items: center; gap: var(--s-2); }
.reveal[open] > summary .when-closed, .reveal:not([open]) > summary .when-open { display: none; }
.reveal > .secret { margin-top: var(--s-2); }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: var(--s-1) var(--s-6); margin: 0; padding: var(--s-3) var(--s-4); list-style: none; border: 1px dashed var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); font: 600 var(--t-16)/1.6 var(--f-mono); user-select: all; }

/* ============================================================ forms */
.form { display: grid; gap: var(--s-4); max-width: 560px; }
.form.is-wide { max-width: none; }
.form-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label, fieldset.field > legend { color: var(--c-ink); font-size: var(--t-13); font-weight: 500; }
fieldset.field { margin: 0; padding: 0; border: 0; }
fieldset.is-locked { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.is-locked:disabled { opacity: .6; }
fieldset.is-locked:disabled .input, fieldset.is-locked:disabled .select, fieldset.is-locked:disabled .btn { cursor: not-allowed; }
.input, .select, .textarea { width: 100%; min-height: var(--ctl-h); padding: 6px 10px; border: 1px solid var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text); font: inherit; }
.textarea { min-height: 84px; resize: vertical; }
.select { padding-right: 28px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.input[readonly] { background: var(--c-surface-2); color: var(--c-text-2); }
.input[aria-invalid="true"] { border-color: var(--c-bad); }
.input.is-short { max-width: 160px; }
.input.is-code { font: 600 var(--t-18)/1 var(--f-mono); letter-spacing: .2em; max-width: 220px; }
.help { color: var(--c-text-2); font-size: var(--t-13); }
.field-error { color: var(--c-bad); font-size: var(--t-13); font-weight: 500; }
.check { display: flex; align-items: flex-start; gap: var(--s-2); color: var(--c-text); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--c-accent); flex: none; }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding-top: var(--s-2); }
.section-body .form-foot.is-bar, .form-foot.is-bar { margin: 0 calc(-1 * var(--s-4)) calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-line); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-2); }
.inline-form .field { flex: 0 1 260px; }
.error-summary { padding: var(--s-3) var(--s-4); border: 1px solid #f1c4bf; border-left: 4px solid var(--c-bad); border-radius: var(--r-md); background: var(--c-bad-bg); color: var(--c-ink); }
.error-summary h2 { margin-bottom: 2px; color: var(--c-bad); font-size: var(--t-14); }
.error-summary ul { margin: var(--s-1) 0 0; padding-left: var(--s-5); }
.stepup { display: grid; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid #ecd28f; border-radius: var(--r-md); background: var(--c-warn-bg); }
.stepup-title { display: flex; align-items: center; gap: var(--s-2); color: var(--c-ink); font-weight: 600; }
.confirm > summary { display: inline-flex; }
.confirm-panel { display: grid; gap: var(--s-3); margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface-2); }

/* ============================================================ feedback */
.alerts { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.alert { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: 1px solid var(--c-line); border-left-width: 4px; border-radius: var(--r-md); background: var(--c-surface); color: var(--c-ink); }
.alert svg.i { margin-top: 1px; }
.alert > div { flex: 1; min-width: 0; }
.alert.is-ok { border-color: #b7dfc5; border-left-color: var(--c-ok); background: var(--c-ok-bg); }
.alert.is-ok svg.i { color: var(--c-ok); }
.alert.is-warn { border-color: #ecd28f; border-left-color: #c98a00; background: var(--c-warn-bg); }
.alert.is-warn svg.i { color: var(--c-warn); }
.alert.is-bad { border-color: #f1c4bf; border-left-color: var(--c-bad); background: var(--c-bad-bg); }
.alert.is-bad svg.i { color: var(--c-bad); }
.alert.is-info { border-color: #b9cdf3; border-left-color: var(--c-accent); background: var(--c-info-bg); }
.alert.is-info svg.i { color: var(--c-info); }
.alert a { font-weight: 500; }

.state { display: grid; justify-items: start; gap: var(--s-2); padding: var(--s-6) var(--s-4); color: var(--c-text-2); }
/* illustrated empty states (§9): the state icon in a brand-tinted ring with a dashed outer line */
.state-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent); box-shadow: 0 0 0 6px #fff, 0 0 0 7px #d6e3fb; margin: 2px 0 var(--s-1) 7px; }
.state-icon svg.i { width: 24px; height: 24px; stroke-width: 1.5; }
.state.is-bad .state-icon { background: var(--c-bad-bg); color: var(--c-bad); }
.state.is-warn .state-icon { background: var(--c-warn-bg); color: var(--c-warn); }
.state h2, .state h3 { color: var(--c-ink); font-size: var(--t-14); }
.state p { max-width: 560px; }
.state .btn { margin-top: var(--s-1); }
.state.is-page { justify-items: center; text-align: center; padding: var(--s-16) var(--s-4); }
.state.is-page h1 { font-size: var(--t-20); }
.loading { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--c-text-2); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading svg.i { animation: spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { .loading svg.i, .nav-parent .chev, .sidebar { animation: none; transition: none; } }

/* ============================================================ authentication */
.auth-page { display: flex; flex-direction: column; min-height: 100vh; background: var(--c-bg); }
.auth-bar { display: flex; align-items: center; height: 52px; padding: 0 var(--s-4); background: var(--c-navy-950); }
.auth-bar .brand { color: var(--c-on-dark); }
.auth-bar .brand:hover { background: none; }
.auth-main { flex: 1; display: grid; place-items: start center; padding: var(--s-12) var(--s-4) var(--s-8); }
.auth-card { width: 100%; max-width: 420px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--e-2); }
.auth-card.is-wide { max-width: 560px; }
.auth-head { padding: var(--s-6) var(--s-6) 0; }
.auth-head h1 { font-size: var(--t-20); }
.auth-head p { margin-top: var(--s-1); color: var(--c-text-2); }
.auth-body { display: grid; gap: var(--s-4); padding: var(--s-5) var(--s-6) var(--s-6); }
.auth-body form { display: grid; gap: var(--s-4); }
.auth-body .btn-primary { height: 40px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2); font-size: var(--t-13); }
.auth-foot { padding: var(--s-3) var(--s-6); border-top: 1px solid var(--c-line); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); color: var(--c-text-2); font-size: var(--t-13); }
.auth-step { color: var(--c-text-3); font-size: var(--t-12); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.auth-legal { padding: var(--s-4); color: var(--c-text-3); font-size: var(--t-13); text-align: center; }
.auth-legal a { color: var(--c-text-2); }
.mfa-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.qr { display: block; width: 180px; height: 180px; padding: var(--s-2); border: 1px solid var(--c-line); border-radius: var(--r-md); background: #fff; image-rendering: pixelated; }
.steps { display: grid; gap: var(--s-4); margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps > li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s-3); counter-increment: step; }
.steps > li::before { content: counter(step); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--c-accent-soft); color: var(--c-accent); font-size: var(--t-13); font-weight: 600; }
.steps > li > div { display: grid; gap: var(--s-2); min-width: 0; }

/* ============================================================ invoice */
.invoice { padding: var(--s-6); }
.invoice-parties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); margin: var(--s-4) 0 var(--s-6); }
.invoice-parties h3 { margin-bottom: var(--s-1); color: var(--c-text-3); font-size: var(--t-12); text-transform: uppercase; letter-spacing: .06em; }
.invoice .table th { position: static; }
.invoice .totals td { font-weight: 600; }

@media print {
  .topbar, .sidebar, .crumbs, .page-actions, .noprint, .alerts, .skip, .panel, .panel-backdrop, .cmdbar { display: none; }
  body, .page { background: #fff; padding: 0; }
  .frame { display: block; }
  .section { border: 0; box-shadow: none; }
}

/* ============================================================ responsive */
@media (max-width: 1100px) {
  .cols-main { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { overflow-x: auto; }
  .table th { position: static; }
  .table th, .table td { white-space: nowrap; }
  .table td.wrap { white-space: normal; min-width: 220px; }
}
@media (max-width: 900px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .invoice-parties { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
}
@media (max-width: 1023px) {
  .frame, .app.nav-collapsed .frame { grid-template-columns: minmax(0, 1fr); }
  .topbar .menu-toggle { display: inline-flex; width: 44px; height: 44px; justify-content: center; padding: 0; }
  .sidebar { position: fixed; top: 52px; left: 0; bottom: 0; z-index: 50; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar-inner { position: static; height: 100%; }
  .drawer-toggle:checked ~ .frame .sidebar { transform: none; box-shadow: var(--e-3); }
  .drawer-toggle:checked ~ .frame .drawer-backdrop { display: block; position: fixed; inset: 52px 0 0 0; z-index: 45; background: rgba(10, 20, 38, .45); }
  .drawer-toggle:focus-visible ~ .topbar .menu-toggle { box-shadow: var(--focus); }
  .sidebar-toggle { display: none; }
  /* the drawer always shows labels, even when the desktop rail is collapsed */
  .app.nav-collapsed .nav-item { justify-content: flex-start; padding: 0 var(--s-3); }
  .app.nav-collapsed .nav-child { padding-left: 44px; }
  .app.nav-collapsed .nav-item > span, .app.nav-collapsed .nav-parent .chev { display: revert; }
  .app.nav-collapsed .nav-parent { min-height: 40px; height: auto; pointer-events: auto; }
  .app.nav-collapsed .nav-parent svg.i { display: revert; }
  .app.nav-collapsed .nav-parent::after { content: none; }
  .app.nav-collapsed .nav-child svg.i:first-child { display: none; }
}
@media (max-width: 767px) {
  .topbar { padding: 0 var(--s-2); gap: var(--s-1); }
  .workspace, .user-name, .topbar .hide-sm, .topbar > .brand > span { display: none; }
  /* phones: the organisation switcher gives way first, so the bell and the account menu always stay on screen
     (several organisations + unread badge overflowed by 22-26 px at 390 px) */
  .org-switch { flex: 0 1 auto; min-width: 0; }
  .org-switch > summary { max-width: 100%; }
  .org-switch > summary > svg.i:first-child { display: none; }
  .org-switch .org-name { flex: 0 1 auto; min-width: 0; max-width: 22vw; }
  .topbar-spacer { min-width: 0; }
  .user-menu > summary > svg.i { display: none; }
  .topbar summary, .topbar-btn { padding: 0 6px; }
  .nav-item { min-height: 44px; }
  .page { padding: var(--s-3) var(--s-3) var(--s-8); }
  .page-head { flex-direction: column; gap: var(--s-3); }
  .page-actions { justify-content: flex-start; }
  .btn { height: var(--ctl-h-touch); }
  .btn-sm { height: 36px; }
  .btn-icon { width: var(--ctl-h-touch); }
  .row-menu > summary { width: 44px; height: 44px; }
  .input, .select { min-height: var(--ctl-h-touch); font-size: var(--t-16); }
  .search, .cmd-search { flex: 1 1 100%; }
  .cmd { height: var(--ctl-h-touch); }
  .cmd-search input { height: var(--ctl-h-touch); font-size: var(--t-16); }
  .panel-head, .panel-facts, .panel-actions, .panel-body { padding-left: var(--s-4); padding-right: var(--s-4); }
  .search input { height: var(--ctl-h-touch); font-size: var(--t-16); }
  .toolbar { padding: var(--s-3); }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > dt { padding-bottom: 0; }
  .kv > dd { border-top: 0; padding-top: 2px; }
  .facts > div { flex: 1 1 45%; padding: var(--s-2) var(--s-3); border-left: 0; }
  .mfa-setup { grid-template-columns: minmax(0, 1fr); }
  .auth-main { padding: var(--s-6) var(--s-3); }
  .auth-head { padding: var(--s-5) var(--s-4) 0; }
  .auth-body { padding: var(--s-4); }
  .menu a:not(.btn), .menu button:not(.btn) { min-height: 44px; }
  .list-foot { gap: var(--s-2); }
}

/* ============================================================ page block rhythm */
.page > .cols, .page > .cols-main, .page > .section, .page > .stack, .page > form.section { margin-bottom: var(--s-4); }
.page > .tabs { margin-top: var(--s-2); }

/* the drawer checkbox only exists for the phone layout (keyboard: Space toggles it there) */
@media (min-width: 1024px) { .drawer-toggle { display: none; } }

/* home: a grid of task panels (§8), each a short list with its actions; no stat tiles */
.task-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
.task.is-wide { grid-column: 1 / -1; }
.task { display: flex; flex-direction: column; }
.task .section-head h2 { display: flex; align-items: center; gap: var(--s-2); }
.task .section-head h2 svg.i { width: 20px; height: 20px; color: var(--c-accent); }
.task-list { margin: 0; padding: 0; list-style: none; }
.task-list li { border-top: 1px solid var(--c-line); }
.task-list li:first-child { border-top: 0; }
.task .section-body + .task-list li:first-child { border-top: 1px solid var(--c-line); }
.task-sub { border-top: 1px solid var(--c-line); }
.task-sub h3 { margin: 0; padding: var(--s-3) var(--s-4) var(--s-1); color: var(--c-ink); font-size: var(--t-14); font-weight: 600; }
.task-sub h3 .sub { color: var(--c-text-3); font-size: var(--t-12); font-weight: 400; }
.task-sub > p { margin: 0; padding: 0 var(--s-4) var(--s-3); font-size: var(--t-13); }
.task-list a { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-2) var(--s-4); color: var(--c-text); }
.task-list a:hover { background: var(--c-surface-2); text-decoration: none; }
.task-list a > svg.i { color: var(--c-text-3); }
.tl-main { display: grid; flex: 1; min-width: 0; color: var(--c-ink); font-weight: 500; overflow-wrap: anywhere; }
.tl-main small { color: var(--c-text-3); font-size: var(--t-13); font-weight: 400; }
.task-actions { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: auto; padding: var(--s-2) var(--s-3); border-top: 1px solid var(--c-line); }
@media (max-width: 767px) { .task-grid { grid-template-columns: minmax(0, 1fr); } }
.panel-actions { align-items: flex-end; }
.panel-actions .inline-form { flex-wrap: nowrap; }
.panel-actions .inline-form .field { flex: 0 1 200px; min-width: 120px; }
/* ============================================================ notifications and admin lists (admin/data work stream) */
.topbar-btn .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-accent); color: #fff; font-size: var(--t-12); font-weight: 600; line-height: 18px; text-align: center; }
.activity li.is-unread { background: var(--c-accent-soft); }
.activity li.is-unread .activity-title { font-weight: 600; }
.activity-icon.is-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.activity-icon.is-info { background: var(--c-info-bg); color: var(--c-info); }
/* admin record facts can hold long emails and names: never push the page wider than the screen */
.app.is-admin .facts > div { max-width: 100%; }
.app.is-admin .facts dd { overflow: hidden; text-overflow: ellipsis; }
/* admin command bar additions: the Filter menu holds real filter fields (selects, dates, text) and an Apply button */
.cmd.is-primary { color: var(--c-accent); font-weight: 600; }
.cmd-filter .menu-panel { min-width: 280px; display: grid; gap: var(--s-3); }
.cmd-filter .menu-panel .form-foot { padding-top: 0; }

/* ============================================================ one-time code boxes (js/app.js over one real input) */
/* the boxes share the width they are given (never wider than the field, so a button beside them stays clear) */
.otp { position: relative; display: block; width: 100%; max-width: 320px; }
.otp-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-2); }
.otp-box { display: grid; place-items: center; min-width: 0; height: 52px; border: 1px solid var(--c-line-2); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-ink); font: 600 var(--t-20)/1 var(--f-mono); }
.otp-box.is-filled { border-color: var(--c-text-3); }
.otp-box.is-active { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); }
.otp-input.input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; background: transparent; color: transparent; caret-color: transparent; font-size: 16px; letter-spacing: 40px; box-shadow: none; }
.otp-input.input:focus-visible { box-shadow: none; }
.otp:focus-within .otp-boxes { outline: none; }
.otp-input::selection { background: transparent; }
@media (max-width: 400px) { .otp-box { height: 48px; } .otp-boxes { gap: 6px; } }

/* ============================================================ §9 premium layer: hover lift and motion */
.task-list a:hover { background: var(--c-row-hover); }
.section.task:hover { box-shadow: var(--e-2); }
.btn-primary { box-shadow: 0 1px 2px rgba(29, 95, 209, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .nav-item, .btn, .cmd, .table td, .task-list a, .section, .chip, .tabs a { transition: none; } .btn:active { transform: none; } }
.table tr.is-addon td { background: var(--c-surface-2); }
.addon-indent { color: var(--c-text-3); padding-left: var(--s-2); }

/* §9 depth: distinct card headers and brand-tinted icon tiles (placed last: they refine the section rules above) */
.section > .section-head { background: linear-gradient(180deg, #fcfdff 0%, #f5f7fb 100%); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.section > .section-head h2 { display: flex; align-items: center; gap: var(--s-3); font-size: 15px; letter-spacing: -.005em; }
.section > .section-head h2 > svg.i:first-child { box-sizing: content-box; width: 18px; height: 18px; padding: 7px; border-radius: 8px; background: linear-gradient(135deg, #e3ecfd 0%, #d3e1fb 100%); color: var(--c-accent); box-shadow: inset 0 0 0 1px rgba(29, 95, 209, .14); flex: none; }
.section.task .section-head h2 > svg.i:first-child { background: linear-gradient(135deg, #1d5fd1 0%, #2f6fe0 100%); color: #fff; box-shadow: 0 2px 6px rgba(29, 95, 209, .28); }
.section { box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 6px rgba(16, 24, 40, .05); }
.record-icon { background: linear-gradient(135deg, #e3ecfd 0%, #d3e1fb 100%); box-shadow: inset 0 0 0 1px rgba(29, 95, 209, .14); }

/* pending state of a submitted form button (js/app.js) */
.btn-spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: citadel-spin .7s linear infinite; }
button[aria-busy="true"] { cursor: progress; opacity: .85; }
@keyframes citadel-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation: none; border-right-color: currentColor; opacity: .6; } }
.page-actions.is-start { justify-content: flex-start; }
.fieldset { margin: 0 0 var(--s-3); padding: var(--s-3) 0 0; border: 0; border-top: 1px solid var(--c-line); }
.fieldset legend { padding: 0 var(--s-2) 0 0; color: var(--c-ink); font-weight: 600; font-size: var(--t-13); }
.form-grid.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .form-grid.is-3 { grid-template-columns: minmax(0, 1fr); } }
.rel { color: var(--c-text-3); font-size: var(--t-12); }

/* ============================================================ charts (Ui/Charts.cs, §9) */
svg.chart { display: block; width: 100%; height: auto; max-height: 240px; overflow: visible; }
svg.chart .grid { stroke: #e8ecf3; stroke-width: 1; }
svg.chart .axis { fill: var(--c-text-3); font-size: 11px; font-family: var(--f-sans); }
svg.chart .val { fill: var(--c-ink); font-size: 11px; font-weight: 600; font-family: var(--f-sans); }
svg.chart .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
svg.chart .line.s1 { stroke: var(--c-accent); } svg.chart .line.s2 { stroke: var(--c-data-2); stroke-dasharray: 5 4; }
svg.chart .dot.s1 { fill: var(--c-accent); } svg.chart .dot.s2 { fill: var(--c-data-2); }
svg.chart .bar.s1 { fill: var(--c-accent); } svg.chart .bar.s2 { fill: var(--c-data-2); } svg.chart .bar.s3 { fill: #94a3b8; }
svg.chart .bar:hover { opacity: .85; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-2); color: var(--c-text-2); font-size: var(--t-12); }
.chart-legend .key { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.chart-legend .key.s1 { background: var(--c-accent); } .chart-legend .key.s2 { background: var(--c-data-2); } .chart-legend .key.s3 { background: #94a3b8; }
.freshness { color: var(--c-text-3); font-size: var(--t-12); }

/* tags, notes, mini timelines (DETAIL-SPEC B) */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px; background: #eef2fb; color: #1e3a8a; font-size: var(--t-12); font-weight: 600; box-shadow: inset 0 0 0 1px #d6e0f5; }
.tag svg.i { width: 12px; height: 12px; }
.tag-x { display: inline; margin: 0; } .tag-x button { display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.tag-x button:hover { background: #d6e0f5; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-line); }
.note-meta { display: flex; align-items: center; gap: var(--s-2); color: var(--c-text-2); font-size: var(--t-13); }
.note-text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-ink); }
.mini-timeline { list-style: none; margin: 0; padding: 0; font-size: var(--t-13); color: var(--c-text-2); }
.mini-timeline li { padding: 4px 0; border-top: 1px dashed var(--c-line); }

/* details panel skeleton while the fragment loads (js/app.js) */
.panel.is-skeleton { padding: var(--s-5); gap: var(--s-4); }
.panel .sk { border-radius: var(--r-md); background: linear-gradient(90deg, #eef1f6 0%, #f6f8fb 50%, #eef1f6 100%); background-size: 200% 100%; animation: citadel-sk 1.2s ease-in-out infinite; }
.panel .sk-head { height: 56px; }
.panel .sk-row { height: 18px; }
.panel.is-loading:not(.is-skeleton) .panel-body { opacity: .55; transition: opacity var(--t-fast) ease; }
@keyframes citadel-sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .panel .sk { animation: none; } }

/* summary strip (key facts with change; reports and the admin home) */
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 0; border-bottom: 1px solid var(--c-line); }
.summary-strip > div { padding: var(--s-3) var(--s-4); border-right: 1px solid var(--c-line); }
.summary-strip dt { color: var(--c-text-3); font-size: var(--t-12); font-weight: 500; }
.summary-strip dd { margin: 2px 0 0; color: var(--c-ink); font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; margin: 0 0 var(--s-4); background: var(--c-surface); border: 1px solid #e3e7ef; border-radius: var(--r-lg); box-shadow: var(--e-1); overflow: hidden; }
.glance a { display: block; padding: var(--s-3) var(--s-4); border-right: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); color: inherit; }
.glance a:hover { background: var(--c-row-hover); text-decoration: none; }
.glance .g-label { color: var(--c-text-3); font-size: var(--t-12); font-weight: 500; }
.glance .g-value { display: block; margin-top: 2px; color: var(--c-ink); font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.glance .g-delta { display: block; margin-top: 2px; font-size: var(--t-12); color: var(--c-text-2); }
.glance .g-delta.is-up { color: var(--c-ok); } .glance .g-delta.is-down { color: var(--c-bad); } .glance .g-delta.is-warn { color: var(--c-warn); }
.glance-head { display: flex; align-items: baseline; gap: var(--s-3); margin: 0 0 var(--s-2); }
.glance-head h2 { font-size: 15px; } .glance-head .sub { color: var(--c-text-3); font-size: var(--t-12); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: var(--r-md); background: var(--c-muted-bg); }
.segmented .seg { padding: 4px 10px; border-radius: 5px; color: var(--c-text-2); font-size: var(--t-13); font-weight: 500; }
.segmented .seg:hover { text-decoration: none; color: var(--c-ink); }
.segmented .seg.is-on { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--e-1); }
.input-date { width: auto; min-width: 150px; }
.code-block { max-height: 420px; overflow: auto; margin: var(--s-2) 0 0; padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface-2); font: 12px/1.5 var(--f-mono); white-space: pre; }

/* ---------- Global search and command palette (Ctrl/⌘+K) ---------- */
.topbar-search { min-width: 0; }
.topbar-search kbd { padding: 1px 6px; border: 1px solid var(--c-navy-700); border-radius: var(--r-sm); color: var(--c-on-dark-2); font: inherit; font-size: 11px; }
.search-group { margin-top: var(--s-5); }
.search-group-label { margin: 0 0 var(--s-2); color: var(--c-text-3); font-size: var(--t-12); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.search-group .task-list { border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface); overflow: hidden; }
.palette { width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 96px)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface); color: var(--c-text); box-shadow: var(--e-3); overflow: hidden; }
.palette[open] { display: flex; flex-direction: column; }
.palette::backdrop { background: rgba(8, 15, 30, .45); }
.palette-form { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.palette-form input { flex: 1; min-width: 0; height: 40px; border: 0; background: none; color: var(--c-ink); font: inherit; font-size: 16px; outline: none; }
.palette-form kbd { padding: 1px 6px; border: 1px solid var(--c-line-2); border-radius: var(--r-sm); color: var(--c-text-3); font: inherit; font-size: 11px; }
.palette-results { flex: 1; overflow-y: auto; padding: var(--s-1) 0; }
.palette-results:empty { display: none; }
.palette-group { padding: var(--s-3) var(--s-4) var(--s-1); color: var(--c-text-3); font-size: var(--t-12); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.palette-results a { display: grid; padding: var(--s-2) var(--s-4); color: var(--c-ink); text-decoration: none; }
.palette-results a small { color: var(--c-text-3); font-size: var(--t-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-results a[aria-selected="true"] { background: var(--c-accent-soft); box-shadow: inset 3px 0 0 var(--c-accent); }
.palette-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-status { margin: 0; padding: var(--s-2) var(--s-4); border-top: 1px solid var(--c-line); color: var(--c-text-3); font-size: var(--t-12); }

/* ---------- Organisation health (score with reasons) ---------- */
.health-head { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-4) var(--s-2); }
.health-score { display: inline-grid; place-items: center; flex: none; width: 56px; height: 56px; border: 3px solid currentColor; border-radius: 50%; font-size: var(--t-20); font-weight: 650; font-variant-numeric: tabular-nums; }
.health-score.is-ok { color: var(--c-ok); } .health-score.is-warn { color: var(--c-warn); } .health-score.is-bad { color: var(--c-bad); } .health-score.is-muted { color: var(--c-text-3); }
.health-band { display: grid; } .health-band strong { color: var(--c-ink); font-size: var(--t-16); } .health-band small { color: var(--c-text-3); font-size: var(--t-13); }
.health-factors { margin: 0; padding: 0; list-style: none; }
.health-factors li { position: relative; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--c-line); }
.health-factors .hf-icon { color: var(--c-text-3); }
.health-factors li.is-ok .hf-icon { color: var(--c-ok); } .health-factors li.is-warn .hf-icon { color: var(--c-warn); } .health-factors li.is-bad .hf-icon { color: var(--c-bad); }
.hf-main { display: grid; min-width: 0; } .hf-label { color: var(--c-ink); font-weight: 500; } .hf-reason { color: var(--c-text-2); font-size: var(--t-13); overflow-wrap: anywhere; }
.hf-points { color: var(--c-text-3); font-size: var(--t-12); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hf-link { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--c-text-3); }
.hf-link:hover { background: var(--c-row-hover); color: var(--c-ink); }

/* ---------- Admin home: balanced 2 x 2 grid, then a full-width staff activity timeline ---------- */
.task-grid.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.task-grid.is-wide-row { margin-top: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1023px) { .task-grid.is-2 { grid-template-columns: minmax(0, 1fr); } }
.timeline { margin: 0; padding: var(--s-2) var(--s-4); list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 150px 20px minmax(0, 1fr); align-items: start; gap: var(--s-2); padding: var(--s-2) 0; }
.timeline li::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(150px + var(--s-2) + 9px); width: 2px; background: var(--c-line); }
.timeline li:first-child::before { top: 50%; } .timeline li:last-child::before { bottom: 50%; }
.timeline .tl-when { display: grid; color: var(--c-text-2); font-size: var(--t-13); font-variant-numeric: tabular-nums; }
.timeline .tl-when small { color: var(--c-text-3); font-size: var(--t-12); }
.timeline .tl-dot { position: relative; z-index: 1; width: 10px; height: 10px; margin: 6px 0 0 5px; border: 2px solid var(--c-surface); border-radius: 50%; background: var(--c-ok); box-shadow: 0 0 0 1px var(--c-line); }
.timeline li.is-warn .tl-dot { background: var(--c-warn); }
.timeline .tl-what { display: grid; color: var(--c-ink); font-weight: 500; }
.timeline .tl-what small { color: var(--c-text-3); font-size: var(--t-13); font-weight: 400; overflow-wrap: anywhere; }
@media (max-width: 767px) { .timeline li { grid-template-columns: 20px minmax(0, 1fr); } .timeline .tl-when { grid-column: 2; grid-row: 2; } .timeline .tl-dot { grid-row: 1; } .timeline li::before { left: 9px; } }

/* ---------- Notification settings, snooze ---------- */
.settings-fold > summary { cursor: pointer; list-style: none; }
.settings-fold > summary::-webkit-details-marker { display: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-2) var(--s-4); margin: 0; padding: 0; border: 0; }
.check.is-locked { color: var(--c-text-3); cursor: default; }
.list-note { margin: 0; padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--c-line); color: var(--c-text-2); font-size: var(--t-13); }
.activity-actions { display: flex; flex-wrap: wrap; align-items: start; gap: var(--s-1); justify-content: flex-end; }
.note-text mark { padding: 0 3px; border-radius: 3px; font-weight: 500; }
.note-text mark.mention { background: var(--c-accent-soft); color: var(--c-accent); }
.note-text mark.hashtag { background: var(--c-muted-bg); color: var(--c-text); }

/* ---------- Saved views (Views menu on staff lists, sidebar) ---------- */
.cmd-views .menu { min-width: 280px; }
.menu .mv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu .mv-count, .nav-count { margin-left: auto; padding: 0 6px; border-radius: 999px; background: var(--c-muted-bg); color: var(--c-text-2); font-size: var(--t-12); font-variant-numeric: tabular-nums; }
.menu-note { margin: 0; padding: var(--s-2) var(--s-3); color: var(--c-text-3); font-size: var(--t-13); white-space: normal; }
.menu-form { display: grid; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-top: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); }
.menu-form label:not(.check) { color: var(--c-text-2); font-size: var(--t-12); font-weight: 600; }

/* ---------- Bell flyout ---------- */
.bell-menu .badge { position: absolute; top: 2px; right: 0; }
.bell-menu > summary { position: relative; }
.bell-panel { width: min(380px, calc(100vw - 32px)); padding: 0; white-space: normal; }
.bell-head { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); color: var(--c-ink); }
.bell-head span { color: var(--c-text-3); font-size: var(--t-12); }
.bell-list { max-height: min(420px, 60vh); margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.bell-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-3); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.bell-list li.is-unread { background: var(--c-accent-soft); }
.bell-icon { color: var(--c-text-3); } .bell-icon.is-bad { color: var(--c-bad); } .bell-icon.is-warn { color: var(--c-warn); } .bell-icon.is-ok { color: var(--c-ok); }
.bell-main { display: grid; gap: 2px; min-width: 0; }
.bell-main > a, .bell-main > span { color: var(--c-ink); font-weight: 500; overflow-wrap: anywhere; }
.bell-main small { color: var(--c-text-3); font-size: var(--t-12); }
.bell-actions { display: flex; gap: var(--s-3); margin-top: 2px; }
.bell-actions button { padding: 0; border: 0; background: none; color: var(--c-accent); font: inherit; font-size: var(--t-12); cursor: pointer; }
.menu .bell-actions button:not(.btn) { width: auto; min-height: 0; padding: 0; color: var(--c-accent); }
.bell-all { justify-content: center; font-weight: 500; }
/* Topbar search: icon only below desktop width (the label and shortcut hint need room). */
@media (max-width: 1199px) { .topbar-search > span:not(.sr), .topbar-search > kbd { display: none; } }
/* Audit log: long codes, IDs and details wrap inside their columns instead of widening the page. */
.table.is-audit td:not(.nowrap) { white-space: normal; }
.table.is-audit td:nth-child(2), .table.is-audit td:nth-child(5) { max-width: 220px; }
.table.is-audit td:nth-child(7) { max-width: 260px; }
.table.is-audit .cell-sub.mono, .table.is-audit td a { overflow-wrap: anywhere; }
.table.is-audit .a-detail-fold { display: none; }
@media (max-width: 599px) {
  /* Audit log on phones: line 1 time, action and result; line 2 actor, organisation, target (only when set);
     the detail folds; codes, IPs and IDs stay on the event page. */
  .table-wrap:has(> .table.is-audit) { overflow-x: visible; }
  .table.is-audit thead { display: none; }
  .table.is-audit, .table.is-audit tbody { display: block; width: 100%; }
  .table.is-audit tr { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--s-2); row-gap: 2px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
  .table.is-audit tr::before { content: ""; order: 4; flex-basis: 100%; height: 0; }
  .table.is-audit td { display: block; height: auto; max-width: none !important; padding: 0 !important; border: 0; white-space: normal; }
  .table.is-audit td.is-empty, .table.is-audit .cell-sub.mono, .table.is-audit .a-detail-full { display: none; }
  .table.is-audit .a-when { order: 1; color: var(--c-text-2); font-size: var(--t-13); }
  .table.is-audit .a-action { order: 2; flex: 1 1 0; min-width: 0; font-weight: 500; }
  .table.is-audit .a-result { order: 3; margin-left: auto; }
  .table.is-audit .a-actor, .table.is-audit .a-org, .table.is-audit .a-target { color: var(--c-text-2); font-size: var(--t-13); min-width: 0; overflow-wrap: anywhere; }
  .table.is-audit .a-actor { order: 5; }
  .table.is-audit .a-org { order: 6; }
  .table.is-audit .a-target { order: 7; }
  .table.is-audit .a-org::before, .table.is-audit .a-target::before { content: "· "; color: var(--c-text-3); }
  .table.is-audit .a-detail { order: 8; flex-basis: 100%; font-size: var(--t-13); }
  .table.is-audit .a-detail-fold { display: block; }
  .table.is-audit .a-detail-fold > summary { color: var(--c-accent); cursor: pointer; }
  .table.is-audit .a-detail-fold > p { margin: var(--s-1) 0 0; color: var(--c-text-2); overflow-wrap: anywhere; }
}
.health-score.is-info { color: var(--c-accent); font-size: var(--t-16); }
.onboard { margin: 0; padding: 0; list-style: none; counter-reset: ob; }
.onboard li { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--c-line); }
.onboard .ob-mark { color: var(--c-text-3); } .onboard li.is-done .ob-mark { color: var(--c-ok); }
.onboard li.is-done .hf-label { color: var(--c-text-2); text-decoration: line-through; text-decoration-color: var(--c-line-2); }

/* ---------- Get started (first run) ---------- */
.first-run { border-top: 1px solid var(--c-line); }
.first-run h3 { margin: 0 0 var(--s-2); font-size: var(--t-14); color: var(--c-ink); }
.steps-plain { margin: 0 0 var(--s-2); padding-left: var(--s-5); color: var(--c-text-2); }
.steps-plain li { margin: var(--s-1) 0; }
.product-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-4); padding: var(--s-4); }
.product-card { padding: var(--s-4); border: 1px solid var(--c-line); border-radius: var(--r-lg); background: var(--c-surface-2); }
.product-card h3 { margin: var(--s-2) 0 var(--s-1); font-size: var(--t-16); color: var(--c-ink); }
.product-card p { margin: 0; color: var(--c-text-2); font-size: var(--t-13); }
.pc-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--c-accent-soft); color: var(--c-accent); }
/* Organisation overview: cards flow into balanced columns (no holes from cards of different heights). */
.task-grid.is-flow { display: block; columns: 360px 3; column-gap: var(--s-4); }
.task-grid.is-flow > .task { display: inline-block; width: 100%; margin: 0 0 var(--s-4); break-inside: avoid; }
.task-grid.is-flow > .task.is-wide { column-span: all; display: block; }
.codes-actions { display: flex; gap: var(--s-2); margin-top: var(--s-3); }

/* ---------- Tax invoice: print-perfect (A4, black on white, no navigation, no row hover or shadows) ---------- */
@media print {
  @page { size: A4; margin: 15mm; }
  html, body { background: #fff !important; color: #000; font-size: 10.5pt; }
  .record-head .page-actions, .help.noprint, .facts { display: none; }
  .invoice { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; background: #fff; }
  .invoice h2 { font-size: 16pt; margin: 0 0 6mm; }
  .invoice .invoice-parties { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6mm; break-inside: avoid; }
  .invoice .table th, .invoice .table td { white-space: normal; color: #000; background: #fff; border-color: #999; }
  .invoice .table tr.totals td { font-weight: 700; border-top: 1.5pt solid #000; }
  .invoice .table-wrap { overflow: visible; }
  a[href]::after { content: none; }
}
/* Bell flyout: titles wrap (two lines at most), never a horizontal scrollbar. */
.bell-panel { overflow-x: hidden; }
.menu .bell-main > a:not(.btn) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; min-height: 0; padding: 0; white-space: normal; overflow: hidden; overflow-wrap: break-word; }
.bell-main > span { white-space: normal; overflow-wrap: break-word; }
.bell-all { white-space: normal; }
.usage .fill.is-ok { fill: var(--c-ok); }

/* ============================================================ phones (< 600 px) */
/* Folded secondary sections on the organisation overview (open on larger screens; script folds them on phones). */
details.fold > summary { cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .fold-chev { margin-left: auto; color: var(--c-text-3); transition: transform var(--t-fast) ease; }
details.fold:not([open]) > summary .fold-chev { transform: rotate(-90deg); }
details.fold:not([open]) > summary { border-bottom: 0; }
@media (max-width: 599px) {
  /* Wide tables become one card per row: the first cell is the title, the others "Label  value" lines. */
  .table-wrap:has(> .table.is-labelled) { overflow-x: visible; }
  .table.is-labelled thead { display: none; }
  .table.is-labelled, .table.is-labelled tbody { display: block; width: 100%; }
  .table.is-labelled tr { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
  .table.is-labelled td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); min-width: 0; height: auto; padding: 0; border: 0; white-space: normal !important; text-align: right; overflow-wrap: anywhere; }
  .table.is-labelled td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--c-text-3); font-size: var(--t-12); text-align: left; }
  .table.is-labelled td:first-child { display: block; text-align: left; font-weight: 500; }
  .table.is-labelled td:first-child::before, .table.is-labelled td.col-actions::before, .table.is-labelled td:not([data-label])::before { content: none; }
  .table.is-labelled td.col-actions { justify-content: flex-end; }
  .table.is-labelled tr:has(> td[colspan]) { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
  .table.is-labelled td[colspan] { font-weight: 500; }
  .table.is-labelled tr.totals { background: var(--c-surface-2); }
  .table.is-labelled .cell-main { justify-content: flex-start; }
  /* A cell holding several blocks (chip + sub-line) stacks under its label instead of squeezing beside it. */
  .table.is-labelled td:has(> :nth-child(2)):not(:first-child):not(.col-actions), .table.is-labelled.is-stacked td { display: block; text-align: left; }
  .table.is-labelled td:has(> :nth-child(2))::before, .table.is-labelled.is-stacked td::before { display: block; max-width: none; margin-bottom: 2px; }
  .table.is-labelled.is-stacked tr { gap: var(--s-2); }
  .table.is-labelled.is-stacked .cell-stack { display: grid; justify-items: start; gap: 2px; }
  .table.is-labelled.is-stacked .addon-indent { display: none; }
  .table.is-labelled tr.is-addon { background: var(--c-surface-2); }
  .table.is-labelled tr.is-addon td { background: none; }
  /* Tab strips scroll sideways with a fade at the edge instead of clipping a tab. */
  .tabs { scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .tabs::-webkit-scrollbar { display: none; }
  /* Tax invoice parties stack. */
  .invoice .invoice-parties { grid-template-columns: minmax(0, 1fr); }
}
