/*
 * SIS admin design system. Original code. Visual reference only: Cassie "Dashboard One"
 * (dimensions and colours observed from the public demo, see docs/UI_DESIGN_SYSTEM.md).
 */
@font-face { font-family: 'Roboto'; font-weight: 400; font-display: swap; src: url('../fonts/roboto-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 500; font-display: swap; src: url('../fonts/roboto-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 700; font-display: swap; src: url('../fonts/roboto-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto'; font-weight: 400; font-display: swap; src: url('../fonts/roboto-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20CF; }
@font-face { font-family: 'Oswald'; font-weight: 400; font-display: swap; src: url('../fonts/oswald-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Oswald'; font-weight: 500; font-display: swap; src: url('../fonts/oswald-latin-500-normal.woff2') format('woff2'); }

:root {
    --primary: #5556fd; --primary-dark: #3f40e6; --primary-soft: #ececff;
    --secondary: #637382;
    --success: #1a8a47; --success-soft: #e3f7eb;
    --warning: #9a6200; --warning-soft: #fff3da;
    --danger: #c9244d; --danger-soft: #fde8ed;
    --info: #0b6e99; --info-soft: #e2f4fb;
    --text: #373857; --text-strong: #06072d; --text-muted: #6b6f8a; --text-nav: #575d78;
    --bg: #f7f8fc; --surface: #fff;
    --border: rgba(230, 231, 239, .85); --border-input: #d6d8e5;
    --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-number: 'Oswald', 'Roboto', sans-serif;
    --fs-xs: 11px; --fs-sm: 12px; --fs-md: 13px; --fs-base: 14px; --fs-lg: 18px; --fs-title: 28px; --fs-kpi: 24px;
    --fw-normal: 400; --fw-medium: 500; --fw-bold: 700;
    --sidebar-width: 240px; --header-height: 80px;
    --radius: 0px; --radius-sm: 2px;
    --shadow-card: 2px 2px 5px rgba(60, 70, 83, .04);
    --shadow-float: 0 4px 12px rgba(131, 146, 165, .15);
    --space-1: 5px; --space-2: 10px; --space-3: 15px; --space-4: 20px; --space-5: 30px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fw-normal) var(--fs-base)/1.5 var(--font); color: var(--text); background: var(--bg); overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
h1, h2, h3, h4 { color: var(--text-strong); font-weight: var(--fw-medium); line-height: 1.2; margin: 0; }
p { margin: 0 0 var(--space-2); }
code { font-size: var(--fs-sm); background: var(--bg); padding: 1px 4px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.stack > * + * { margin-top: var(--space-4); }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow-float); display: flex; flex-direction: column; z-index: 40; }
.sidebar-header { height: var(--header-height); flex: none; border-bottom: 1px solid var(--border); padding: 0 19px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: block; line-height: 1.1; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font: var(--fw-medium) 28px/1 var(--font-number); color: var(--primary); }
.brand span { display: block; font: var(--fw-normal) var(--fs-xs)/1.4 var(--font-number); color: var(--text); }
.sidebar-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-4) var(--space-2) var(--space-5); overscroll-behavior: contain; }
.website-switch { margin: 0 0 var(--space-4); }
.website-switch .dropdown-toggle { width: 100%; justify-content: space-between; }
.website-switch .dropdown-menu { left: 0; right: 0; min-width: 0; }
.website-switch .dropdown-item { overflow-wrap: anywhere; }
.truncate { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding-left: 9px; margin: var(--space-4) 0 var(--space-1); }
.nav, .nav-sub { list-style: none; margin: 0; padding: 0; }
.nav-link { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 35px; padding: 7px 8px; border: 0; background: none; font: var(--fw-medium) var(--fs-base) var(--font); color: var(--text-nav); text-align: left; cursor: pointer; }
a.nav-link:hover, button.nav-link:hover { color: var(--primary); text-decoration: none; }
.nav-link .nav-caret { margin-left: auto; transition: transform .15s; }
.nav-link[aria-expanded="true"] .nav-caret { transform: rotate(90deg); }
.nav-link[aria-current="page"], .nav-link[aria-current="page"]:hover { background: var(--primary); color: #fff; }
.nav-link.is-open { color: var(--primary); }
.nav-sub { padding: 2px 0 var(--space-1); }
.nav-sub[hidden] { display: none; }
.nav-sub .nav-link { padding-left: 34px; font-weight: var(--fw-normal); font-size: var(--fs-md); min-height: 30px; }
.nav-sub .nav-link[aria-current="page"], .nav-sub .nav-link[aria-current="page"]:hover { background: none; color: var(--primary); font-weight: var(--fw-medium); }
.nav-planned { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 8px 5px 34px; font-size: var(--fs-md); color: #8b8fa6; cursor: default; }
.tag-planned { font-size: 9px; text-transform: uppercase; border: 1px solid var(--border-input); padding: 0 4px; line-height: 14px; white-space: nowrap; }

/* Header and content */
/*
 * Application shell: a column at least one screen tall. <main> takes the spare height, so the
 * footer sits at the bottom of short pages and after the content of long ones. Never position
 * the footer fixed or absolute.
 */
.shell { margin-left: var(--sidebar-width); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; min-width: 0; }
.shell > main { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }
.header { flex-shrink: 0; height: var(--header-height); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); position: sticky; top: 0; z-index: 30; }
.header-context { flex: 0 1 auto; min-width: 0; line-height: 1.3; }
.header-context strong { display: block; color: var(--text-strong); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.icon-button { background: none; border: 0; padding: 8px; cursor: pointer; color: var(--text-strong); display: inline-flex; }
.icon-button .icon { width: 20px; height: 20px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: var(--fw-medium); }
.avatar-button { background: none; border: 0; padding: 0; cursor: pointer; }
.content-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); }
.content-title { font-size: var(--fs-title); overflow-wrap: anywhere; }
.breadcrumb { list-style: none; display: flex; flex-wrap: wrap; margin: 0 0 2px; padding: 0; font-size: var(--fs-sm); }
.breadcrumb li + li::before { content: '\203A'; color: var(--text-muted); padding: 0 8px; }
.breadcrumb a { color: var(--text); }
.breadcrumb [aria-current] { color: var(--primary); }
.content-body { padding: 0 var(--space-4) var(--space-4); flex: 1 0 auto; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.footer { flex-shrink: 0; margin-top: auto; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); background: var(--surface); }
.backdrop { display: none; }

/* Grid */
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid + .grid, .card + .grid, .grid + .card { margin-top: var(--space-4); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); border-radius: var(--radius); min-width: 0; }
.card + .card { margin-top: var(--space-4); }
.grid > .card + .card { margin-top: 0; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border); }
.card-title { font-size: var(--fs-base); }
.card-body { padding: var(--space-4); }
.card-footer { padding: var(--space-3); border-top: 1px solid var(--border); }

