:root {
    color-scheme: light;
    --bg: #f5f6f7;
    --surface: #ffffff;
    --surface-2: #f0f2f4;
    --ink: #191c1f;
    --muted: #66707a;
    --line: #d8dde3;
    --brand: #d71920;
    --brand-dark: #991b1f;
    --accent: #12716f;
    --warn: #9a6200;
    --bad: #9d1c26;
    --good-bg: #e8f5f0;
    --warn-bg: #fff4df;
    --bad-bg: #fdebed;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--brand-dark);
}

.topbar {
    align-items: center;
    background: #151719;
    color: #fff;
    display: flex;
    justify-content: space-between;
    min-height: 84px;
    padding: 18px clamp(18px, 4vw, 42px);
}

.topbar h1,
.login-panel h1 {
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: 0;
    line-height: 1.1;
    margin: 3px 0 0;
}

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
}

.top-actions {
    align-items: center;
    display: flex;
    gap: 14px;
    white-space: nowrap;
}

.top-actions a {
    color: #fff;
    text-decoration: none;
}

.dashboard-shell {
    margin: 0 auto;
    max-width: 1260px;
    padding: 24px clamp(14px, 3vw, 30px) 42px;
}

.status-strip {
    align-items: stretch;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.status-card,
.kpi-card,
.panel,
.empty-state,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.status-card {
    padding: 13px 14px;
}

.status-card strong {
    display: block;
    font-size: 13px;
    margin-bottom: 3px;
}

.status-card span {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.status-ok {
    background: var(--good-bg);
    border-color: #b8dcca;
}

.status-warn {
    background: var(--warn-bg);
    border-color: #f0cd8b;
}

.status-bad {
    background: var(--bad-bg);
    border-color: #f0b6bd;
}

.kpi-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 16px;
}

.filter-panel {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px 16px;
}

.filter-panel form {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-panel label {
    color: var(--muted);
    display: grid;
    font-size: 12px;
    gap: 5px;
}

.filter-panel input {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 38px;
    padding: 7px 9px;
}

.filter-panel button {
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 38px;
    padding: 8px 13px;
}

.filter-panel button[type="submit"] {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.filter-panel button[type="button"] {
    background: var(--surface-2);
    color: var(--ink);
}

.filter-panel p {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
    text-align: right;
}

.kpi-card {
    min-height: 126px;
    padding: 16px;
}

.kpi-label {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 9px;
}

.kpi-value {
    font-size: clamp(25px, 3vw, 35px);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    margin: 0;
}

.kpi-sub {
    color: var(--muted);
    font-size: 12px;
    margin: 10px 0 0;
}

.panel {
    margin-bottom: 16px;
    padding: 18px;
}

.panel-header {
    align-items: start;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.panel h2 {
    font-size: 18px;
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}

.panel p {
    color: var(--muted);
    margin: 4px 0 0;
}

.two-column {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.chart-wrap {
    min-height: 250px;
    position: relative;
}

canvas {
    display: block;
    max-width: 100%;
    width: 100%;
}

.table-scroll {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    min-width: 820px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

td.numeric,
th.numeric {
    text-align: right;
}

.pill {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
}

.pill-ok {
    background: var(--good-bg);
    color: #14533c;
}

.pill-warn {
    background: var(--warn-bg);
    color: var(--warn);
}

.pill-muted {
    background: var(--surface-2);
    color: var(--muted);
}

.source-list,
.notes-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.source-list li,
.notes-list li {
    border-top: 1px solid var(--line);
    padding: 11px 0;
}

.source-list li:first-child,
.notes-list li:first-child {
    border-top: 0;
    padding-top: 0;
}

.empty-state {
    padding: 26px;
}

.login-body {
    background: #151719;
}

.login-shell {
    align-items: center;
    display: flex;
    min-height: 100vh;
    justify-content: center;
    padding: 24px;
}

.login-panel {
    max-width: 440px;
    padding: 28px;
    width: 100%;
}

.login-form {
    display: grid;
    gap: 15px;
    margin-top: 22px;
}

.login-form label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    gap: 6px;
}

.login-form input {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    padding: 11px 12px;
}

.login-form button {
    background: var(--brand);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 12px 14px;
}

.login-error {
    background: var(--bad-bg);
    border: 1px solid #e7a9b1;
    border-radius: 6px;
    color: var(--bad);
    margin: 18px 0 0;
    padding: 10px 12px;
}

@media (max-width: 980px) {
    .status-strip,
    .kpi-grid,
    .two-column,
    .filter-panel {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-panel p {
        text-align: left;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 560px) {
    .dashboard-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .panel,
    .kpi-card,
    .filter-panel {
        padding: 14px;
    }

    .top-actions {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
}
