/* ---------- Design tokens: ScImage brand — matches the PICOM365 portal (dark charcoal, white text, portal crimson, portal gray).
   Dark only. Sampled from the portal buttons: "GET IN TOUCH" #8f1d20 crimson, "APPS & INFO" #5a5a5a gray, both white uppercase text.
   Every text/background pair below meets WCAG AA (>= 4.5:1) so it stays legible for older eyes. -----------------------------------*/
:root, [data-theme="dark"], [data-theme="light"] {
    --bg: #1f1f1f;             /* portal charcoal page */
    --surface: #2a2a2a;        /* cards */
    --surface-2: #343434;      /* inputs, table headers, hover */
    --surface-3: #3e3e3e;
    --border: #4a4a4a;
    --text: #f2f2f2;           /* near-white (13:1 on cards) */
    --text-muted: #bdbdbd;     /* 7:1 on cards — still easy to read */
    --brand-red: #c8102e;      /* ScImage corporate red — logo/brand mark only */
    --primary: #8f1d20;        /* portal crimson (9:1 with white text) */
    --primary-hover: #a62327;
    --primary-contrast: #ffffff;
    --secondary: #5a5a5a;      /* portal gray button (6.9:1 with white text) */
    --secondary-hover: #6b6b6b;
    --link: #f0a49d;           /* light coral for links/sort arrows: 8:1 on cards */
    --accent: #d9d9d9;         /* info badges */
    --ok: #a8d8a8;
    --danger: #f08a80;         /* 7:1 on cards */
    --sidebar-bg: #161616;
    --sidebar-text: #d6d6d6;
    --sidebar-active: #2a2a2a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .25);
    --radius: 6px;
    --chart-text: #c4c4c4;
    --chart-grid: #4a4a4a;
    --chart-palette: #b8383c, #d9d9d9, #8a8a8a, #f0a49d, #5a5a5a, #f5c6c1, #b5b5b5;
    color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font: 16px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    background: radial-gradient(1200px 700px at 70% -10%, #2a2a2a 0%, var(--bg) 60%) fixed; color: var(--text);
    display: flex; min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 13.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.pill { font-size: 12px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); margin-left: 4px; vertical-align: middle; }

/* ---------- Layout ---------- */
.sidebar {
    width: 250px; flex: none; background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    transition: margin-left .2s;
}
body.sidebar-collapsed .sidebar { margin-left: -250px; }
/* Sidebar brand: same treatment as the landing title — thin PICOM365, corporate-red Analytics, outlined red P. */
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 12px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; border-radius: 8px; border: 1.5px solid var(--brand-red); color: var(--brand-red); background: transparent; display: grid; place-items: center; font-weight: 300; font-size: 19px; line-height: 1; }
.brand-text { font-weight: 300; font-size: 18px; letter-spacing: -.01em; line-height: 1; color: #fff; white-space: nowrap; }
.brand-text span { color: var(--brand-red); font-weight: 400; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; padding: 14px 10px 4px; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 10px 10px; border-radius: 6px; color: var(--sidebar-text); font-size: 15px; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.soon { opacity: .45; cursor: default; }
.nav-link .ico { width: 14px; text-align: center; opacity: .7; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.user-name { color: #fff; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.user-sub { font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 20px; margin: 0; font-weight: 600; }
.page-title a { color: inherit; text-decoration: none; }
.spacer { flex: 1; }
.sidebar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.jump { margin: 0; }
.jump .input { width: 240px; padding: 7px 10px 7px 32px; border-radius: 999px; font-size: 14px; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23bdbdbd' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center; }
.jump .input:focus { width: 300px; background-color: var(--surface); }
@media (max-width: 900px) { .jump .input, .jump .input:focus { width: 150px; } }
.institution { font-size: 13px; font-weight: 500; color: var(--text-muted); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
.content { padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
/* Anonymous (login / legal) pages: transparent header with logo + links, centered content, footer. */
body.anon .topbar { background: transparent; border: 0; position: static; padding: 18px 32px; }
body.anon .content { flex: 1; padding: 0 32px 40px; }
.logo { display: inline-flex; align-items: center; height: 40px; }
.logo img { height: 40px; width: auto; display: block; }
.logo-light { display: none; }   /* dark theme only: the white-on-dark logo */
.anon-links { display: flex; gap: 28px; margin-right: 14px; }
.anon-links a { color: var(--text-muted); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; }
.anon-links a:hover { color: var(--text); text-decoration: none; }
.anon-foot { text-align: center; padding: 18px; }
.anon-foot a { color: var(--text-muted); text-decoration: underline; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.empty { text-align: center; max-width: 520px; margin: 40px auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 18px; border-radius: 4px; border: 1px solid transparent;
       background: var(--secondary); color: #fff; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--secondary-hover); color: #fff; text-decoration: none; }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: #fff; }
.btn-icon { padding: 6px 10px; min-height: 36px; font-size: 18px; line-height: 1; letter-spacing: 0; text-transform: none; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.input { width: 100%; padding: 10px 12px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.input:focus { outline: 2px solid color-mix(in srgb, #fff 45%, transparent); outline-offset: 1px; border-color: #9a9a9a; }
label { display: block; font-size: 14px; color: var(--text-muted); margin: 8px 0 4px; }
.alert { padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }


/* Login landing (same layout as PicomAnalytics.Next / the legacy portal) */
.landing { max-width: 1100px; margin: 0 auto; width: 100%; padding-top: 6vh; }
.landing-title { font-size: clamp(44px, 8vw, 96px); font-weight: 200; letter-spacing: -.02em; line-height: 1.05; margin: 0 0 18px; color: var(--text); }
.landing-title span { color: var(--brand-red); font-weight: 200; }
.landing-blurb { max-width: 560px; font-size: 16px; line-height: 1.55; color: var(--text-muted); margin: 0 0 40px; }
.landing-blurb a { color: var(--text); text-decoration: underline; }
.login-card { width: 420px; max-width: 100%; padding: 30px 40px 32px; background: #171717; border-color: #2e2e2e; }
.login-card .input { background: #e9eef5; color: #1a1a1a; border-color: #e9eef5; }
.login-card .input::placeholder { color: #6b7280; }
.login-card .input:focus { border-color: var(--primary); outline-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.login-heading { text-align: center; font-weight: 300; font-size: 26px; letter-spacing: .3em; text-transform: uppercase; margin: 0 0 26px; }
.login-card .input { margin-bottom: 14px; padding: 12px 13px; font-size: 16px; }
.login-links { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.login-btn { padding: 13px; min-height: 46px; font-size: 14px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; margin-top: 0; border-radius: 0; }
.login-notice { font-size: 12.5px; line-height: 1.5; margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--border); }
.login-notice a { color: inherit; text-decoration: underline; }
/* Second-step pages (MFA verify, change password, SAML error) */
.landing-narrow { display: flex; flex-direction: column; align-items: center; padding-top: 10vh; }
.login-lead { font-size: 15px; line-height: 1.5; margin: -8px 0 18px; }
.input-code { text-align: center; font-size: 22px; letter-spacing: .35em; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); margin: 0 0 16px; }
.check input { accent-color: var(--primary-hover); margin: 0; }
.login-under { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.alert-info { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); border: 1px solid var(--border); font-size: 14px; }

/* Legal pages (Terms / Privacy) */
.legal-wrap { max-width: 900px; margin: 0 auto; width: 100%; }
.legal { padding: 28px 40px 32px; line-height: 1.6; }
.legal-title { text-align: center; font-weight: 300; font-size: 28px; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 12px; }
.legal-sub { text-align: center; color: var(--danger); font-size: 16px; text-transform: uppercase; margin: 18px 0 20px; }
.legal hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.legal p { margin: 0 0 14px; }
.legal-indent { margin-left: 28px; }

/* Dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile-list { list-style: none; margin: 0; padding: 0; }
.tile-list li { padding: 6px 0; border-top: 1px solid var(--border); }
.tile-list li:first-child { border-top: 0; }

/* Filters (search bars) */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { min-width: 150px; flex: 1 1 150px; }
/* Shared "Date basis" on a non-default (remembered) value: make it visible before Run, not just in the status line. */
.filters .input.non-default { border-color: var(--primary-hover); box-shadow: inset 3px 0 0 var(--primary-hover); }
.filters .field label { margin-top: 0; }
.filters .actions { display: flex; gap: 8px; flex: 0 0 auto; }
.range { display: flex; gap: 6px; }

/* Multi-select dropdown (PA.multiSelect) */
.ms { position: relative; }
.ms-btn { text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); padding-right: 26px; }
.ms-btn.ms-has { color: var(--text); }
.ms-btn::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.ms-pop { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 8px; }
.ms-search { margin-bottom: 6px; }
.ms-list { max-height: 240px; overflow-y: auto; }
.ms-item { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 4px; cursor: pointer; font-size: 14px; color: var(--text); margin: 0; }
.ms-item:hover { background: var(--surface-2); }
.ms-item input { accent-color: var(--primary-hover); margin: 0; }
.ms-empty { padding: 6px; }
.ms-foot { display: flex; gap: 6px; align-items: center; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.ms-asof { flex: 1; white-space: nowrap; }
.ms-reload { padding: 2px 8px; min-height: 30px; font-size: 15px; letter-spacing: 0; text-transform: none; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi-label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.kpi-value { font-size: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi { border-top: 3px solid var(--primary); }
.kpi-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; min-height: 1em; }

/* Busy overlay (PA.busy): blocks the page while a report runs. */
.busy-overlay { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(10, 16, 28, .55); backdrop-filter: blur(2px); cursor: wait; }
.busy-overlay.on { display: flex; }
.busy-box { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 28px 40px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); min-width: 340px; }
.busy-spinner { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; border: 5px solid var(--border); border-top-color: var(--primary-hover); animation: busy-spin .8s linear infinite; }
.busy-text { font-size: 22px; font-weight: 600; color: var(--text); }
.busy-sub { font-size: 14px; color: var(--text-muted); margin-top: 6px; }
@keyframes busy-spin { to { transform: rotate(360deg); } }

/* Charts */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
/* Pack cards of uneven height where the browser supports masonry (progressive; the grid above is the fallback). */
@supports (grid-template-rows: masonry) { .grid-2 { grid-template-rows: masonry; } }
.chart { height: 300px; width: 100%; }
.chart-tall { height: 420px; }
.chart-mid { height: 250px; }
.chart-short { height: 210px; }
.tabulator-row.tabulator-group { background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--border); font-weight: 600; }
.tabulator-row.tabulator-group:hover { background: var(--surface-2); }
.tabulator-row.tabulator-group .tabulator-group-toggle { color: var(--text-muted); }
.tabulator-row.tabulator-group .tabulator-arrow { border-left-color: var(--text-muted); border-top-color: var(--text-muted); }
.tabulator-row.tabulator-group span, .tabulator-row.tabulator-group .grp-sub { color: var(--text-muted); font-weight: 400; }  /* vendor default paints the count red */
.card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }

/* Chart focus view (PA.focusable / PA.focusChart): ⤢ in the card header opens the chart full-window. */
h3.has-expand { display: flex; align-items: center; gap: 8px; }
.chart-expand { margin-left: auto; opacity: .55; }
.card:hover .chart-expand, .chart-expand:focus-visible { opacity: 1; }
/* Table tools (Copy / CSV) in a table card's header, same placement as ⤢ on charts. */
.table-tools { margin-left: auto; display: inline-flex; gap: 4px; opacity: .7; }
.card:hover .table-tools, .table-tools:focus-within { opacity: 1; }
.chart-focus { position: fixed; inset: 0; z-index: 900; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(10, 16, 28, .6); backdrop-filter: blur(2px); }
.chart-focus-panel { display: flex; flex-direction: column; width: min(1400px, 100%); height: min(860px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.45); overflow: hidden; }
.chart-focus-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chart-focus-head h3 { margin: 0; flex: 1; }
.chart-focus-body { flex: 1; min-height: 0; padding: 12px; }
body.no-scroll { overflow: hidden; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); margin: 0; cursor: pointer; }
.check input { accent-color: var(--primary-hover); margin: 0; }

/* Tabulator theming through tokens (site.css loads after tabulator.min.css so these win) */
.tabulator { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 15px; color: var(--text); }
.tabulator .tabulator-header { background: var(--surface-2); color: var(--text); border-bottom: 2px solid var(--border); font-weight: 600; }
.tabulator .tabulator-header .tabulator-col,
.tabulator .tabulator-header .tabulator-col.tabulator-frozen { background: var(--surface-2); border-right: 1px solid var(--border); color: var(--text); }
/* hover / sorted / being dragged: subtle tint, never the vendor light grey */
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover,
.tabulator .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover,
.tabulator .tabulator-header .tabulator-col.tabulator-moving,
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"],
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] { background: color-mix(in srgb, var(--primary) 22%, var(--surface-2)); color: var(--text); }
.tabulator .tabulator-header .tabulator-col.tabulator-moving { border: 1px solid var(--primary-hover); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter { color: var(--text-muted); }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow { border-bottom-color: var(--link); }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow { border-top-color: var(--link); }
.tabulator .tabulator-col-resize-handle:hover { background: var(--primary-hover); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title { color: var(--text); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter .tabulator-arrow { border-bottom-color: var(--text-muted); border-top-color: var(--text-muted); }
.tabulator .tabulator-header .tabulator-header-filter input,
.tabulator .tabulator-header input { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; font: inherit; font-weight: 400; }
.tabulator-row .tabulator-cell.tabulator-frozen { background: inherit; border-right: 2px solid var(--border); }
.tabulator .tabulator-tableholder .tabulator-table { background: var(--surface); color: var(--text); }
.tabulator-row { background: var(--surface); border-bottom: 1px solid var(--border); }
.tabulator-row.tabulator-row-even { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }
/* hover / selected / selectable states — vendor CSS uses light greys with higher specificity, so match it */
.tabulator-row:hover, .tabulator-row.tabulator-row-even:hover,
.tabulator-row.tabulator-selectable:hover, .tabulator-row.tabulator-selectable.tabulator-row-even:hover,
.tabulator-row.tabulator-selected, .tabulator-row.tabulator-selected:hover,
.tabulator-row.tabulator-selected.tabulator-row-even { background: color-mix(in srgb, var(--primary) 20%, var(--surface)); color: var(--text); }
.tabulator-row.tabulator-selected .tabulator-cell, .tabulator-row.tabulator-selectable:hover .tabulator-cell { color: var(--text); }
.tabulator-row .tabulator-cell { border-right: 1px solid var(--border); }
.tabulator .tabulator-footer { background: var(--surface-2); color: var(--text); border-top: 1px solid var(--border); }
.tabulator .tabulator-footer .tabulator-page { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.tabulator .tabulator-footer .tabulator-page.active { color: var(--link); border-color: var(--primary-hover); }
.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents { color: var(--text-muted); background: transparent; }

/* Off-canvas backdrop (phones only) */
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.45); }
@media (max-width: 900px) {
    .sidebar { position: fixed; z-index: 20; margin-left: -250px; box-shadow: 0 0 30px rgba(0,0,0,.5); }
    body.sidebar-open .sidebar { margin-left: 0 !important; }
    body.sidebar-open .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; }
    .topbar { padding: 10px 12px; }
    .content { padding: 12px 12px 40px; }
    .institution { display: none; }
    .page-title { font-size: 17px; }
    .page-title a { color: inherit; text-decoration: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .sticky-actions { margin: 0 -12px -40px; padding: 10px 12px; flex-wrap: wrap; }
}
@media print {
    .sidebar, .topbar, .filters, .btn { display: none !important; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* ================= AdminConsole additions (same tokens; components the console needs) ================= */
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-red); }
.nav-link:hover .ico, .nav-link.active .ico { opacity: 1; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-accent { background: var(--secondary); color: #fff; }   /* portal gray, same as the default button (kept for markup compatibility) */
.btn-accent:hover { background: var(--secondary-hover); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .spacer { flex: 1; }
.kbd { font: 12px/1 ui-monospace, Consolas, monospace; padding: 2px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--text-muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; line-height: 1.5; }
.badge-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge-warn { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; border-color: color-mix(in srgb, #d97706 40%, transparent); }
.badge-warn { color: #fbbf24; }
.badge-bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.badge-info { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* Forms: responsive field grid, sections, switches */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.form-grid .field { min-width: 0; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field label { margin-top: 0; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 25%, transparent); }
.field .err { font-size: 13px; color: var(--danger); margin-top: 3px; min-height: 0; }
.input[disabled], .input:disabled { opacity: .55; cursor: not-allowed; }
select.input { appearance: auto; }
textarea.input { min-height: 72px; resize: vertical; }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row .input { flex: 1; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0; }
.section-title .pill { margin-left: 0; }
.stack { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .stack { grid-template-columns: 1fr; } }
.sticky-actions { position: sticky; bottom: 0; z-index: 4; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border); margin: 0 -22px -40px; padding: 12px 22px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Switch (toggle) — replaces the legacy Kendo toggle buttons */
/* Toggle switches. One consistent look everywhere: neutral track when off, portal crimson when on, white knob.
   Inside .switch-grid (Account Options) every toggle becomes a uniform settings row — label left, switch right — so a
   wall of twenty options reads as one tidy list instead of scattered red pills. */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; color: var(--text); margin: 0; user-select: none; line-height: 1.3; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #4f4f4f; border: 1px solid #5e5e5e; position: relative; transition: background .18s, border-color .18s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #d0d0d0; transition: left .18s, background .18s; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.switch:hover .track { border-color: #7a7a7a; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { left: 20px; background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid #fff; outline-offset: 2px; }
.switch input:disabled + .track { opacity: .4; }
.switch input:disabled ~ .label { color: var(--text-muted); }
.switch.premium .label::after { content: 'PREMIUM'; display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 3px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; color: var(--text-muted); border: 1px solid var(--border); vertical-align: middle; }
.switch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.switch-grid .switch { display: flex; flex-direction: row-reverse; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 12px 8px 14px; border-radius: 6px; background: var(--surface-2); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.switch-grid .switch:hover { background: var(--surface-3); }
.switch-grid .switch:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 55%, transparent); background: color-mix(in srgb, var(--primary) 10%, var(--surface-2)); }
.switch-grid .switch .label { flex: 1; }
.switch-grid .switch:has(input:disabled) { opacity: .6; cursor: not-allowed; }
/* Inline toggles in a toolbar/input-row (Sign-in, MFA): breathing room so neighbouring label+switch pairs don't run together. */
.toolbar .switch, .input-row .switch { margin: 4px 22px 4px 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.check-grid .check { font-size: 15px; color: var(--text); }
.check-grid .check.disabled { opacity: .5; }
.check-grid .grp { grid-column: 1 / -1; font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-top: 6px; }

/* Modal (PA.modal) */
.modal-overlay { position: fixed; inset: 0; z-index: 950; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(10, 16, 28, .6); backdrop-filter: blur(2px); }
.modal { width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,.45); overflow: hidden; }
.modal-wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; flex: 1; text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--text); }
.modal-body { padding: 16px; overflow: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Toasts (PA.toast) */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 420px; padding: 11px 14px; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.35); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; border-left: 4px solid var(--text-muted); font-size: 15px; }
.toast.on { opacity: 1; transform: none; }
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }

/* Dashboard stat tiles / feature tiles */
.tile { display: flex; flex-direction: column; gap: 8px; }
.tile a.tile-link { font-weight: 600; font-size: 16px; color: var(--text); }
.tile .tile-ico { font-size: 22px; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { font-variant-numeric: tabular-nums; }
.stat b { font-size: 20px; font-weight: 600; display: block; }
.stat span { font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* Plain tables (system health, license lists) */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.group td { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Progress bars (disk / volume usage) */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; background: var(--primary-hover); border-radius: 999px; }
.bar > i.warn { background: #d97706; }
.bar > i.bad { background: var(--danger); }

/* Tabs (panel selector) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tab { padding: 8px 14px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font: inherit; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary-hover); }
.tab-panel[hidden] { display: none; }

/* Full-width card inside .grid-2, and single-panel mode (System Health tabs) */
.grid-2 > .span-all { grid-column: 1 / -1; }
.grid-2.single { grid-template-columns: 1fr; }

/* Tabulator extras for the console */
.tabulator .tabulator-cell input[type="checkbox"] { accent-color: var(--primary-hover); }
.tabulator-row .tabulator-cell a { color: var(--link); }
.tabulator .tabulator-cell.locked { color: var(--danger); }
.rows-note { font-size: 12px; color: var(--text-muted); }
