/* ============================================================================
   Asset Intelligence redesign (v2) — shared shell and components used by Asset
   Overview, Asset Planning, Asset Detail, Management Intelligence and the
   Executive Report.

   Opted into per page with the .ai-v2 modifier on the page container (next to
   the existing .ai-executive-page wrapper), so anything not yet moved across
   keeps asset-intelligence.css styling unchanged. Still plain Bootstrap +
   Radzen underneath — no new framework.
   ============================================================================ */

/* Tokens are shared with the Asset Overview sidebar (which hosts AssetDetailPanel outside the
   page container); the ground/padding shell below applies to the page container only. */
.ai-v2,
.ai-sidebar {
    --ai-accent: #1d5fa8;
    --ai-accent-dark: #123f73;
    --ai-accent-soft: #e6eef8;
    --ai-ink: #16212c;
    --ai-ink-2: #3d4652;
    --ai-muted: #5a6573;
    --ai-ground: #f5f5f2;
    --ai-surface: #ffffff;
    --ai-surface-alt: #f6f8fb;
    --ai-border: #e3e5e8;
    --ai-border-strong: #cfd4da;
    --ai-divider: #eef0f2;
    --ai-attention: #c2410c;
    --ai-attention-ink: #7c2d12;
    --ai-attention-soft: #fdf4ee;
    --ai-attention-border: #f1cdb6;
    font-variant-numeric: tabular-nums;
}

.ai-v2 {
    background: var(--ai-ground);
    border-radius: 1rem;
    padding: 1.5rem 1.75rem 2rem;
}

.ai-v2 a:not(.btn), .ai-sidebar a:not(.btn) { color: var(--ai-accent); }
.ai-v2 a:not(.btn):hover, .ai-sidebar a:not(.btn):hover { color: var(--ai-accent-dark); }

.ai-breadcrumb {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: var(--ai-muted);
}

.ai-breadcrumb a { text-decoration: none; }
.ai-breadcrumb [aria-current="page"] { color: var(--ai-ink); }

/* ---- Asset detail (full page and sidebar) ---- */

.ai-asset-detail {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.ai-asset-detail__cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

/* Two columns only when the panel itself is wide (full page), one in the 720px sidebar. */
@container (min-width: 900px) {
    .ai-asset-detail__cols { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}

.ai-asset-detail__map {
    height: 280px;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--ai-border);
}

.ai-photo {
    width: 128px;
    height: 96px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--ai-border);
}

.ai-timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
    border-left: 2px solid var(--ai-border);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    font-size: 0.85rem;
}

.ai-timeline__title { font-weight: 700; }
.ai-timeline__meta { font-size: 0.78rem; color: var(--ai-muted); }

/* ---- Page header + section tabs ---- */

.ai-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ai-page-header__eyebrow {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai-muted);
}

.ai-page-header__title {
    margin: 0.3rem 0 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ai-ink);
}

.ai-page-header__title-suffix {
    margin-left: 0.2rem;
    font-weight: 500;
    color: var(--ai-muted);
}

.ai-page-header__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--ai-muted);
}

.ai-freshness {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-freshness__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0f766e;
    flex-shrink: 0;
}

.ai-freshness--stale { color: #7a4f06; font-weight: 600; }
.ai-freshness--stale .ai-freshness__dot { background: #d08a00; }

.ai-page-header__actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ai-section-nav {
    display: flex;
    gap: 1.75rem;
    border-bottom: 1px solid #dfe2e6;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.ai-section-nav__link {
    padding: 0.6rem 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ai-muted) !important;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.ai-section-nav__link:hover { color: var(--ai-ink) !important; }

.ai-section-nav__link--active {
    font-weight: 700;
    color: var(--ai-ink) !important;
    border-bottom-color: var(--ai-accent);
}

/* ---- Buttons ---- */

.ai-v2 .btn { font-weight: 600; border-radius: 0.5rem; }

.ai-btn-lg {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ---- Panels: the one card style every v2 section uses ---- */

.ai-panel {
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    min-width: 0;
}

.ai-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ai-panel__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ai-ink);
}

.ai-panel__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.82rem;
    color: var(--ai-muted);
}

.ai-panel__link {
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.ai-panel__footnote {
    margin: 0.85rem 0 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--ai-muted);
}

.ai-stack { display: flex; flex-direction: column; gap: 1.5rem; }

.ai-grid-12 {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1.5rem;
}

.ai-span-4 { grid-column: span 4; }
.ai-span-5 { grid-column: span 5; }
.ai-span-6 { grid-column: span 6; }
.ai-span-7 { grid-column: span 7; }
.ai-span-8 { grid-column: span 8; }
.ai-span-12 { grid-column: span 12; }

/* ---- Filter bar ---- */

.ai-filterbar {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
}

.ai-filterbar__group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.ai-filterbar__group--primary {
    padding-right: 1rem;
    border-right: 1px solid var(--ai-border);
    min-width: 260px;
    max-width: 420px;
}

.ai-filterbar__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ai-muted);
    margin: 0;
}

.ai-filterbar .form-select,
.ai-filterbar .form-control,
.ai-page-header__actions .form-select {
    min-height: 40px;
    border-color: var(--ai-border-strong);
    border-radius: 0.5rem;
}

.ai-filterbar__status {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--ai-muted);
    padding-bottom: 0.6rem;
}

.ai-filterbar__status strong { color: var(--ai-ink); }

.ai-segment-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: var(--ai-accent-soft);
    border: 1px solid #c7d8ee;
    border-radius: 10px;
    color: var(--ai-accent-dark);
    font-size: 0.9rem;
}

/* ---- Data confidence strip ---- */

.ai-confidence {
    display: flex;
    gap: 1.75rem;
    align-items: stretch;
}

.ai-confidence__intro {
    width: 250px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-confidence__intro p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--ai-muted);
}

.ai-confidence__dims {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 1.25rem;
}

