:root {
    color-scheme: dark;
    --bg: #080b0f;
    --surface: #111820;
    --surface-2: #151e28;
    --border: #263442;
    --text: #eef5fb;
    --muted: #8b9aaa;
    --amber: #ffce5c;
    --red: #ff4d5f;
    --blue: #3f8cff;
    --green: #1ed99d;
    --purple: #a172ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
    width: min(1560px, calc(100vw - 36px));
    margin: 0 auto;
    padding: 16px 0 34px;
}

.masthead,
.control-strip,
.plot-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.masthead {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    padding: 13px 20px 12px;
    margin-bottom: 8px;
}

h1,
h2,
p {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(1.55rem, 2.6vw, 2.5rem);
    line-height: 1.05;
}

.control-strip {
    display: grid;
    grid-template-columns: minmax(440px, 0.95fr) minmax(680px, 1.2fr);
    gap: 1px;
    overflow: hidden;
    margin-bottom: 8px;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(132px, 1fr));
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
}

label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    min-width: 0;
}

input,
select {
    min-width: 0;
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #0b1117;
    color: var(--text);
    padding: 0 10px;
    font: inherit;
    font-weight: 650;
}

.summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(112px, 1fr));
    gap: 1px;
    overflow: hidden;
}

.summary div {
    background: var(--surface-2);
    min-width: 0;
    padding: 10px 14px;
}

.summary span {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.summary strong {
    display: block;
    margin-top: 5px;
    font-size: clamp(1.15rem, 1.55vw, 1.7rem);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.plot-card {
    padding: 16px;
    margin-top: 10px;
}

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.card-head h2 {
    font-size: 1rem;
}

.card-head span {
    color: var(--muted);
    font-size: 0.86rem;
}

.chart-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.chart-legend i {
    display: inline-block;
    width: 22px;
    height: 3px;
    border-radius: 999px;
}

.legend-red {
    background: var(--red);
}

.legend-blue {
    background: var(--blue);
}

.legend-green {
    background: var(--green);
}

.plot {
    position: relative;
    width: 100%;
    height: 430px;
}

.plot-small {
    height: 370px;
}

.uplot {
    background: transparent;
    color: var(--muted);
    font-family: Inter, sans-serif;
}

.u-legend {
    color: var(--text);
    font-size: 0.78rem;
}

.u-title {
    color: var(--text);
}

.u-select {
    background: rgba(255, 206, 92, 0.12);
    border: 1px solid rgba(255, 206, 92, 0.42);
}

.chart-tooltip {
    position: fixed;
    z-index: 10;
    min-width: 190px;
    max-width: 280px;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 12px));
    border: 1px solid #334457;
    border-radius: 8px;
    background: rgba(8, 11, 15, 0.96);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.42);
    color: var(--text);
    padding: 10px 11px;
    font-size: 0.82rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.08s ease;
}

.chart-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.tooltip-date {
    margin-bottom: 7px;
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap;
}

.tooltip-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 7px;
    align-items: center;
    margin-top: 5px;
}

.tooltip-swatch {
    width: 18px;
    height: 3px;
    border-radius: 999px;
}

.tooltip-label {
    color: #c9d5e2;
    font-weight: 700;
}

.tooltip-value {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .masthead,
    .card-head {
        display: grid;
    }

    .status {
        text-align: left;
    }

    .control-strip,
    .toolbar,
    .summary {
        grid-template-columns: 1fr;
    }

    .plot,
    .plot-small {
        height: 340px;
    }
}
