/* ---------- tokens: the original OxyFlow colours ---------- */
:root {
    color-scheme: light;
    --page: #D3E3F5;
    --surface: #ffffff;
    --surface-2: #E5E5EF;
    --border: rgba(0, 35, 52, 0.10);
    --text: #434343;
    --heading: #002334;
    --text-2: #5a5a5a;
    --text-muted: #707070;
    --grid: #e6eaf0;
    --axis: #c5ccd6;
    --navy: #191F2F;
    --accent: #002334;
    --accent-ink: #ffffff;
    --value: #038E00;
    --table-head: #D3EDF5;
    --shadow: rgba(193, 193, 193, 0.35) 0px 5px 15px;

    /* chart series, from the original palette: colour follows the thing, on every chart */
    --series-consumption: #002334;
    --series-forecast: #7E366F;
    --series-produced: #5E9CA0;
    --series-stock: #4D5BD4;

    /* status, as on the original hospital list; always shown with an icon and a label */
    --good: #038E00;
    --good-bg: #DDF0F1;
    --good-ink: #038E00;
    --warning: #D4AE4D;
    --warning-bg: #F5EBD3;
    --warning-ink: #8a6300;
    --critical: #D44D4D;
    --critical-bg: #F5D3D3;
    --critical-ink: #b02a2a;
    --neutral-bg: #eeeeee;
    --neutral-ink: #666666;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
    margin: 0;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 18px 20px;
}

/* ---------- top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 18px;
    padding: 14px 20px;
    border-radius: 14px;
    background: var(--navy);
    color: #ffffff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 40px;
    width: auto;
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-sub {
    color: #c9d3e6;
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.sync-status {
    color: #c9d3e6;
    font-size: 13px;
    margin-right: 4px;
}

.btn {
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
}

/* on the navy bar: the original light-blue sidebar buttons */
.topbar .btn-primary {
    background: #D3E3F5;
    color: #002334;
}

.topbar .btn-quiet {
    color: #c9d3e6;
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: progress;
}

.btn-quiet {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}

.btn:focus-visible,
.tab:focus-visible,
.row-link:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- token form and banners ---------- */
.token-form {
    margin-bottom: 14px;
}

.field-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.token-row {
    display: flex;
    gap: 8px;
}

.field {
    flex: 1;
    min-width: 0;
    font: inherit;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid var(--axis);
    background: var(--surface);
    color: var(--text);
}

.hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 6px;
}

.banner {
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 14px;
}

.banner-error {
    background: var(--critical-bg);
    color: var(--critical-ink);
}

.banner-notice {
    background: var(--warning-bg);
    color: var(--warning-ink);
}

/* ---------- facility tabs ---------- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.tab {
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
}

.tab[aria-current="true"] {
    background: var(--navy);
    color: #ffffff;
    border-color: var(--navy);
}

.as-of {
    color: var(--text-2);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- layout ---------- */
.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

/* let wide content (tables, charts) scroll inside its card instead of stretching the page */
.grid > *,
.section > * {
    min-width: 0;
}

.grid-tiles {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
}

.section {
    margin-bottom: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--heading);
}

/* stat tiles keep the original left rule */
.tile {
    border-left: 3px solid var(--heading);
}

.card-sub {
    color: var(--text-2);
    font-size: 13px;
    margin-top: 2px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

/* ---------- stat tiles ---------- */
.tile-label {
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
}

.tile-value {
    color: var(--value);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-top: 6px;
}

.tile-value.hero {
    font-size: 42px;
}

.tile-value small {
    white-space: nowrap;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0;
    margin-left: 4px;
}

.tile-value.unavailable {
    font-size: 18px;
    color: var(--text-muted);
    letter-spacing: 0;
}

.tile-note {
    color: var(--text-2);
    font-size: 13px;
    margin-top: 8px;
}

/* ---------- status ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-critical {
    background: var(--critical-bg);
    color: var(--critical-ink);
}

.badge-low {
    background: var(--warning-bg);
    color: var(--warning-ink);
}

.badge-sufficient {
    background: var(--good-bg);
    color: var(--good-ink);
}

.badge-none {
    background: var(--neutral-bg);
    color: var(--neutral-ink);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 8px;
}

.dot-critical {
    background: var(--critical);
}

.dot-low {
    background: var(--warning);
}

.dot-sufficient {
    background: var(--good);
}

.dot-none {
    background: var(--axis);
}

/* ---------- attention list ---------- */
.attention {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.attention li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 14px;
}

.attention .badge {
    flex: 0 0 auto;
}

.all-clear {
    color: var(--text-2);
    font-size: 14px;
}

/* ---------- tables ---------- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    background: var(--table-head);
    color: var(--heading);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--grid);
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--grid);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.muted {
    color: var(--text-muted);
}

.sub {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
}

.row-link {
    font: inherit;
    font-weight: 700;
    color: var(--text);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--axis);
    text-underline-offset: 3px;
}

td.method {
    min-width: 180px;
}

td.method .badge {
    margin-left: 6px;
}

.nowrap {
    white-space: nowrap;
}

tr.chosen td {
    background: var(--surface-2);
    font-weight: 600;
}

/* ---------- days-of-cover meter ---------- */
.meter {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 170px;
}

.meter-track {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: 999px;
}

.meter-critical {
    background: var(--critical);
}

.meter-low {
    background: var(--warning);
}

.meter-sufficient {
    background: var(--good);
}

.meter-share {
    background: var(--series-forecast);
}

.meter-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 62px;
    text-align: right;
}

/* ---------- charts ---------- */
.chart-box {
    position: relative;
    height: 260px;
}

.chart-box.short {
    height: 220px;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--text-2);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-key {
    width: 14px;
    height: 3px;
    border-radius: 2px;
}

.legend-key.block {
    height: 10px;
    width: 10px;
    border-radius: 3px;
}

details.data {
    margin-top: 10px;
    font-size: 13px;
}

details.data summary {
    cursor: pointer;
    color: var(--text-2);
    width: fit-content;
}

details.data .table-wrap {
    max-height: 260px;
    overflow-y: auto;
    margin-top: 8px;
}

.empty {
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px 0;
    text-align: center;
}

/* ---------- facts list ---------- */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin: 0;
}

.facts dt {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.facts dd {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--heading);
}

.prose {
    color: var(--text-2);
    font-size: 14px;
    margin-bottom: 12px;
    max-width: 75ch;
}

.footer {
    color: var(--text-2);
    font-size: 12px;
    margin-top: 24px;
}

@media (max-width: 600px) {
    .page {
        padding: 14px 14px 32px;
    }

    .tile-value.hero {
        font-size: 40px;
    }
}

/* ---------- filter row: facility tabs + the 3 / 7 day switch ---------- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 8px;
}

.toolbar .tabs {
    margin-bottom: 0;
}

.segmented {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.segmented-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    padding: 0 8px 0 10px;
}

.segment {
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
}

.segment[aria-pressed="true"] {
    background: var(--navy);
    color: #ffffff;
}

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

.subhead {
    font-size: 14px;
    font-weight: 700;
    color: var(--heading);
    margin: 16px 0 6px;
}