.ai-dim { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.ai-dim__name { font-size: 0.82rem; font-weight: 600; color: var(--ai-ink); }
.ai-dim__value { display: flex; align-items: baseline; gap: 0.5rem; }
.ai-dim__pct { font-size: 1.35rem; font-weight: 700; color: var(--ai-ink); }
.ai-dim__note {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--ai-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-dim__note--caveat { color: #7a4f06; -webkit-line-clamp: unset; }

.ai-meter {
    height: 6px;
    border-radius: 3px;
    background: #eceef1;
    overflow: hidden;
}

.ai-meter__fill {
    height: 100%;
    border-radius: 3px;
    background: #2a78d6;
}

.ai-status {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.ai-status-text { font-size: 0.75rem; font-weight: 600; }

.ai-status--strong { background: #d9f0ec; color: #0b5049; }
.ai-status-text--strong { color: #0f5f58; }
.ai-meter__fill--strong { background: #0f766e; }

.ai-status--adequate { background: #e6f0fb; color: #174f8c; }
.ai-status-text--adequate { color: #174f8c; }
.ai-meter__fill--adequate { background: #2a78d6; }

.ai-status--limited { background: #fdf0d5; color: #7a4f06; }
.ai-status-text--limited { color: #7a4f06; }
.ai-meter__fill--limited { background: #d08a00; }

.ai-status--critical { background: #fbe4d8; color: #8a2c0d; }
.ai-status-text--critical { color: #8a2c0d; }
.ai-meter__fill--critical { background: var(--ai-attention); }

/* ---- Headline figures ---- */

.ai-headline {
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    overflow: hidden;
}

.ai-headline__primary,
.ai-headline__secondary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ai-headline__secondary { border-top: 1px solid var(--ai-border); }

.ai-figure {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.ai-figure + .ai-figure { border-left: 1px solid var(--ai-border); }

.ai-figure__label { font-size: 0.82rem; font-weight: 600; color: var(--ai-muted); }

.ai-figure__value {
    font-size: clamp(1.6rem, 1.4vw + 1rem, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--ai-ink);
    overflow-wrap: anywhere;
}

/* A figure that cannot be measured keeps its slot but reads as a statement, not a number. */
.ai-figure__value--muted { font-size: 1.35rem; color: var(--ai-ink-2); letter-spacing: 0; }

.ai-figure__note { font-size: 0.8rem; line-height: 1.4; color: var(--ai-muted); }

.ai-figure--attention { background: var(--ai-attention-soft); }
.ai-figure--attention .ai-figure__label { color: #9a3412; }
.ai-figure--attention .ai-figure__value,
.ai-figure--attention .ai-figure__note { color: var(--ai-attention-ink); }

/* Secondary headline row: same anatomy as a primary figure, smaller value. */
.ai-figure--compact { padding: 0.9rem 1.5rem 1rem; }
.ai-figure--compact .ai-figure__value { font-size: 1.2rem; letter-spacing: -0.01em; }
.ai-figure--compact .ai-figure__value--muted { font-size: 1rem; }
.ai-figure--compact .ai-figure__note { font-size: 0.75rem; }

.ai-figure-sm {
    padding: 0.85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
}

.ai-figure-sm + .ai-figure-sm { border-left: 1px solid var(--ai-border); }
.ai-figure-sm__label { font-size: 0.82rem; color: var(--ai-muted); }
.ai-figure-sm__value { font-size: 1.05rem; font-weight: 700; color: var(--ai-ink); text-align: right; }

/* ---- "Where to act" callout ---- */

.ai-callout {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    padding: 1rem 1.1rem;
    background: var(--ai-attention-soft);
    border: 1px solid var(--ai-attention-border);
    border-radius: 10px;
    margin-bottom: 1rem;
}

.ai-callout__figure {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ai-attention-ink);
    white-space: nowrap;
}

.ai-callout__figure small { font-size: 1rem; font-weight: 600; }
.ai-callout__figure + .ai-callout__figure { padding-left: 1.25rem; border-left: 1px solid var(--ai-attention-border); }

.ai-callout__text {
    margin: 0;
    flex: 1;
    min-width: 220px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #5b2410;
}

.ai-callout--calm {
    background: var(--ai-surface-alt);
    border-color: var(--ai-border);
}

.ai-callout--calm .ai-callout__text { color: var(--ai-ink-2); }

/* ---- Tables ---- */

.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.ai-executive-page .ai-table thead th,
.ai-table th {
    padding: 0.55rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ai-muted);
    text-align: left;
    border-bottom: 1px solid var(--ai-border) !important;
    background: transparent;
    text-transform: none;
    letter-spacing: 0;
}

.ai-table td {
    padding: 0.7rem 0.5rem;
    border-bottom: 1px solid var(--ai-divider);
    vertical-align: middle;
}

.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-table th:first-child, .ai-table td:first-child { padding-left: 0; }
.ai-table th:last-child, .ai-table td:last-child { padding-right: 0; }
.ai-executive-page .ai-table .num, .ai-table .num { text-align: right; white-space: nowrap; }
.ai-table__rank { color: var(--ai-muted); width: 2rem; }
.ai-table__sub { font-size: 0.75rem; color: var(--ai-muted); }

.ai-link-button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--ai-ink);
    text-align: left;
    cursor: pointer;
}

.ai-link-button:hover { color: var(--ai-accent); text-decoration: underline; }
.ai-link-button:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 2px; border-radius: 2px; }

.ai-swatch-label { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }

.ai-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.ai-swatch--round { border-radius: 50%; }

.ai-timeleft { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.ai-timeleft .ai-meter { width: 80px; flex-shrink: 0; }
.ai-timeleft .ai-meter__fill { background: var(--ai-attention); }

/* ---- Briefing ---- */

.ai-briefing {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    font-size: 0.88rem;
    line-height: 1.45;
}

.ai-briefing li { display: flex; gap: 0.65rem; align-items: flex-start; }

.ai-tag {
    flex-shrink: 0;
    min-width: 74px;
    text-align: center;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ai-tag--critical { background: #fbe4d8; color: #8a2c0d; }
.ai-tag--warning { background: #fdf0d5; color: #7a4f06; }
.ai-tag--gap,
.ai-tag--info { background: #eceef1; color: var(--ai-ink-2); }
.ai-tag--positive,
.ai-tag--known { background: #d9f0ec; color: #0b5049; }

/* ---- Chips ---- */

.ai-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: #f1f3f5;
    font-size: 0.8rem;
    color: var(--ai-ink);
}

.ai-chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Column chart (replacement exposure by band) ---- */

.ai-columns {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.85rem;
    align-items: end;
    height: 230px;
    border-bottom: 1px solid var(--ai-border-strong);
    padding: 0 0.25rem;
}

.ai-columns__col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    height: 100%;
    min-width: 0;
}

.ai-columns__value { font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.ai-columns__bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 2px; }

.ai-columns-axis {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.85rem;
    padding: 0.45rem 0.25rem 0;
    text-align: center;
    font-size: 0.8rem;
}

.ai-columns-axis strong { display: block; font-weight: 600; }
.ai-columns-axis span { color: var(--ai-muted); }

/* ---- Horizontal bars (exposure by class) ---- */

.ai-hbars { display: flex; flex-direction: column; gap: 0.65rem; font-size: 0.82rem; }

.ai-hbar {
    display: grid;
    grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.ai-hbar__label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-hbar__track { display: flex; height: 18px; }
.ai-hbar__due { background: var(--ai-attention); border-radius: 3px 0 0 3px; }
.ai-hbar__rest { background: #a6c6ec; border-radius: 0 3px 3px 0; flex-grow: 1; }
.ai-hbar__due:only-child { border-radius: 3px; }
.ai-hbar__value { text-align: right; white-space: nowrap; }
.ai-hbar__value span { color: var(--ai-muted); }

.ai-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.78rem;
    color: var(--ai-muted);
}

.ai-legend__item { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---- Stacked 100% bars (condition mix, data quality) ---- */

.ai-stackbar {
    display: flex;
    height: 22px;
    border-radius: 4px;
    overflow: hidden;
    background: #eceef1;
}

.ai-stackbar > span { display: block; height: 100%; }

.ai-stackbar-rows {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 1rem 1.25rem;
    align-items: start;
    font-size: 0.82rem;
    margin: 0;
}

.ai-stackbar-rows > dt { font-weight: 600; padding-top: 0.15rem; }
.ai-stackbar-rows > dd { margin: 0; }
.ai-stackbar-rows .ai-legend { margin-top: 0.4rem; }

/* ---- Segmented control ---- */

.ai-segmented {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: #f1f3f5;
    border-radius: 10px;
    flex-wrap: wrap;
}

.ai-segmented__btn {
    min-height: 34px;
    padding: 0 0.8rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ai-muted);
}

.ai-segmented__btn:hover { color: var(--ai-ink); }

.ai-segmented__btn[aria-selected="true"],
.ai-segmented__btn[aria-checked="true"] {
    background: #ffffff;
    color: var(--ai-ink);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

.ai-segmented__btn:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 1px; }

/* ---- Heatmap ---- */

.ai-heatmap-wrap { overflow-x: auto; }

.ai-heatmap {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    font-size: 0.82rem;
}

.ai-heatmap caption {
    caption-side: bottom;
    padding-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--ai-muted);
    text-align: left;
}

.ai-executive-page .ai-heatmap thead th,
.ai-heatmap thead th {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ai-muted);
    text-align: center;
    padding: 0.2rem;
    white-space: nowrap;
    background: transparent;
    text-transform: none;
    letter-spacing: 0;
    border: 0 !important;
}

.ai-heatmap tbody th {
    font-weight: 600;
    text-align: left;
    padding-right: 0.5rem;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-heatmap tbody th.ai-heatmap__row--unknown { color: var(--ai-muted); }
.ai-heatmap td { padding: 0; }
.ai-heatmap__total { text-align: right; font-weight: 700; padding: 0 0.25rem !important; white-space: nowrap; }

.ai-heatmap__cell {
    width: 100%;
    min-width: 56px;
    height: 46px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--ai-ink);
    cursor: pointer;
}

.ai-heatmap__cell small { display: block; font-size: 0.68rem; font-weight: 500; opacity: 0.85; }
.ai-heatmap__cell:disabled { cursor: default; }
.ai-heatmap__cell:focus-visible { outline: 3px solid var(--ai-ink); outline-offset: 1px; }
.ai-heatmap__cell:not(:disabled):hover { filter: brightness(0.95); }

.ai-heatmap__cell--l0 { background: #ffffff; border: 1px dashed #d5d9de; color: var(--ai-muted); font-weight: 500; }
.ai-heatmap__cell--l1 { background: #eef3fa; }
.ai-heatmap__cell--l2 { background: #d3e3f6; }
.ai-heatmap__cell--l3 { background: #a6c6ec; }
.ai-heatmap__cell--l4 { background: #5e9be0; color: #0b1f36; }
.ai-heatmap__cell--l5 { background: #1c5cab; color: #ffffff; }

/* Neutral ramp for the "Not assessed" / "Unknown" row — shading still shows volume, but in
   grey so an unknown is never read on the same scale as a recorded condition. */
.ai-heatmap__cell--n1 { background: #eceae4; }
.ai-heatmap__cell--n2 { background: #d9d6cc; }
.ai-heatmap__cell--n3,
.ai-heatmap__cell--n4,
.ai-heatmap__cell--n5 { background: #c3c2b7; }

.ai-heatmap__cell--highlight { outline: 2px solid var(--ai-attention); outline-offset: -2px; font-weight: 700; }
.ai-heatmap__cell--selected { box-shadow: inset 0 0 0 3px var(--ai-ink); }

.ai-heatmap-scale { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.75rem; color: var(--ai-muted); }
.ai-heatmap-scale__bar { display: flex; gap: 3px; }
.ai-heatmap-scale__bar span { flex-grow: 1; height: 10px; }
.ai-heatmap-scale__ends { display: flex; justify-content: space-between; }

/* ---- Side rail (Asset Planning) ---- */

.ai-rail-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.ai-rail {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.88rem;
}

.ai-rail__heading {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ai-muted);
    padding: 0 0.75rem 0.5rem;
}

.ai-rail__link {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--ai-ink-2) !important;
    text-decoration: none;
}

.ai-rail__link:hover { background: #eceef1; }

.ai-rail__note {
    margin-top: 1rem;
    padding: 0.85rem 0.75rem 0;
    border-top: 1px solid var(--ai-border);
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--ai-muted);
}

.ai-rail__note strong { color: var(--ai-ink); }

.ai-anchor { scroll-margin-top: 1rem; }

/* ---- Key facts row (Asset Detail) ---- */

.ai-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    overflow: hidden;
}

.ai-facts .ai-figure { border-left: 1px solid var(--ai-border); margin-left: -1px; }
.ai-facts .ai-figure__value { font-size: 1.45rem; }

.ai-grade-scale { display: flex; gap: 3px; margin-top: 0.2rem; }
.ai-grade-scale span { flex-grow: 1; height: 8px; border-radius: 2px; opacity: 0.35; }
.ai-grade-scale span.is-current { opacity: 1; outline: 2px solid var(--ai-ink); outline-offset: 1px; }

.ai-dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.75rem;
    margin: 0;
    font-size: 0.9rem;
}

.ai-dl dt { font-size: 0.75rem; font-weight: 600; color: var(--ai-muted); }
.ai-dl dd { margin: 0.1rem 0 0; overflow-wrap: anywhere; }

.ai-subheading {
    margin: 1.4rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ai-divider);
    font-size: 0.95rem;
    font-weight: 700;
}

/* ---- Domain columns (Management Intelligence) ---- */

.ai-domain {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.ai-domain__head {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--ai-border);
}

.ai-domain__source { margin-top: 0.25rem; font-size: 0.75rem; color: var(--ai-muted); }

.ai-domain__body {
    padding: 1.1rem 1.4rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    flex-grow: 1;
}

.ai-mini-figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.ai-mini-figures .ai-figure__value { font-size: 1.5rem; }

.ai-progress-row__head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
}

.ai-progress-row .ai-meter { height: 12px; border-radius: 6px; }
.ai-progress-row .ai-meter__fill { background: var(--ai-accent); border-radius: 6px; }

/* ---- Disclosure (secondary detail kept one click away rather than removed) ---- */

.ai-details > summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ai-accent);
    width: fit-content;
}

.ai-details > summary:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 2px; border-radius: 2px; }

.ai-drilldown-panel { border-left: 4px solid var(--ai-accent); }

.ai-v2 .ai-map-card__map { height: 440px; border: 1px solid var(--ai-border); }

/* ---- Radzen grids inside v2 panels: drop the card-in-card look ---- */

.ai-v2 .ai-panel .rz-data-grid { border: none; box-shadow: none; }

/* Radzen truncates cell text to one line by default; asset names are the whole point of these
   tables, so let them wrap instead of disappearing behind an ellipsis. */
.ai-v2 .rz-grid-table td .rz-cell-data,
.ai-sidebar .rz-grid-table td .rz-cell-data { white-space: normal; overflow: visible; text-overflow: clip; }

/* ---- Executive Report: a printed document, not a dashboard ---- */

.ai-report {
    background: #ffffff;
    border: 1px solid var(--ai-border);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
    padding: 3rem 3.5rem;
    max-width: 1100px;
    margin: 0 auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ai-report__cover {
    padding-bottom: 1.5rem;
    margin-bottom: 1.75rem;
    border-bottom: 2px solid var(--ai-ink);
}

.ai-report__eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ai-muted);
}

.ai-report__title,
.ai-report__h2 {
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ai-ink);
}

.ai-report__title {
    margin: 0.4rem 0 1rem;
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
}

.ai-report__meta,
.ai-report__kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.9rem 1.5rem;
    margin: 0;
}

.ai-report__meta dt,
.ai-report__kpis dt,
.ai-report__pairs dt { font-size: 0.72rem; font-weight: 600; color: var(--ai-muted); }

.ai-report__meta dd { margin: 0.1rem 0 0; font-weight: 600; }

.ai-report__kpis {
    border-top: 1px solid var(--ai-ink);
    border-bottom: 1px solid var(--ai-border-strong);
    padding: 0.9rem 0;
    margin-bottom: 1rem;
}

.ai-report__kpis dd { margin: 0.15rem 0 0; font-weight: 700; font-size: 0.95rem; }

.ai-report__pairs { margin: 0 0 1rem; }
.ai-report__pairs > div { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--ai-divider); }
.ai-report__pairs dd { margin: 0; }

.ai-report__section { margin-bottom: 2.25rem; break-inside: auto; }
.ai-report__section--closing { background: var(--ai-surface-alt); border-radius: 6px; padding: 1.1rem 1.25rem; }

.ai-report__h2 {
    margin: 0 0 0.9rem;
    font-size: 1.35rem;
    font-weight: 700;
    break-after: avoid;
}

.ai-report__h2 > span { color: var(--ai-muted); font-weight: 600; margin-right: 0.35rem; }

.ai-report__h3 { margin: 1.4rem 0 0.6rem; font-size: 1rem; font-weight: 700; break-after: avoid; }

.ai-report__source { font-size: 0.8rem; color: var(--ai-muted); }

.ai-report-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.ai-executive-page .ai-report-table thead th,
.ai-report-table thead th {
    padding: 0.4rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ai-muted);
    background: transparent;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--ai-ink) !important;
}

.ai-report-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--ai-divider);
    vertical-align: top;
}

.ai-report-table tr { break-inside: avoid; }
.ai-report-table th:first-child, .ai-report-table td:first-child { padding-left: 0; }
.ai-report-table th:last-child, .ai-report-table td:last-child { padding-right: 0; }
.ai-report-table__bar { width: 28%; }
.ai-report-table__bar > span { display: block; height: 8px; border-radius: 2px; margin-top: 0.4rem; }

@media (max-width: 576px) {
    .ai-report { padding: 1.25rem 1rem; }
    .ai-report__title { font-size: 1.6rem; }
    .ai-report__pairs > div { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
}

@media print {
    .ai-report-page { padding: 0 !important; background: #fff !important; }
    .ai-report { border: none; box-shadow: none; padding: 0; max-width: none; }
    .ai-report__section--closing { background: none; padding: 0; }
    .ai-stackbar > span, .ai-report-table__bar > span, .ai-swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Responsive ---- */

@media (max-width: 1200px) {
    .ai-span-4, .ai-span-5, .ai-span-6, .ai-span-7, .ai-span-8 { grid-column: span 12; }
    .ai-headline__secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-headline__secondary .ai-figure:nth-child(3) { border-left: none; }
    .ai-headline__secondary .ai-figure:nth-child(n+3) { border-top: 1px solid var(--ai-border); }
    .ai-confidence { flex-direction: column; gap: 1rem; }
    .ai-confidence__intro { width: auto; }
}

@media (max-width: 992px) {
    .ai-rail-layout { grid-template-columns: minmax(0, 1fr); }
    .ai-rail { position: static; flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
    .ai-rail__heading, .ai-rail__note { display: none; }
    .ai-headline__primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-headline__primary .ai-figure:nth-child(3) { border-left: none; }
    .ai-headline__primary .ai-figure:nth-child(n+3) { border-top: 1px solid var(--ai-border); }
}

@media (max-width: 576px) {
    .ai-v2 { padding: 1rem 0.75rem 1.5rem; border-radius: 0; }
    .ai-page-header__title { font-size: 1.4rem; }
    .ai-filterbar__group, .ai-filterbar__group--primary { width: 100%; min-width: 0; max-width: none; padding-right: 0; border-right: none; }
    .ai-filterbar__status { margin-left: 0; padding-bottom: 0; }
    .ai-headline__primary, .ai-headline__secondary { grid-template-columns: minmax(0, 1fr); }
    .ai-headline .ai-figure { border-left: none !important; }
    .ai-headline .ai-figure + .ai-figure { border-top: 1px solid var(--ai-border); }
    .ai-figure { padding: 1rem; }
    .ai-figure-sm { padding: 0.75rem 1rem; }
    .ai-panel { padding: 1rem; }
    .ai-dl { grid-template-columns: minmax(0, 1fr); }
    .ai-mini-figures { grid-template-columns: minmax(0, 1fr); }
    .ai-hbar { grid-template-columns: minmax(0, 1fr) auto; }
    .ai-hbar__track { grid-column: 1 / -1; grid-row: 2; }
    .ai-stackbar-rows { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
    .ai-stackbar-rows > dd { margin-bottom: 0.75rem; }
    .ai-columns-axis, .ai-columns { gap: 0.4rem; }
    .ai-columns__value { font-size: 0.68rem; }
    .ai-page-header__actions { width: 100%; }
    .ai-callout__figure { font-size: 1.5rem; }
    .ai-callout__figure + .ai-callout__figure { padding-left: 0; border-left: none; }
    .ai-heatmap { border-spacing: 3px; }
    .ai-heatmap__cell { min-width: 42px; height: 40px; font-size: 0.8rem; }
    .ai-heatmap tbody th { max-width: 96px; font-size: 0.75rem; }
}

/* A ranked asset table becomes one small card per row on a phone: rank, name, then condition and
   value, then time left — instead of four squeezed columns with the value scrolled off-screen. */
@media (max-width: 576px) {
    .ai-table--stack thead { display: none; }
    .ai-table--stack tbody tr {
        display: grid;
        grid-template-columns: 1.75rem minmax(0, 1fr) auto;
        gap: 0.3rem 0.75rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid var(--ai-divider);
    }
    .ai-table--stack tbody tr:last-child { border-bottom: none; }
    .ai-table--stack td { padding: 0 !important; border: none !important; }
    .ai-table--stack td:nth-child(1) { grid-row: 1 / span 3; }
    .ai-table--stack td:nth-child(2) { grid-column: 2 / 4; }
    .ai-table--stack td:nth-child(3) { grid-column: 2; grid-row: 2; }
    .ai-table--stack td:nth-child(4) { grid-column: 2 / 4; grid-row: 3; }
    .ai-table--stack td:nth-child(5) { grid-column: 3; grid-row: 2; }
}

@media print {
    .ai-v2 { background: #fff; padding: 0; }
    .ai-section-nav, .ai-page-header__actions, .ai-filterbar { display: none !important; }
}

/* ---- Asset domain (movable / immovable) and findings ---- */

.ai-domain-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--ai-border);
    background: var(--ai-surface-alt);
    color: var(--ai-ink-2);
    cursor: help;
}
.ai-domain-badge--movable { background: var(--ai-accent-soft); color: var(--ai-accent-dark); border-color: #c9d9ee; }
.ai-domain-badge--immovable { background: #e8f3ef; color: #0b5049; border-color: #c4e3da; }
.ai-domain-badge--unknown { background: #f1f3f5; color: var(--ai-muted); }
.ai-domain-badge__project { font-weight: 400; color: var(--ai-muted); }

.ai-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem 1.5rem;
}
.ai-metric-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.ai-check-detail td { background: var(--ai-surface-alt); }
.ai-check-row--expandable { cursor: pointer; }
.ai-check-row--expandable:hover td { background: var(--ai-surface-alt); }

.ai-finding-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.ai-finding { border-left: 3px solid var(--ai-border-strong); padding-left: 0.75rem; }
.ai-finding__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ai-finding__title { color: var(--ai-ink); }
.ai-finding__evidence { font-size: 0.85rem; color: var(--ai-ink-2); margin-top: 0.2rem; }
.ai-finding__detail { font-size: 0.85rem; color: var(--ai-ink-2); margin-top: 0.15rem; }

.ai-findings-form .form-label { font-size: 0.8rem; font-weight: 600; color: var(--ai-ink-2); margin-bottom: 0.2rem; }
.ai-findings-history { font-size: 0.82rem; color: var(--ai-ink-2); }

@media (max-width: 768px) {
    .ai-metric-grid--2 { grid-template-columns: minmax(0, 1fr); }
}

/* Pager shared by every paged list (AiPaged) */
.ai-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--ai-divider);
}
.ai-pager__summary { font-size: 0.8125rem; color: var(--ai-muted); }
.ai-pager__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.ai-pager__btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid var(--ai-border);
    border-radius: 6px;
    background: var(--ai-surface);
    color: var(--ai-ink-2);
    font: inherit;
    font-size: 0.8125rem;
    line-height: 1;
    cursor: pointer;
}
.ai-pager__btn:hover:not(:disabled) { border-color: var(--ai-accent); color: var(--ai-accent); }
.ai-pager__btn:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 2px; }
.ai-pager__btn:disabled { opacity: 0.45; cursor: default; }
.ai-pager__btn--current,
.ai-pager__btn--current:hover:not(:disabled) { background: var(--ai-accent); border-color: var(--ai-accent); color: #fff; font-weight: 600; }
.ai-pager__gap { padding: 0 0.25rem; color: var(--ai-muted); }

/* Waiting for a register from AMS */
.ai-register-loading {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    max-width: 36rem;
    margin: 3rem auto;
}
.ai-register-loading--compact { gap: 0.6rem; margin: 0; max-width: none; color: var(--ai-muted); }
.ai-register-loading__text { min-width: 0; flex: 1; }
.ai-register-loading__title { font-weight: 600; color: var(--ai-ink); }
.ai-register-loading--compact .ai-register-loading__title { font-weight: 500; color: inherit; }
.ai-register-loading__stage { color: var(--ai-muted); }
.ai-register-loading__meta { margin-top: 0.4rem; font-size: 0.8125rem; color: var(--ai-muted); font-variant-numeric: tabular-nums; }
.ai-register-loading__bar {
    position: relative;
    height: 3px;
    margin-top: 0.5rem;
    overflow: hidden;
    border-radius: 2px;
    background: var(--ai-divider);
}
.ai-register-loading__bar span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 30%;
    border-radius: 2px;
    background: var(--ai-accent);
    animation: ai-register-loading-slide 1.6s ease-in-out infinite;
}
@keyframes ai-register-loading-slide {
    from { transform: translateX(-100%); }
    to { transform: translateX(340%); }
}
@media (prefers-reduced-motion: reduce) {
    .ai-register-loading__bar span { animation: none; width: 100%; opacity: 0.4; }
}

/* Search box over a long list, and sortable column headers */
.ai-list-search { position: relative; }
.ai-list-search__icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ai-muted);
    pointer-events: none;
}
.ai-list-search__input { min-height: 40px; padding-left: 2.25rem; padding-right: 2.25rem; }
.ai-list-search__input::-webkit-search-cancel-button { display: none; }
.ai-list-search__clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--ai-muted);
    padding: 0.25rem;
    line-height: 1;
    cursor: pointer;
}
.ai-list-search__clear:hover { color: var(--ai-ink); }
.ai-list-search__clear:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 2px; border-radius: 4px; }
.ai-list--busy { opacity: 0.55; transition: opacity 0.15s ease; }
.ai-sort-button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.ai-table th.num .ai-sort-button { justify-content: flex-end; }
.ai-sort-button:hover, .ai-sort-button--active { color: var(--ai-ink); }
.ai-sort-button:focus-visible { outline: 2px solid var(--ai-accent); outline-offset: 2px; border-radius: 4px; }
.ai-sort-button__icon { font-size: 0.7rem; opacity: 0.6; }
.ai-sort-button--active .ai-sort-button__icon { opacity: 1; color: var(--ai-accent); }

/* Findings & actions slide-in panel */
.ai-row--clickable { cursor: pointer; }
.ai-row--clickable:hover td { background: var(--ai-surface-alt); }
.ai-required { color: var(--ai-attention); font-weight: 700; }
.ai-findings-panel__section {
    margin: 1.5rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ai-divider);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ai-ink);
}
.ai-findings-panel__footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.ai-findings-panel__add {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px dashed var(--ai-border-strong);
    border-radius: 8px;
    background: var(--ai-surface-alt);
}

/* Base-map switcher drawn inside the infrastructure map by facility-map.js. */
.ai-facility-map__styles {
    position: absolute; top: 10px; left: 10px; z-index: 1; display: flex; overflow: hidden;
    background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); font-size: 12px;
}
.ai-facility-map__styles button { padding: 6px 12px; border: 0; background: #fff; color: #1f2933; cursor: pointer; }
.ai-facility-map__styles button[aria-pressed="true"] { font-weight: 700; background: #eef2ff; }

/* ============================================================================
   UX makeover — brand, navigation, shared states and the infrastructure map
   ============================================================================ */

/* Brand: MST deep blue for identity (eyebrow, active tab, primary action); the
   existing accent stays for links and data. */
.ai-v2,
.ai-sidebar {
    --ai-brand: #003e5f;
    --ai-brand-dark: #002b43;
    --ai-brand-soft: #e3edf3;
    --ai-risk-critical: #b42318;
    --ai-risk-high: #e8590c;
    --ai-risk-medium: #d69e2e;
    --ai-risk-low: #2f855a;
    --ai-risk-none: #9aa5b1;
}

.ai-page-header__eyebrow { color: var(--ai-brand); }
.ai-page-header__purpose {
    margin: 0.35rem 0 0;
    max-width: 62rem;
    font-size: 0.95rem;
    color: var(--ai-ink-2);
}

.ai-v2 .btn-primary,
.ai-sidebar .btn-primary {
    background: var(--ai-brand);
    border-color: var(--ai-brand);
}
.ai-v2 .btn-primary:hover,
.ai-v2 .btn-primary:focus-visible,
.ai-sidebar .btn-primary:hover {
    background: var(--ai-brand-dark);
    border-color: var(--ai-brand-dark);
}
.ai-v2 .btn:focus-visible,
.ai-v2 a:focus-visible,
.ai-v2 button:focus-visible,
.ai-sidebar .btn:focus-visible {
    outline: 2px solid var(--ai-accent);
    outline-offset: 2px;
    box-shadow: none;
}

/* Section tabs: icon + label, brand underline on the current page. */
.ai-section-nav { gap: 1.5rem; }
.ai-section-nav__link { display: inline-flex; align-items: center; gap: 0.45rem; }
.ai-section-nav__link .bi { font-size: 0.95rem; opacity: 0.75; }
.ai-section-nav__link--active { border-bottom-color: var(--ai-brand); }
.ai-section-nav__link--active .bi { opacity: 1; color: var(--ai-brand); }

.ai-filterbar__help { font-size: 0.75rem; color: var(--ai-muted); max-width: 22rem; }
.ai-filterbar__group--muni { min-width: 240px; }

/* Rail step numbers (Risk & capital plan). */
.ai-rail__link { align-items: center; }
.ai-rail__step {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.35rem; height: 1.35rem; margin-right: 0.5rem; flex-shrink: 0;
    border-radius: 50%; background: var(--ai-brand-soft); color: var(--ai-brand);
    font-size: 0.72rem; font-weight: 700;
}
.ai-rail__link > .ai-rail__step + * { margin-right: auto; }

.ai-section-heading {
    margin: 0.5rem 0 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ai-ink);
}

/* Empty, unavailable and refusal states. */
.ai-empty {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.5rem 1.75rem;
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    color: var(--ai-ink-2);
}
.ai-empty__icon { font-size: 1.6rem; line-height: 1; color: var(--ai-muted); }
.ai-empty__title { margin: 0 0 0.25rem; font-size: 1.05rem; font-weight: 700; color: var(--ai-ink); }
.ai-empty__text { margin: 0; max-width: 60rem; }
.ai-empty--info { border-left: 4px solid var(--ai-accent); }
.ai-empty--info .ai-empty__icon { color: var(--ai-accent); }
.ai-empty--warning { border-left: 4px solid #d08a00; }
.ai-empty--warning .ai-empty__icon { color: #a16207; }
.ai-empty--danger { border-left: 4px solid var(--ai-risk-critical); }
.ai-empty--danger .ai-empty__icon { color: var(--ai-risk-critical); }

/* Active filters as chips. */
.ai-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.ai-chips__label { font-size: 0.78rem; font-weight: 600; color: var(--ai-muted); margin-right: 0.15rem; }
.ai-chips__chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.25rem 0.2rem 0.65rem;
    border: 1px solid #c9d9ee; border-radius: 999px;
    background: var(--ai-accent-soft); color: var(--ai-accent-dark);
    font-size: 0.82rem; max-width: 100%;
}
.ai-chips__name { font-weight: 600; }
.ai-chips__remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.35rem; height: 1.35rem; border: 0; border-radius: 50%;
    background: transparent; color: inherit; cursor: pointer;
}
.ai-chips__remove:hover { background: rgba(18, 63, 115, 0.12); }
.ai-chips__reset { font-size: 0.82rem; padding: 0.1rem 0.35rem; }

/* Overview: where to go next. */
.ai-next {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}
.ai-next__item {
    display: flex; gap: 0.75rem; align-items: flex-start;
    padding: 0.9rem 1rem;
    background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 10px;
    text-decoration: none; color: var(--ai-ink-2) !important;
}
.ai-next__item:hover { border-color: var(--ai-brand); background: var(--ai-brand-soft); }
.ai-next__item > .bi { font-size: 1.2rem; color: var(--ai-brand); margin-top: 0.1rem; }
.ai-next__item strong { display: block; color: var(--ai-ink); }
.ai-next__item span > span { display: block; font-size: 0.82rem; line-height: 1.4; }

/* Compact data confidence (Overview). */
.ai-confidence__dims--compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* A strip of small figures above a list (Asset portfolio). */
.ai-mini-figures--strip {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    padding: 0.85rem 1rem;
    background: var(--ai-surface-alt);
    border-radius: 10px;
}
.ai-mini-figures--strip .ai-figure__value { font-size: 1.15rem; }

.ai-icon-link { text-decoration: none; }
.ai-inline-facts { display: grid; gap: 0.25rem; font-size: 0.85rem; }
.ai-inline-facts > div { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ai-inline-facts dt { font-weight: 600; color: var(--ai-ink-2); }
.ai-inline-facts dd { margin: 0; }

/* Reports. */
.ai-report-cards { display: grid; gap: 1rem; }
.ai-report-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 1rem 1.25rem;
    align-items: start;
    padding: 1.15rem 1.35rem;
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: 12px;
}
.ai-report-card__icon {
    display: flex; align-items: center; justify-content: center;
    width: 2.6rem; height: 2.6rem; border-radius: 10px;
    background: var(--ai-brand-soft); color: var(--ai-brand); font-size: 1.25rem;
}
.ai-report-card__title { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 700; color: var(--ai-ink); }
.ai-report-card__body p { margin: 0 0 0.35rem; font-size: 0.9rem; color: var(--ai-ink-2); }
.ai-report-card__use { font-size: 0.82rem !important; color: var(--ai-muted) !important; }
.ai-report-card__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }

/* A list that becomes labelled cards on a phone (asset lists). */
@media (max-width: 576px) {
    .ai-table--cards thead { display: none; }
    .ai-table--cards tbody tr { display: block; padding: 0.65rem 0; border-bottom: 1px solid var(--ai-divider); }
    .ai-table--cards td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.1rem 0 !important; border: none !important; text-align: right; }
    .ai-table--cards td::before { content: attr(data-label); font-size: 0.75rem; font-weight: 600; color: var(--ai-muted); text-align: left; }
    .ai-table--cards td:first-child { display: block; text-align: left; }
    .ai-table--cards td:first-child::before { content: none; }
    .ai-report-card { grid-template-columns: auto minmax(0, 1fr); }
    .ai-report-card__actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---- Infrastructure map workspace ---- */

.ai-mapws-page { display: flex; flex-direction: column; gap: 0.85rem; }
.ai-mapws-page .ai-section-nav { margin-bottom: 0.5rem; }
.ai-mapws__scope { position: relative; z-index: 6; }
.ai-mapws__search { position: relative; flex: 1 1 280px; max-width: 420px; }
.ai-mapws__results {
    position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 360px; overflow-y: auto; padding: 0.35rem 0;
    background: var(--ai-surface); border: 1px solid var(--ai-border-strong); border-radius: 10px;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.18);
}
.ai-mapws__results-heading {
    padding: 0.35rem 0.85rem 0.2rem; font-size: 0.7rem; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--ai-muted);
}
.ai-mapws__results button {
    display: flex; flex-direction: column; align-items: flex-start; width: 100%;
    padding: 0.45rem 0.85rem; border: 0; background: none; text-align: left; font: inherit; font-size: 0.86rem; color: var(--ai-ink);
}
.ai-mapws__results button:hover:not(:disabled),
.ai-mapws__results button:focus-visible { background: var(--ai-accent-soft); outline: none; }
.ai-mapws__results button:disabled { opacity: 0.6; cursor: default; }
.ai-mapws__results .ai-mapws__results-action { flex-direction: row; align-items: center; color: var(--ai-accent); font-weight: 600; }
.ai-mapws__results-note { padding: 0.35rem 0.85rem; font-size: 0.82rem; color: var(--ai-muted); }

