.dashboard-kpi-page {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-kpi-header,
.dashboard-card-header,
.dashboard-pipeline-foot,
.dashboard-pipeline-metrics,
.dashboard-top-clients li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dashboard-kpi-header h1 {
    margin: 4px 0;
    font-size: 32px;
    font-family: var(--font-heading);
}

/* HIVE-210: a multi-company rollup label ("Related companies" / "All companies")
   is not a real company name, so it gets a smaller heading than a single company. */
.dashboard-kpi-header h1.is-aggregate {
    font-size: 22px;
}

.dashboard-kpi-header p,
.dashboard-card-header span,
.dashboard-stat-card span,
.dashboard-pipeline-foot,
.dashboard-health-signal small,
.dashboard-empty {
    color: var(--text-secondary);
}

/* C3 (owner round-2): .dashboard-kpi-eyebrow removed from the selector — the
   dashboard header eyebrows were dropped; .dashboard-card-header span stays. */
.dashboard-card-header span {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: none;
}

.dashboard-period-selector {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dashboard-period-selector a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    color: var(--text-secondary);
    font-weight: 600;
    text-decoration: none;
}

.dashboard-period-selector a.active,
.dashboard-period-selector a:hover {
    background: var(--primary);
    color: #fff;
}

/* D-C4 global year/pipeline focus and scoped claim lookup. */
.dashboard-global-filters {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-filter-field {
    display: grid;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.dashboard-filter-field select {
    min-width: 116px;
    min-height: 38px;
    padding: 6px 30px 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
}

.dashboard-filter-field:last-child select {
    min-width: 190px;
}

.dashboard-claim-lookup {
    position: relative;
    width: min(100%, 760px);
    margin-top: -8px;
}

.dashboard-claim-lookup > label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.dashboard-claim-lookup__control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dashboard-claim-lookup__control:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.dashboard-claim-lookup__control input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
}

.dashboard-claim-lookup__hint {
    margin: 5px 2px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.dashboard-claim-lookup__status {
    margin: 5px 2px 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.dashboard-claim-lookup__status[hidden] {
    display: none;
}

.dashboard-claim-lookup__status[data-state="error"] {
    color: var(--danger);
}

.dashboard-claim-lookup__results {
    position: absolute;
    z-index: 30;
    top: calc(100% - 14px);
    right: 0;
    left: 0;
    max-height: 320px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg, 0 14px 30px rgba(0, 0, 0, .14));
}

.dashboard-claim-lookup__option {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.dashboard-claim-lookup__option:hover,
.dashboard-claim-lookup__option.is-active {
    background: var(--primary-light);
}

.dashboard-widget-filter-help {
    position: relative;
    display: inline-flex;
    margin-left: auto;
}

.dashboard-widget-filter-help__button {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: help;
}

.dashboard-widget-filter-help__text {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    width: min(290px, 80vw);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.45;
}

.dashboard-widget-filter-summary {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 11px;
}

.dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-stat-card,
.chart-card,
.dashboard-pipeline-card,
.dashboard-info-card,
.dashboard-health-panel,
.dashboard-top-clients {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.dashboard-stat-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--surface);
}

.dashboard-stat-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 28px;
    font-family: var(--font-heading);
}

.dashboard-stat-card small,
.dashboard-pipeline-metrics small,
.dashboard-pipeline-foot span:last-child {
    font-weight: 700;
}

.dashboard-stat-card small.up,
.dashboard-pipeline-metrics small.up,
.dashboard-pipeline-foot span.up {
    color: var(--success);
}

.dashboard-stat-card small.down,
.dashboard-pipeline-metrics small.down,
.dashboard-pipeline-foot span.down {
    color: var(--danger);
}

/* Held-98: NEUTRAL-direction KPI deltas (counts / values / payouts) render muted, never
   alarm. var(--text-muted) is theme-aware (site.css light / theme.css dark), so dark mode
   follows automatically. Red/green is now reserved for a defined bad/good direction only. */
.dashboard-stat-card small.neutral,
.dashboard-pipeline-metrics small.neutral,
.dashboard-pipeline-foot span.neutral {
    color: var(--text-muted);
}

.dashboard-chart-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
    gap: 16px;
}

.chart-card,
.dashboard-pipeline-card,
.dashboard-info-card,
.dashboard-health-panel,
.dashboard-top-clients {
    padding: 20px;
}

.dashboard-card-header {
    gap: var(--dashboard-card-header-gap, 16px);
    margin-bottom: var(--dashboard-card-header-margin, 16px);
}

.dashboard-card-header h2 {
    margin: 2px 0 0;
    font-size: 18px;
    font-family: var(--font-heading);
}

.dashboard-chart {
    min-height: 300px;
}

.chart-card .dashboard-chart + .dashboard-chart {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

.dashboard-chart--split {
    min-height: 240px;
}

.dashboard-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
    gap: 16px;
}

.dashboard-pipeline-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.dashboard-pipeline-tile {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--pipeline-color);
    border-radius: var(--radius);
    background: #fff;
}

