:root {
    --eg-chart-height: 420px;
}

.map-full {
    position: relative;
    height: calc(100vh - 56px - 60px);
    min-height: 400px;
}
#map {
    height: 100%;
    width: 100%;
}

.station-header .station-meta { font-variant-numeric: tabular-nums; }

.live-tile {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    padding: .6rem .9rem;
    min-width: 110px;
    transition: opacity .15s ease;
}
.live-tile .label {
    font-size: .7rem;
    text-transform: uppercase;
    color: var(--bs-secondary);
    letter-spacing: .05em;
}
.live-tile .value {
    font-size: 1.3rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.is-stale .live-tile { opacity: .55; filter: grayscale(.6); }
.is-stale .live-tile .value { font-weight: 500; }

.chart-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.chart-toolbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-left: auto;
}
.chart-toolbar-metrics {
    padding-top: .5rem;
    border-top: 1px dashed var(--bs-border-color);
}
.chart-toolbar-hint {
    font-size: .75rem;
    letter-spacing: .02em;
    color: var(--bs-secondary);
    display: none;
}
@media (min-width: 768px) {
    .chart-toolbar-hint { display: inline; }
}

.chart-card .chart-wrap {
    position: relative;
    height: var(--eg-chart-height);
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    overflow: hidden;
    padding: .5rem;
}

.station-collapse > summary {
    cursor: pointer;
    list-style: none;
    padding: .6rem 1rem;
    color: var(--bs-secondary);
    font-size: .875rem;
    font-weight: 500;
    user-select: none;
}
.station-collapse > summary::-webkit-details-marker { display: none; }
.station-collapse > summary::before {
    content: '▸';
    display: inline-block;
    width: 1em;
    color: var(--bs-secondary);
    transition: transform 150ms ease;
}
.station-collapse[open] > summary::before { transform: rotate(90deg); }
.station-collapse[open] > summary { border-bottom: 1px dashed var(--bs-border-color); margin-bottom: .5rem; }

.station-health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem 1.25rem;
    align-items: end;
}
.station-health-grid .spark-tile .spark-value {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}
.station-health-grid .spark-tile svg {
    width: 100%;
    height: 36px;
    display: block;
}

#chart {
    width: 100%;
    height: 100%;
    transition: opacity 180ms ease-out;
}
#chart .uplot { width: 100%; }

.chart-toolbar .btn-group .btn { min-width: 3rem; }

/* Narrow viewports: let the range btn-group wrap, drop the right-align pin
   so smooth/normalize controls flow under, reduce the per-button min-width
   so the 9-item group fits more cleanly on two rows. */
@media (max-width: 600px) {
    .chart-toolbar { gap: .5rem; }
    .chart-toolbar .btn-group { flex-wrap: wrap; }
    .chart-toolbar .btn-group .btn { min-width: 2.5rem; flex: 0 0 auto; }
    .chart-toolbar-right { gap: .75rem; margin-left: 0; width: 100%; }
    .chart-toolbar-metrics { gap: .35rem; }
    .chart-toolbar-metrics .form-check-inline { margin-right: .5rem; }
    :root { --eg-chart-height: 320px; }
}

.chart-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--bs-secondary);
    pointer-events: none;
    font-size: .9rem;
}

.chart-summary {
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    color: var(--bs-secondary);
}
.chart-summary .row-line {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: .25rem 0;
    border-bottom: 1px dashed var(--bs-border-color);
}
.chart-summary .row-line:last-child { border-bottom: 0; }
.chart-summary .swatch {
    display: inline-block;
    width: 0.75rem; height: 0.75rem;
    border-radius: 2px;
    vertical-align: middle;
}
.chart-summary .name   { color: var(--bs-body-color); font-weight: 500; min-width: 3.5rem; }
.chart-summary .stat   { display: inline-flex; gap: .25rem; white-space: nowrap; }
.chart-summary .stat b { font-weight: 600; color: var(--bs-body-color); }
.chart-summary .stat span { text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; }

@media (max-width: 720px) {
    .chart-summary .row-line { gap: .75rem; flex-wrap: wrap; }
    .chart-summary .stat     { flex-direction: column; gap: 0; align-items: flex-start; }
    .chart-summary .stat b   { font-size: .9rem; line-height: 1.2; }
    .chart-summary .stat span { font-size: .65rem; line-height: 1; }
}

.census-alert-row {
    display: grid;
    grid-template-columns: minmax(12rem, 1fr) minmax(14rem, auto) 4rem;
    align-items: center;
    gap: 1rem;
    padding: .4rem 0;
    border-bottom: 1px dashed var(--bs-border-color);
}
.census-alert-row:last-child { border-bottom: 0; }
.census-alert-figures { font-variant-numeric: tabular-nums; }
.census-alert-figures span + span { margin-left: .5rem; }
.census-alert-score { text-align: right; font-variant-numeric: tabular-nums; }

.census-row {
    display: grid;
    grid-template-columns: minmax(8rem, 12rem) 1fr 3rem;
    align-items: center;
    gap: .75rem;
    padding: .35rem 0;
    border-bottom: 1px dashed var(--bs-border-color);
}
.census-row:last-child { border-bottom: 0; }
.census-name  { font-size: .9rem; }
.census-count { font-size: .9rem; font-variant-numeric: tabular-nums; text-align: right; }
.census-bar   { height: .5rem; background: var(--bs-light); border-radius: .25rem; overflow: hidden; }
.census-bar-fill { height: 100%; background: var(--bs-primary); opacity: .7; }

/* --- Station search (navbar) --------------------------------------------- */
.station-search { min-width: 200px; }
@media (min-width: 768px) {
    .station-search { width: 320px; }
}
.station-search .dropdown-menu {
    max-height: 24rem;
    overflow-y: auto;
    margin-top: .25rem;
}
.station-search .dropdown-item {
    padding-top: .4rem;
    padding-bottom: .4rem;
}
.station-search .dropdown-item.active {
    /* Subtle — just a tint, not a shout. Keeps "Enter picks the top row"
       discoverable without making the first result feel "chosen". */
    background-color: var(--bs-tertiary-bg);
    color: inherit;
    box-shadow: inset 2px 0 0 var(--bs-primary);
}