.ai-mapws__quick { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.ai-mapws__quick-label { font-size: 0.82rem; font-weight: 600; color: var(--ai-ink-2); margin-right: 0.25rem; }

.ai-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    min-height: 34px; padding: 0.25rem 0.75rem;
    border: 1px solid var(--ai-border-strong); border-radius: 999px;
    background: var(--ai-surface); color: var(--ai-ink-2); font-size: 0.85rem; font-weight: 500;
    cursor: pointer;
}
.ai-toggle:hover { border-color: var(--ai-ink-2); }
.ai-toggle[aria-pressed="true"] { background: var(--ai-ink); border-color: var(--ai-ink); color: #fff; font-weight: 600; }
.ai-toggle__dot { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--ai-risk-none); flex-shrink: 0; }
.ai-toggle--critical .ai-toggle__dot, .ai-toggle__dot.ai-toggle--critical { background: var(--ai-risk-critical); }
.ai-toggle--high .ai-toggle__dot, .ai-toggle__dot.ai-toggle--high { background: var(--ai-risk-high); }
.ai-toggle--medium .ai-toggle__dot, .ai-toggle__dot.ai-toggle--medium { background: var(--ai-risk-medium); }
.ai-toggle--low .ai-toggle__dot, .ai-toggle__dot.ai-toggle--low { background: var(--ai-risk-low); }
.ai-toggle[aria-pressed="true"] .ai-toggle__dot { box-shadow: 0 0 0 2px #fff; }

.ai-mapws__more {
    display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem 1.5rem;
    padding: 1rem 1.15rem; background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 12px;
}
.ai-mapws__more fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.ai-mapws__more legend { float: none; margin-bottom: 0.5rem; font-size: 0.82rem; font-weight: 700; color: var(--ai-ink); }
.ai-mapws__more-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; }
.ai-mapws__more-note { margin: 0.5rem 0 0; font-size: 0.75rem; color: var(--ai-muted); }
.ai-mapws__flags { display: grid; gap: 0.35rem; font-size: 0.88rem; }
.ai-mapws__flags .form-check { margin: 0; }