/* KPI */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: var(--space-3); }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); margin: 0; }
.kpi-label .icon { width: 14px; height: 14px; flex: none; }
.kpi-label > span { min-width: 0; overflow-wrap: anywhere; }
.kpi-value { display: block; font: var(--fw-medium) 26px/1.25 var(--font-number); color: var(--text-strong); overflow-wrap: anywhere; }
.kpi-value small { font-size: var(--fs-sm); color: var(--text-muted); }
.kpi-value.is-missing { font: var(--fw-medium) var(--fs-base)/1.4 var(--font); color: var(--text-muted); }
.kpi-note { font-size: var(--fs-xs); color: var(--text-muted); margin: 0; }
.kpi-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: auto 0 0; }
.kpi-coverage { font-size: var(--fs-xs); color: var(--text-muted); }
.kpi-link { font-size: var(--fs-xs); }
.kpi-source { font-size: var(--fs-xs); color: var(--text-muted); }
.metric-info, .metric-close { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; background: none; border: 0; border-radius: 50%; color: var(--text-muted); cursor: pointer; }
.metric-info:hover, .metric-info:focus-visible, .metric-info[aria-expanded="true"], .metric-close:hover { color: var(--primary); }
.metric-popover { position: fixed; inset: auto; margin: 0; width: min(340px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: var(--space-3); background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(16, 24, 40, .18); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.metric-popover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; color: var(--text-strong); }
.metric-popover p { margin: 6px 0; }
.metric-popover dl { margin: 6px 0 0; }
.metric-popover dt { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; }
.metric-popover dd { margin: 0; color: var(--text-strong); }
.metric-links { display: flex; flex-wrap: wrap; gap: 12px; }
@media (max-width: 480px) {
    /* A sheet along the bottom where an anchored panel cannot fit. */
    .metric-popover { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; max-height: 70vh !important; }
}
.coverage-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 var(--space-3); font-size: var(--fs-sm); color: var(--text-muted); }
.coverage-line summary { cursor: pointer; color: var(--primary); }
.coverage-line ul { margin: 4px 0 0; padding-left: 16px; }
.kpi-dates { margin: 0; font-size: var(--fs-md); }
.kpi-dates dt { color: var(--text-muted); font-size: var(--fs-xs); }
.kpi-dates dd { margin: 0 0 4px; color: var(--text-strong); font-weight: var(--fw-medium); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Card sections size by the space they have, not by the window, so a collapsed sidebar counts. */
.card-section { container-type: inline-size; margin-top: var(--space-4); }
.card-grid { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.card-grid > .card { margin: 0; }
@container (min-width: 440px) {
    .card-grid[data-count="2"], .card-grid[data-count="4"], .card-grid[data-count="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 600px) {
    .card-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (min-width: 660px) {
    .card-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container (min-width: 760px) {
    .card-grid[data-count="chart"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card-grid[data-count="chart"] > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@container (min-width: 860px) {
    .card-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@container (min-width: 1380px) {
    .card-grid[data-count="6"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 37px; padding: 6px 12px; border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--surface); color: var(--text-nav); font: var(--fw-normal) var(--fs-base) var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9bcd0; color: var(--text-strong); text-decoration: none; }
.btn-primary, .btn-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger, .btn-danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 3px 9px; font-size: var(--fs-sm); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-loading::after { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.form-grid { display: grid; gap: var(--space-3) var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium); margin-bottom: 4px; color: var(--text); }
.form-control { width: 100%; min-height: 37px; padding: 6px 10px; border: 1px solid var(--border-input); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
textarea.form-control { resize: vertical; }
.form-control:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); }
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
.form-control[aria-invalid="true"] { border-color: var(--danger); }
.field-error { display: block; color: var(--danger); font-size: var(--fs-sm); margin-top: 3px; }
.field-hint { display: block; color: var(--text-muted); font-size: var(--fs-xs); margin-top: 3px; }
.check { display: flex; align-items: center; gap: var(--space-2); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.field .check label { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.filters .form-control { width: auto; min-width: 150px; }

/* Tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: var(--fs-sm); font-weight: var(--fw-medium); text-align: left; padding: 8px var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { font-size: var(--fs-md); padding: 10px var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfbfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.details { display: grid; grid-template-columns: fit-content(45%) minmax(0, 1fr); margin: 0; }
.details dt, .details dd { margin: 0; padding: 9px var(--space-3); border-bottom: 1px solid var(--border); font-size: var(--fs-md); }
.details dt { font-weight: var(--fw-medium); }
.details dd { overflow-wrap: anywhere; white-space: pre-line; }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 18px; white-space: nowrap; border-radius: var(--radius-sm); background: var(--bg); color: var(--text-nav); border: 1px solid var(--border-input); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.alert { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid; margin: 0 0 var(--space-4); font-size: var(--fs-md); }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.empty { text-align: center; padding: var(--space-5) var(--space-4); color: var(--text-muted); }
.empty .icon { width: 28px; height: 28px; opacity: .55; margin-bottom: var(--space-2); }
.empty strong { display: block; color: var(--text); font-weight: var(--fw-medium); }
.empty p { font-size: var(--fs-sm); margin: 2px 0 0; }
.progress { height: 4px; background: var(--border-input); }
.progress > span { display: block; height: 100%; background: var(--primary); }

/* Dropdown, tooltip, dialog */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border-input); box-shadow: var(--shadow-float); padding: var(--space-1) 0; z-index: 50; max-height: 300px; overflow-y: auto; }
.dropdown-menu[hidden] { display: none; }
.dropdown-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: 8px var(--space-3); border: 0; background: none; font: inherit; font-size: var(--fs-md); color: var(--text); text-align: left; cursor: pointer; }
.dropdown-item:hover:not(:disabled) { background: var(--bg); color: var(--primary); text-decoration: none; }
.dropdown-item:disabled { color: var(--primary); font-weight: var(--fw-medium); cursor: default; }
.dropdown-header { padding: 8px var(--space-3); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.tooltip { position: relative; display: inline-flex; cursor: help; color: var(--text-muted); background: none; border: 0; padding: 2px; }
.tooltip > span { position: absolute; bottom: calc(100% + 6px); right: -8px; width: 220px; background: var(--text-strong); color: #fff; font: var(--fw-normal) var(--fs-xs)/1.45 var(--font); text-align: left; text-transform: none; padding: 6px 9px; visibility: hidden; z-index: 60; }
.tooltip:hover > span, .tooltip:focus > span { visibility: visible; }
dialog { border: 1px solid var(--border-input); box-shadow: var(--shadow-float); padding: 0; width: min(420px, calc(100vw - 32px)); color: var(--text); }
dialog::backdrop { background: rgba(6, 7, 45, .45); }

/* Pagination */
.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); padding: var(--space-3); border-top: 1px solid var(--border); }
.pagination .muted { margin: 0 var(--space-2); font-size: var(--fs-sm); }

/* Chart: one series per plot */
.chart { position: relative; margin: 0; }
.chart-body { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 6px; }
.chart-y { position: relative; font-size: var(--fs-xs); color: var(--text-muted); }
.chart-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.chart svg { display: block; width: 100%; height: 180px; overflow: visible; }
.chart svg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chart .gridline { stroke: #eef0f5; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .gap { fill: #f3f4f8; }
.chart .series { fill: none; stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .dot { stroke: var(--primary); stroke-width: 6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .hit { fill: transparent; }
.chart .hit:hover, .chart .hit.is-active { fill: rgba(85, 86, 253, .12); }
.chart-x { position: relative; height: 18px; margin: 4px 0 0 54px; font-size: var(--fs-xs); color: var(--text-muted); }
.chart-x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart-x span:first-child { transform: none; }
.chart-x span:last-child:not(:first-child) { transform: translateX(-100%); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0; margin: 4px 0 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.chart-legend i { display: inline-block; width: 14px; height: 0; margin-right: 5px; vertical-align: middle; border-top: 2px solid var(--primary); }
.chart-legend i.key-compare { border-top: 2px dashed var(--warning); }
.chart-legend i.key-gap { height: 10px; border: 1px solid var(--border-input); background: #f3f4f8; }
.chart-readout { min-height: 18px; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-strong); }
.chart-empty { min-height: 180px; display: flex; align-items: center; justify-content: center; }
@media (max-width: 767px) { .chart-x span:nth-child(2), .chart-x span:nth-child(4) { display: none; } }

/* Auth and error pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth-card { width: min(380px, 100%); }
.auth-card .card-body { padding: var(--space-5); }
.auth-card .btn { width: 100%; }
.error-code { font: var(--fw-medium) 64px/1 var(--font-number); color: var(--primary); }

/* Responsive */
@media (max-width: 1199px) {
    .col-3 { grid-column: span 6; }
    .col-4 { grid-column: span 6; }
    .col-8 { grid-column: span 12; }
}
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; }
    body.sidebar-collapsed .shell { margin-left: 0; }
    .sidebar-close { display: none; }
}
@media (max-width: 991px) {
    .shell { margin-left: 0; }
    .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s; width: min(var(--sidebar-width), 85vw); }
    body.sidebar-open .sidebar { transform: none; visibility: visible; }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(6, 7, 45, .45); z-index: 35; border: 0; }
}
@media (max-width: 767px) {
    .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .header { padding: 0 var(--space-3); gap: var(--space-2); }
    .header-status { display: none; }
    .content-header, .content-body { padding-left: var(--space-3); padding-right: var(--space-3); }
    .content-title { font-size: 22px; }
    .details { grid-template-columns: minmax(0, 1fr); }
    .details dt { border-bottom: 0; padding-bottom: 0; }

    /* Rows become labelled blocks instead of a sideways scroll. */
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { border-bottom: 1px solid var(--border-input); padding: var(--space-2) 0; }
    .table-stack td { display: flex; justify-content: space-between; gap: var(--space-3); border: 0; padding: 4px var(--space-3); text-align: right; overflow-wrap: anywhere; }
    .table-stack td[data-label]::before { content: attr(data-label); font-weight: var(--fw-medium); text-align: left; flex: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }

/* Long values stay inside their component and remain readable in full. */
.card-title, .breadcrumb li, .details dt, .alert > *, .kpi-value, .nav-link, .dropdown-header, .field label, .field-hint, .field-error, .empty { min-width: 0; overflow-wrap: anywhere; }
.badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.table td { overflow-wrap: break-word; }
.form-control, .filters > * { max-width: 100%; }
.required { color: var(--danger); }
.field-hint { line-height: 1.45; }
.help-more { margin-top: 3px; font-size: var(--fs-sm); color: var(--text-muted); }
.help-more summary { cursor: pointer; color: var(--primary); }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps > li { counter-increment: step; padding: var(--space-3); border-bottom: 1px solid var(--border); font-size: var(--fs-md); overflow-wrap: anywhere; }
.steps > li:last-child { border-bottom: 0; }
.steps > li > strong::before { content: counter(step) ". "; }

/* Reporting date range picker */
.drp { max-width: 100%; min-width: 0; }
.drp-label { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 2px; }
.drp-trigger { display: flex; align-items: center; gap: var(--space-2); max-width: 100%; min-height: 38px; padding: 6px var(--space-3); background: var(--surface); border: 1px solid var(--border-input); font: inherit; font-size: var(--fs-md); color: var(--text-strong); text-align: left; cursor: pointer; }
.drp-trigger:disabled { cursor: default; color: var(--text); }
.drp-summary { display: block; min-width: 0; overflow-wrap: anywhere; }
.drp-summary-compare { display: block; font-size: var(--fs-xs); color: var(--warning); }
.drp-summary-compare[hidden] { display: none; }
.drp-panel { position: fixed; z-index: 60; display: flex; width: min(680px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto; background: var(--surface); border: 1px solid var(--border-input); box-shadow: 0 10px 30px rgba(60, 70, 83, .22); text-align: left; }
.drp-panel[hidden] { display: none; }
.drp-presets { flex: none; width: 150px; border-right: 1px solid var(--border); padding: var(--space-2) 0; overflow-y: auto; }
.drp-preset { display: block; width: 100%; padding: 5px var(--space-3); border: 0; border-left: 3px solid transparent; background: none; font: inherit; font-size: var(--fs-md); color: var(--text); text-align: left; cursor: pointer; }
.drp-preset:hover { background: var(--bg); }
.drp-preset[aria-pressed="true"] { border-left-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: var(--fw-medium); }
.drp-main { flex: 1; min-width: 0; padding: var(--space-3); }
.drp-main > * + * { margin-top: var(--space-2); }
.drp-nav { display: flex; gap: var(--space-2); align-items: center; justify-content: center; }
.drp-nav .form-control { width: auto; }
.drp-calendars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.drp-month table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.drp-month-title { text-align: center; font-weight: var(--fw-medium); color: var(--text-strong); margin: 0 0 var(--space-1); }
.drp-month th { font-size: var(--fs-xs); font-weight: var(--fw-normal); color: var(--text-muted); padding: 2px 0; }
.drp-month td { padding: 1px 0; text-align: center; }
.drp-day { position: relative; width: 100%; height: 30px; border: 1px solid transparent; background: none; font: inherit; font-size: var(--fs-sm); color: var(--text-strong); cursor: pointer; }
.drp-day:hover { border-color: var(--primary); }
.drp-day[aria-disabled="true"] { color: var(--text-muted); opacity: .45; cursor: default; border-color: transparent; }
.drp-day.is-today { font-weight: var(--fw-bold); text-decoration: underline; }
.drp-day.is-compare { border-top: 2px dashed var(--warning); border-bottom: 2px dashed var(--warning); }
.drp-day.is-in-range { background: var(--primary-soft); }
.drp-day.is-start, .drp-day.is-end { background: var(--primary); color: #fff; font-weight: var(--fw-medium); }
.drp-day.is-start { border-radius: 15px 0 0 15px; }
.drp-day.is-end { border-radius: 0 15px 15px 0; }
.drp-day.is-start.is-end { border-radius: 15px; }
.drp-day.has-data::after, .drp-day.is-preliminary::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.drp-day.is-preliminary::after { background: none; border: 1px solid currentColor; width: 5px; height: 5px; }
.drp-key { display: inline-block; width: 6px; height: 6px; border-radius: 50%; border: 1px solid currentColor; margin: 0 2px 0 6px; }
.drp-key.has-data { background: currentColor; }
.drp-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-2); }
.drp-fields .form-control { width: 100%; }
.drp-fields input[readonly] { background: var(--bg); }
.drp-actions { display: flex; justify-content: flex-end; gap: var(--space-2); position: sticky; bottom: 0; background: var(--surface); padding: var(--space-2) 0 0; }
.drp-main [data-drp-error]:empty { display: none; }
.kpi-change { font-size: var(--fs-sm); margin: 0; overflow-wrap: anywhere; }
.kpi-previous { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.kpi-change.is-good { color: var(--success); }
.kpi-change.is-bad { color: var(--danger); }
.chart .series-compare { fill: none; stroke: var(--warning); stroke-width: 1.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }

@media (max-width: 767px) {
    .drp, .drp-trigger { width: 100%; }
    .drp-trigger .drp-summary { flex: 1; }
    .drp-panel { inset: 0; width: 100%; max-height: none; display: block; border: 0; }
    .drp-presets { width: auto; display: flex; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--border); padding: var(--space-2); }
    .drp-preset { width: auto; border: 1px solid var(--border-input); }
    .drp-preset[aria-pressed="true"] { border-color: var(--primary); }
    .drp-calendars { grid-template-columns: minmax(0, 1fr); }
    .drp-month + .drp-month { display: none; }
    .drp-day { height: 36px; }
    .drp-actions { padding-bottom: var(--space-2); }
}

/* Focus sits on the inner segments of a date field, so the field itself needs the indicator. */
input[type="date"]:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Dashboard sections */
.section-title { margin: 1.5rem 0 .5rem; font-size: 1rem; }

.scroll-box { max-height: 420px; overflow: auto; }
.text-sample { max-height: 320px; overflow: auto; font-size: var(--fs-md); }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }

.btn[aria-current="page"] { border-color: var(--primary); color: var(--primary); }

/* Coverage summary, compact module states and setup progress */
.coverage { font-size: var(--fs-sm); }
.coverage ul { margin: 4px 0 0; padding-left: 18px; }
.modules { list-style: none; margin: 0; padding: 0; }
.modules li { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.modules li:last-child { border-bottom: 0; }
.modules .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--text-muted); }
.modules strong { display: block; color: var(--text-strong); }
.modules li > div { min-width: 0; overflow-wrap: anywhere; }
details.card > summary { cursor: pointer; padding: var(--space-3); font-weight: var(--fw-medium); color: var(--text-strong); }
details.card > summary span { font-weight: var(--fw-normal); color: var(--text-muted); font-size: var(--fs-sm); display: block; }
