.dashboard-page {
    display: grid;
    gap: 1rem;
}

.dashboard-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
}

/* The page title is an <h1>, and this rule was written for an <h2> that the markup
 * never had — so the dashboard's own title fell through to Bootstrap's h1 and
 * rendered at 40px in weight 500. That is display-scale type on an operational
 * surface, and the world reserves display for the marketing boundary. Headline
 * role: 1.5rem at 700, which is also the largest type the app is allowed. */
.dashboard-heading h1 {
    margin: 0;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--type-headline);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-wrap: balance;
}

.dashboard-heading p:last-child {
    margin: 0.35rem 0 0;
    color: var(--ink-muted);
}

.dashboard-heading .btn {
    flex: 0 0 auto;
}

/* While data reloads the button stays focusable (aria-disabled, not disabled),
 * its label reads "Refreshing…" and the icon turns, so the state is visible as
 * well as announced. */
.dashboard-heading .btn[aria-busy='true'] {
    cursor: progress;
}

.dashboard-heading .btn[aria-busy='true'] .mdi {
    display: inline-block;
    animation: dashboard-refresh-spin 0.9s linear infinite;
}

@keyframes dashboard-refresh-spin {
    to {
        transform: rotate(360deg);
    }
}

.dashboard-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-metric {
    position: relative;
    min-width: 0;
    padding: 1rem 1.1rem;
    overflow: hidden;
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* A one-pixel leading rule, not a side stripe: at two pixels it read as a
 * category tab rather than a rail entry, and a coloured edge on a card is a
 * category habit this world does not use. The rule stays as the at-a-glance
 * marker; the number itself carries the state, which is what the reader is
 * actually looking at. */
.dashboard-metric::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 1px;
    background: var(--rule-strong);
    content: "";
}

/* Tone classes are added by the page script only once a count above zero has
 * loaded, so a loading or failed card never borrows an alarm colour. */
.dashboard-metric-warning::before {
    background: var(--warn);
}

.dashboard-metric-danger::before {
    background: var(--danger);
}

.dashboard-metric-link,
.dashboard-metric small {
    display: block;
    color: var(--ink-muted);
}

/* The label is the link, stretched over the whole card, so the card opens the
 * queue behind its number while the figure stays plain text for screen readers. */
.dashboard-metric-link {
    min-height: 2.5em;
    text-decoration: none;
    font-size: var(--type-meta);
    font-weight: 600;
    line-height: 1.25;
}

.dashboard-metric strong {
    display: block;
    margin: 0.4rem 0 0.15rem;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: var(--type-metric);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* The state lands on the figure, not only on the card's edge. A liaison scans
 * four numbers across a rail before it scans any label, and the tone is
 * reinforced by the wording either side of it, so nothing here is carried by
 * colour alone. --warn-ink rather than --warn: the mark colour is not a label
 * colour, and only the ink step clears AA. */
.dashboard-metric-warning strong {
    color: var(--warn-ink);
}

.dashboard-metric-danger strong {
    color: var(--danger);
}

.dashboard-metric-link::after {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    content: "";
}

.dashboard-metric:hover {
    border-color: var(--rule-strong);
}

.dashboard-metric:hover .dashboard-metric-link {
    color: var(--brand-ink);
}

.dashboard-metric:has(.dashboard-metric-link:focus-visible) {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

.dashboard-metric-link:focus-visible {
    outline: none;
}

.dashboard-metric small {
    font-size: var(--type-micro);
}

.dashboard-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(20rem, 0.9fr);
    gap: 1rem;
    align-items: start;
}

/* The open-leg total reads as a count beside the title, not as more title. */
.dashboard-panel-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.5rem;
    margin-left: 0.5rem;
    padding: 0 0.5rem;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--ink-2);
    font: 600 var(--type-meta)/1 var(--font-ui);
    font-variant-numeric: tabular-nums;
    vertical-align: 0.15em;
}

.dashboard-panel-count:empty {
    display: none;
}

.dashboard-workspace > .fx-panel {
    min-width: 0;
}

/* With nothing to show, the notifications panel is one line: its title and
 * "No notifications." side by side, instead of a tall card for a sentence. */
.fx-panel.is-empty {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 1rem;
    padding-block: 0.75rem;
}

.fx-panel.is-empty .fx-panel-head {
    margin-bottom: 0;
}

.fx-panel.is-empty .dashboard-notifications-list .list-group-item {
    padding: 0;
    border: 0;
}

.dashboard-notifications-list {
    max-height: 31rem;
    overflow-y: auto;
}

.dashboard-notifications-list .list-group-item {
    padding: 0.75rem 0.5rem;
    border-color: var(--rule);
    background: transparent;
    color: var(--ink-2);
    font-size: var(--type-meta);
}

.dashboard-notifications-list label.list-group-item {
    cursor: pointer;
}

.dashboard-notifications-list label.list-group-item:hover {
    background: var(--surface-2);
}

@media (max-width: 1199px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Two-up, a loaded caption often wraps where "Loading…" did not. */
    .dashboard-metric small {
        min-height: 2lh;
    }

    .dashboard-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .dashboard-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .dashboard-metric-link {
        min-height: 1.5rem;
    }
}

/* On a phone the four counts stay two-up, so the exceptions and the volume panels
 * below them are one short scroll away instead of four card-heights down. They only
 * stack when a column would be too narrow to hold a two-line label. */
@media (max-width: 339px) {
    .dashboard-metrics {
        grid-template-columns: 1fr;
    }
}