.ai-mapws__strip {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 12px; overflow: hidden;
}
.ai-mapws__stat {
    display: flex; flex-direction: column; gap: 0.1rem; min-width: 0;
    padding: 0.7rem 0.9rem; border: 0; border-left: 1px solid var(--ai-border);
    background: none; text-align: left; font: inherit; color: inherit;
}
.ai-mapws__stat:first-child { border-left: none; }
.ai-mapws__stat--action { cursor: pointer; }
.ai-mapws__stat--action:hover { background: var(--ai-surface-alt); }
.ai-mapws__stat-label { font-size: 0.74rem; font-weight: 600; color: var(--ai-muted); }
.ai-mapws__stat-value { font-size: 1.2rem; font-weight: 700; color: var(--ai-ink); line-height: 1.25; }
.ai-mapws__stat-note { font-size: 0.72rem; color: var(--ai-muted); overflow-wrap: anywhere; }
.ai-mapws__stat--critical .ai-mapws__stat-value { color: var(--ai-risk-critical); }
.ai-mapws__unmapped {
    padding: 0.75rem 1rem; border-radius: 10px; background: var(--ai-surface-alt);
    border: 1px dashed var(--ai-border-strong); font-size: 0.86rem; color: var(--ai-ink-2);
}

.ai-mapws {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
    gap: 1rem;
    align-items: stretch;
}
.ai-mapws__map-frame { position: relative; min-width: 0; }
.ai-mapws__map {
    height: calc(100vh - 300px); min-height: 560px; width: 100%;
    border: 1px solid var(--ai-border); border-radius: 12px; overflow: hidden; background: #eef1f4;
}
.ai-mapws__overlay {
    position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
    padding: 2rem; text-align: center; color: var(--ai-ink-2);
    background: rgba(246, 248, 251, 0.88); border-radius: 12px;
}
.ai-mapws__overlay--error { color: var(--ai-attention-ink); }
.ai-mapws__tools { position: absolute; top: 10px; right: 52px; z-index: 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ai-mapws__fit {
    padding: 6px 10px; border: 0; border-radius: 6px; background: #fff; color: #1f2933;
    font-size: 12px; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); cursor: pointer;
}
.ai-mapws__fit:hover { background: #f3f5f7; }
.ai-mapws__legend {
    position: absolute; left: 10px; bottom: 34px; z-index: 2; max-width: min(320px, calc(100% - 20px));
    display: flex; flex-direction: column; gap: 0.2rem;
    padding: 0.6rem 0.75rem; background: rgba(255, 255, 255, 0.95); border-radius: 8px;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.2); font-size: 0.78rem;
}
.ai-mapws__legend-title { font-weight: 700; color: var(--ai-ink); }
.ai-mapws__legend-note { margin-top: 0.2rem; font-size: 0.7rem; color: var(--ai-muted); line-height: 1.35; }
.ai-mapws__legend .ai-legend__item { font-size: 0.78rem; }