.dashboard-pipeline-tile h3 {
    margin: 4px 0 0;
    font-size: 15px;
}

.dashboard-pipeline-code {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--pipeline-color);
    background: color-mix(in srgb, var(--pipeline-color) 14%, white);
    font-size: 12px;
    font-weight: 700;
}

.dashboard-pipeline-metrics strong {
    font-size: 24px;
    font-family: var(--font-heading);
}

.dashboard-info-card dl {
    display: grid;
    grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
    gap: 10px 16px;
}

.dashboard-info-card dt {
    color: var(--text-secondary);
    font-weight: 700;
}

.dashboard-info-card dd {
    margin: 0;
    word-break: break-word;
}

.dashboard-admin-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dashboard-health-overall {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.dashboard-health-grid {
    display: grid;
    gap: 10px;
}

.dashboard-health-signal {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.dashboard-health-signal > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.dashboard-health-signal.green,
.dashboard-health-overall.green {
    color: #276749;
    background: #f0fff4;
}

.dashboard-health-signal.yellow,
.dashboard-health-overall.yellow {
    color: #975a16;
    background: #fffaf0;
}

.dashboard-health-signal.red,
.dashboard-health-overall.red {
    color: #9b2c2c;
    background: #fff5f5;
}

.dashboard-top-clients ol {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dashboard-top-clients li {
    /* The right inset keeps the count column clear of the fixed AI-assistant
       FAB, which hangs over the card's last ~40px when this widget sits in
       the bottom-right of the canvas (FHD audit finding). */
    padding: 10px 32px 10px 0;
    border-bottom: 1px solid var(--border);
}

.dashboard-top-clients li:last-child {
    border-bottom: 0;
}

@media (max-width: 1100px) {
    .dashboard-stat-grid,
    .dashboard-chart-grid,
    .dashboard-content-grid,
    .dashboard-pipeline-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .dashboard-kpi-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-period-selector {
        flex-wrap: wrap;
        border-radius: var(--radius);
    }

    .dashboard-kpi-header-tools,
    .dashboard-global-filters,
    .dashboard-filter-field,
    .dashboard-filter-field select,
    .dashboard-claim-lookup {
        width: 100%;
    }

    .dashboard-global-filters {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        min-width: 0;
    }

    .dashboard-filter-field,
    .dashboard-filter-field select,
    .dashboard-filter-field:last-child select {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* The same localized applicability text is always rendered as the mobile
       summary below the card. Hide the tooltip trigger as one unit so touch
       users are never left with a visible button whose popup cannot render. */
    .dashboard-widget-filter-help {
        display: none;
    }

    /* Mobile has no reliable hover: keep filter applicability visible. */
    .dashboard-widget-filter-summary {
        display: block;
    }

    /* The user-activity grid is 5 fixed 1fr columns; at phone widths the cells
       can't shrink below their number + "LIVE" badge min-content and overflow
       the section card by a few px. Drop to 2 columns + let cells shrink. */
    .user-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .user-stat-cell { min-width: 0; }
}

/* ============================================================
   Redesign 2026-05-17 — four sections below the claims top half.
   .section-card is the shared container for: user-activity grid,
   integrations grid, recent-activity feed, infra-health rail.
   ============================================================ */
.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}
/* User activity grid — 5 mini-cells. */
.user-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}
.user-stat-cell {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0,0,0,0.02);
    display: flex; flex-direction: column; gap: 4px;
    position: relative;
}
.user-stat-cell span.lbl {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: none;
    color: var(--text-secondary);
}
.user-stat-cell strong {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.user-stat-cell small { font-size: 11px; color: var(--text-muted); }
.user-stat-cell small.up   { color: var(--success); }
.user-stat-cell small.down { color: var(--danger); }
.user-stat-cell small.neutral { color: var(--text-muted); }
.user-stat-cell.bad strong { color: var(--danger); }
.user-stat-cell.live::before {
    content: "LIVE";
    position: absolute; top: 8px; right: 10px;
    font-size: 8px; font-weight: 700; letter-spacing: 0.1em;
    color: #27AE60; padding: 1px 5px;
    border: 1px solid rgba(39,174,96,0.35); border-radius: 3px;
    background: rgba(39,174,96,0.06);
}

/* Integration cards — bigger than B2 pills so AI model names + token totals
   read cleanly. Auto-fit 3-4 across on wide screens. */
.integration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.integration-card {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0,0,0,0.02);
    display: flex; flex-direction: column; gap: 4px;
}
.integration-card .top { display: flex; align-items: center; gap: 8px; }
.integration-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.integration-dot.ok   { background: #27AE60; box-shadow: 0 0 0 3px rgba(39,174,96,0.15); }
.integration-dot.warn { background: #F08A33; box-shadow: 0 0 0 3px rgba(240,138,51,0.15); }
.integration-dot.bad  { background: #EB5757; box-shadow: 0 0 0 3px rgba(235,87,87,0.15); }
.integration-card .name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.integration-card .subtype {
    font-family: 'Menlo','Consolas',monospace;
    font-size: 11px; color: var(--text-muted);
    padding-left: 16px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.integration-card .usage {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    padding-left: 16px;
    margin-top: 4px;
}
.integration-card .usage-label {
    font-size: 11px;
    color: var(--text-muted);
    padding-left: 16px;
}

/* Recent activity feed — same row layout as the existing dashboard feed. */
.section-card .activity-list { list-style: none; padding: 0; margin: 0; }
.section-card .activity-item {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start; font-size: 13px;
}
.section-card .activity-item:last-child { border-bottom: none; }
.section-card .activity-time {
    color: var(--text-muted); font-size: 12px;
    width: 140px; flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.section-card .activity-icon {
    width: 18px; text-align: center; flex-shrink: 0;
}
.section-card .activity-icon.ok   { color: var(--success); }
.section-card .activity-icon.warn { color: var(--warning); }
.section-card .activity-icon.err  { color: var(--danger); }
.section-card .activity-icon.info { color: var(--info); }
.section-card .activity-text { color: var(--text); }
.section-card .activity-text strong { font-weight: 600; }
.section-card .activity-text a { color: var(--primary); text-decoration: none; }
.section-card .activity-text a:hover { text-decoration: underline; }
/* Infra health row — 3 light cards, no links. */
.health-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.health-cell {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0,0,0,0.02);
    display: flex; flex-direction: column; gap: 4px;
}
.health-cell .head { display: flex; align-items: center; justify-content: space-between; }
.health-cell .head strong {
    font-family: 'Menlo','Consolas',monospace;
    font-size: 13px; font-weight: 600; color: var(--text);
}
.health-cell .ok-badge {
    font-size: 10px; font-weight: 700; color: #27AE60;
    padding: 1px 6px; border-radius: 3px;
    background: rgba(39,174,96,0.1); border: 1px solid rgba(39,174,96,0.25);
}
.health-cell small { font-size: 11px; color: var(--text-muted); }

@media (max-width: 1100px) {
    .user-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .health-row { grid-template-columns: 1fr; }
}

/* E2 drill-through (phase-3 §E2): the "open filtered source" affordance.
   Card-header cards get a small ↗ link (the header is already a flex row with
   justify-content:space-between, so it sits at the right edge); KPI stat cards
   become a whole-card link. Both hrefs are server-built + scope-safe. */
.dashboard-drill-link {
    flex: none;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--primary);
    text-decoration: none;
}
.dashboard-drill-link:hover,
.dashboard-drill-link:focus-visible { text-decoration: underline; }

.dashboard-stat-card--link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s ease, transform .15s ease;
}
.dashboard-stat-card--link:hover,
.dashboard-stat-card--link:focus-visible {
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
    transform: translateY(-1px);
}

/* Pipeline tiles adapt inside the fixed-unit tile. The tile grid owns outer
   height; the pipeline list is the signposted internal scroll region. */
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-grid {
    flex: 1;
    min-height: 0;
    align-content: start;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-card {
    /* The card's intrinsic tile stack must never defeat the saved height —
       cap per span and scroll internally (review plan W3). */
    overflow: hidden;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-grid {
    overflow-y: auto;
    scrollbar-gutter: stable;
    /* Signpost: fade the bottom edge while more tiles are scrollable. */
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-grid {
    gap: 8px;
    padding-right: 4px;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-tile {
    padding: 9px 12px;
    gap: 6px;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-metrics strong {
    font-size: 18px;
}
.dashboard-widget-cell[data-widget-rows] .dashboard-pipeline-tile h3 {
    margin: 0;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