.ai-mapws__panel {
    display: flex; flex-direction: column; min-width: 0;
    max-height: max(560px, calc(100vh - 300px));
    background: var(--ai-surface); border: 1px solid var(--ai-border); border-radius: 12px; overflow: hidden;
}
.ai-mapws__panel-head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
    padding: 0.9rem 1rem; border-bottom: 1px solid var(--ai-border); flex-shrink: 0;
}
.ai-mapws__panel-body { padding: 1rem; overflow-y: auto; flex: 1; }
.ai-mapws__panel-body .ai-asset-detail { gap: 0.85rem; }
.ai-mapws__panel-body .ai-page-header__title { font-size: 1.15rem !important; }
.ai-mapws__panel-body .ai-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ai-mapws__panel-body .ai-facts .ai-figure { padding: 0.75rem; }
.ai-mapws__panel-body .ai-facts .ai-figure__value { font-size: 1.05rem; }
.ai-mapws__eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ai-brand); }
.ai-mapws__title { margin: 0.15rem 0 0; font-size: 1.15rem; font-weight: 700; color: var(--ai-ink); overflow-wrap: anywhere; }
.ai-mapws__section {
    margin: 1.1rem 0 0.5rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--ai-muted);
}
.ai-mapws__facts { display: grid; gap: 0.4rem; margin: 0; font-size: 0.86rem; }
.ai-mapws__facts > div { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0.5rem; }
.ai-mapws__facts dt { font-weight: 600; color: var(--ai-ink-2); }
.ai-mapws__facts dd { margin: 0; overflow-wrap: anywhere; }
.ai-mapws__facts--figures dd { font-weight: 700; color: var(--ai-ink); }
.ai-mapws__facts--figures dd span { display: block; font-weight: 400; font-size: 0.76rem; color: var(--ai-muted); }
.ai-mapws__interpretation { margin: 0.6rem 0 0; padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--ai-surface-alt); font-size: 0.86rem; color: var(--ai-ink-2); }
.ai-mapws__actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }
.ai-mapws__intro .ai-mapws__title { margin-bottom: 0.75rem; }
.ai-mapws__howto { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.7rem; font-size: 0.88rem; color: var(--ai-ink-2); }
.ai-mapws__howto li { display: flex; gap: 0.65rem; }
.ai-mapws__howto .bi { font-size: 1.05rem; color: var(--ai-brand); margin-top: 0.05rem; }
.ai-mapws__scope-note { display: grid; gap: 0.35rem; padding: 0.75rem; border-radius: 8px; background: var(--ai-surface-alt); font-size: 0.85rem; }
.ai-mapws__scope-note > div { display: flex; justify-content: space-between; gap: 0.75rem; }
.ai-mapws__scope-note span { color: var(--ai-muted); }

.ai-riskbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--ai-divider); gap: 2px; }
.ai-riskbar__seg { flex-basis: 0; min-width: 4px; }
.ai-riskbar__seg--critical { background: var(--ai-risk-critical); }
.ai-riskbar__seg--high { background: var(--ai-risk-high); }
.ai-riskbar__seg--medium { background: var(--ai-risk-medium); }
.ai-riskbar__seg--low { background: var(--ai-risk-low); }
.ai-riskbar__seg--notassessed { background: var(--ai-risk-none); }
.ai-riskbar__key { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.8rem; color: var(--ai-ink-2); }
.ai-riskbar__key li { display: inline-flex; align-items: center; gap: 0.35rem; }

.ai-map-hover .mapboxgl-popup-content { padding: 6px 10px; font-size: 12px; border-radius: 6px; }

.min-w-0 { min-width: 0; }

@media (max-width: 1400px) {
    .ai-mapws__strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ai-mapws__stat:nth-child(5) { border-left: none; }
    .ai-mapws__stat:nth-child(n+5) { border-top: 1px solid var(--ai-border); }
}

/* Tablet and phone: the map first, full width; the side panel below it, and a bottom sheet once
   something is selected so the map stays in view. */
@media (max-width: 992px) {
    .ai-mapws { grid-template-columns: minmax(0, 1fr); }
    .ai-mapws__map { height: 62vh; min-height: 380px; }
    .ai-mapws__panel { max-height: none; }
    .ai-mapws--selected .ai-mapws__panel {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
        max-height: 58vh; border-radius: 16px 16px 0 0;
        box-shadow: 0 -8px 28px rgba(16, 24, 40, 0.25);
    }
    .ai-mapws--selected .ai-mapws__panel-head::before {
        content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px;
        margin-left: -20px; border-radius: 2px; background: var(--ai-border-strong);
    }
    .ai-mapws--selected .ai-mapws__panel-head { position: relative; padding-top: 1.1rem; }
    .ai-mapws--selected { padding-bottom: 58vh; }
    .ai-mapws__more { grid-template-columns: minmax(0, 1fr); }
    .ai-mapws__search { max-width: none; }
}

@media (max-width: 576px) {
    .ai-mapws__strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-mapws__stat { border-left: none; border-top: 1px solid var(--ai-border); }
    .ai-mapws__stat:nth-child(-n+2) { border-top: none; }
    .ai-mapws__stat:nth-child(even) { border-left: 1px solid var(--ai-border); }
    .ai-mapws__legend { position: static; max-width: none; margin-top: 0.5rem; box-shadow: none; border: 1px solid var(--ai-border); }
    .ai-mapws__tools { right: 10px; top: auto; bottom: 34px; }
    .ai-mapws__facts > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .ai-section-nav { gap: 1rem; padding-right: 1.5rem; -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
    .ai-section-nav__link span { font-size: 0.88rem; }
}

@media print {
    .ai-mapws__panel, .ai-mapws__quick, .ai-mapws__more, .ai-chips, .ai-mapws__tools { display: none !important; }
}

/* ---- Asset plan (AMP/SAMP) workspace ---- */
.ai-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1rem; }
.ai-form-grid > label { display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; font-weight: 600; }

.ai-riskmatrix { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 560px; }
.ai-riskmatrix th { font-size: .8rem; font-weight: 600; text-align: center; vertical-align: middle; padding: .25rem; }
.ai-riskmatrix th[scope="row"] { text-align: right; white-space: nowrap; }
.ai-riskmatrix__corner { text-align: left !important; font-weight: 400 !important; color: var(--bs-secondary-color, #6c757d); }
.ai-riskmatrix__cell { text-align: center; border-radius: 6px; padding: .5rem .25rem; min-width: 84px; }
.ai-riskmatrix__score { font-size: .7rem; opacity: .8; }
.ai-riskmatrix__count { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.ai-riskmatrix__value { font-size: .72rem; }

.ai-jaws { width: 100%; max-width: 760px; height: auto; display: block; }
.ai-jaws__grid { stroke: rgba(128, 128, 128, .25); stroke-width: 1; }
.ai-jaws__tick { font-size: 11px; fill: currentColor; opacity: .75; }
.ai-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .85rem; margin-top: .5rem; }
.ai-legend > span { display: inline-flex; align-items: center; gap: .4rem; }

.ai-board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.ai-board__col { flex: 0 0 210px; background: var(--bs-tertiary-bg, #f6f7f9); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: 8px; padding: .5rem; min-height: 160px; }
.ai-board__col--target { outline: 2px dashed #2a78d6; outline-offset: -2px; }
.ai-board__col--over { border-color: #e34948; }
.ai-board__head { margin-bottom: .5rem; }
.ai-board__year { font-weight: 700; }
.ai-board__money { font-size: .8rem; }
.ai-board__meter { height: 4px; background: rgba(128, 128, 128, .2); border-radius: 2px; margin-top: .25rem; overflow: hidden; }
.ai-board__meter > span { display: block; height: 100%; background: #2a78d6; }
.ai-board__warn { font-size: .75rem; color: #e34948; font-weight: 600; }
.ai-board__card { background: var(--bs-body-bg, #fff); border: 1px solid var(--bs-border-color, #dee2e6); border-radius: 6px; padding: .4rem .5rem; margin-bottom: .4rem; cursor: grab; font-size: .8rem; }
.ai-board__card--deferred { border-left: 3px solid #eda100; }
.ai-board__card--held { border-left: 3px solid #4a3aa7; }
.ai-board__card--notcostable { border-left: 3px solid #c3c2b7; }
.ai-board__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-board__cost { font-size: .75rem; }
.ai-row--attention > td { background: rgba(237, 161, 0, .08); }

/* ---- AMP / SAMP print view ---- */
.ai-plandoc__actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.ai-plandoc { max-width: 960px; margin: 0 auto; line-height: 1.5; }
.ai-plandoc__cover { border-bottom: 2px solid #1f3864; margin-bottom: 1.5rem; padding-bottom: 1rem; }
.ai-plandoc__eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; color: #595959; }
.ai-plandoc__title { font-size: 2rem; font-weight: 700; color: #1f3864; margin: .25rem 0; }
.ai-plandoc__subtitle { font-size: 1.1rem; margin-bottom: .25rem; }
.ai-plandoc__meta { font-size: .85rem; color: #595959; }
.ai-plandoc__toc h2 { font-size: 1rem; font-weight: 700; margin-top: 1rem; }
.ai-plandoc__h1 { font-size: 1.4rem; font-weight: 700; color: #1f3864; margin-top: 2rem; border-bottom: 1px solid #d9e2f3; padding-bottom: .25rem; }
.ai-plandoc__h2 { font-size: 1.1rem; font-weight: 700; color: #1f3864; margin-top: 1.25rem; }
.ai-plandoc__callout { border-left: 4px solid #2a78d6; background: #e8f0fe; padding: .6rem .9rem; margin: .75rem 0; color: #102a43; }
.ai-plandoc__callout--warning { border-left-color: #eda100; background: #fff4ce; }
.ai-plandoc__table { margin: 1rem 0; overflow-x: auto; }
.ai-plandoc__table figcaption { font-weight: 700; font-size: .9rem; margin-bottom: .35rem; }
.ai-plandoc__table table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.ai-plandoc__table th, .ai-plandoc__table td { border: 1px solid #bfbfbf; padding: .25rem .4rem; vertical-align: top; }
.ai-plandoc__table th { background: #d9e2f3; color: #102a43; }
.ai-plandoc__table .num { text-align: right; white-space: nowrap; }
.ai-plandoc__note { font-size: .78rem; font-style: italic; color: #595959; margin: .25rem 0 0; }
.ai-plandoc__break { height: 0; }
@media print {
    /* Only the plan document prints without the app's sidebar and top bar. */
    body:has(.ai-plandoc-page) .sidebar,
    body:has(.ai-plandoc-page) .top-row { display: none !important; }
    body:has(.ai-plandoc-page) main { margin: 0 !important; padding: 0 !important; }
    .ai-plandoc__callout, .ai-plandoc__table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ai-plandoc-page { padding: 0; }
    .ai-plandoc { max-width: none; color: #000; }
    .ai-plandoc__break { break-after: page; }
    .ai-plandoc__h1 { break-after: avoid; }
    .ai-plandoc__table thead { display: table-header-group; }
    .ai-plandoc__table tr { break-inside: avoid; }
}

.ai-tag--backlog { background: #fde8d9; color: #8a3a0f; border: 1px solid #eb6834; }
.ai-form-row { border-bottom: 1px dashed var(--bs-border-color, #dee2e6); padding-bottom: .75rem; }
.ai-spark { display: flex; align-items: flex-end; gap: 1px; height: 28px; min-width: 0; max-width: 100%; }
.ai-spark > span { flex: 1 1 0; min-height: 1px; background: #2a78d6; border-radius: 1px 1px 0 0; }

@media (max-width: 767.98px) {
    .ai-v2 .form-select,
    .ai-v2 .form-control,
    .ai-page-header .form-select {
        min-width: 0 !important;
        width: 100%;
        max-width: 100%;
    }

    .ai-page-header__actions,
    .ai-page-header__actions .ai-filterbar__group,
    .ai-filterbar__group,
    .ai-filterbar__group--muni,
    .ai-filterbar__group--primary {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .ai-section-nav {
        gap: 0.25rem 1rem;
    }

    .ai-section-nav__link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .ai-segmented {
        display: flex;
        width: 100%;
    }

    .ai-segmented__btn {
        min-height: 44px;
        flex: 1 1 auto;
    }

    .ai-pager__btn {
        min-width: 44px;
        height: 44px;
    }

    .ai-heatmap-wrap,
    .ai-board,
    .table-responsive {
        max-width: 100%;
    }

    .ai-figure__value,
    .ai-callout__figure {
        overflow-wrap: anywhere;
    }
}

/* ---- Tablet and phone refinements ---- */

/* In-page section links (rail) once they leave the side column: tidy pills that wrap,
   so every section stays one tap away instead of a ragged run of plain links. */
@media (max-width: 992px) {
    .ai-rail { gap: 0.4rem; }
    .ai-rail__link {
        align-items: center;
        min-height: 40px;
        padding: 0.35rem 0.8rem;
        border: 1px solid var(--ai-border);
        border-radius: 999px;
        background: var(--ai-surface);
        white-space: nowrap;
    }
    .ai-rail__link > span:not(.ai-rail__step) { color: var(--ai-muted); font-variant-numeric: tabular-nums; }
    .ai-rail__link > .ai-rail__step { margin-right: 0; }
    .ai-rail__link:hover { border-color: var(--ai-brand); background: var(--ai-brand-soft); }
}

@media (max-width: 576px) {
    /* Numeric column headers may wrap; the figures below them stay on one line. Without this a
       header such as "Known replacement value" holds the table wider than a phone. */
    .ai-table th.num { white-space: normal; }
    .ai-table th,
    .ai-table td { padding-left: 0.35rem; padding-right: 0.35rem; }
    .ai-table th:first-child, .ai-table td:first-child { padding-left: 0; }
    .ai-table th:last-child, .ai-table td:last-child { padding-right: 0; }

    /* A count's share sits under it rather than beside it, so a count column stays narrow
       (e.g. "22,000 (49.6%)" in a large register). */
    .ai-table td.num > .ai-table__sub { display: block; }

    /* Small figures above a list: two per row rather than one long column. */
    .ai-mini-figures--strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1rem; }
}

/* Secondary headline figures (compact values) read two per row on most phones; the primary
   figures keep a full row each for their longer notes. Dividers use an inset shadow so the
   one-column rules above don't need overriding. */
@media (min-width: 360px) and (max-width: 576px) {
    .ai-headline__secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-headline__secondary .ai-figure + .ai-figure { border-top: none; }
    .ai-headline__secondary .ai-figure:nth-child(n+3) { border-top: 1px solid var(--ai-border); }
    .ai-headline__secondary .ai-figure:nth-child(even) { box-shadow: inset 1px 0 0 var(--ai-border); }
}


/* Section tabs never scroll sideways: when they do not fit they wrap onto another line
   (underlined tabs on desktop, pills on tablets and phones), so no tab is hidden off-screen. */
.ai-section-nav.ai-section-nav {
    flex-wrap: wrap;
    row-gap: 0.25rem;
    overflow: visible;
}

@media (max-width: 991.98px) {
    .ai-section-nav,
    .ai-section-nav.ai-section-nav {
        flex-wrap: wrap;
        gap: 0.4rem;
        overflow: visible;
        padding: 0 0 0.85rem;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .ai-section-nav__link {
        min-height: 40px;
        padding: 0.35rem 0.8rem;
        border: 1px solid var(--ai-border);
        border-radius: 999px;
        background: var(--ai-surface);
        margin-bottom: 0;
    }

    .ai-section-nav__link--active {
        border-color: var(--ai-brand);
        background: var(--ai-brand-soft);
    }
}

/* Heat map on phones: the matrix keeps its grid but fits the screen. */
@media (max-width: 576px) {
    .ai-heatmap { border-spacing: 2px; font-size: 0.75rem; }
    .ai-executive-page .ai-heatmap thead th,
    .ai-heatmap thead th { white-space: normal; font-size: 0.68rem; line-height: 1.15; padding: 0.15rem 0.05rem; }
    .ai-heatmap tbody th { max-width: 68px; font-size: 0.7rem; line-height: 1.15; white-space: normal; overflow: visible; text-overflow: clip; }
    .ai-heatmap__cell { min-width: 0; height: 36px; font-size: 0.75rem; }
}

/* Narrow phones: large registers put five-digit counts in every heat map column. */
@media (max-width: 400px) {
    .ai-heatmap { border-spacing: 1px; font-size: 0.68rem; }
    .ai-heatmap tbody th { max-width: 56px; font-size: 0.66rem; }
    .ai-heatmap__cell { padding: 0 2px; font-size: 0.68rem; letter-spacing: -0.02em; }
    .ai-heatmap__total { padding: 0 0.1rem !important; font-size: 0.68rem; }
}

/* Rail links: the section name sits next to its step number and any count goes to the right.
   (The name is a text node, which ".ai-rail__step + *" never matched, so names drifted right.) */
.ai-rail__link { justify-content: flex-start; }
.ai-rail__link > span:not(.ai-rail__step) { margin-left: auto; }
