:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #182126;
    background: #edf1f2;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    margin: 0;
}

.shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    padding: 22px 24px;
    border-radius: 8px;
    color: #f7fafb;
    background: #203038;
}

.logout-button {
    min-width: 72px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #bdcbd2;
    border-radius: 6px;
    color: #263840;
    background: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

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

.brand-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #d6f0e1;
    font-size: 0.75rem;
    font-weight: 700;
}

.live-badge::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #57c989;
    content: "";
}

.header-subtitle {
    margin: 7px 0 0;
    color: #bfd0d7;
    font-size: 0.9rem;
}

.admin-link {
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 6px;
    border: 1px solid #6f858f;
    color: #f7fafb;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
}

.admin-link:hover {
    background: #31454e;
}

.logout-button:hover {
    background: #edf3f6;
}

.logout-button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.eyebrow,
.section-label {
    margin: 0 0 6px;
    color: #47616f;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar .eyebrow {
    margin: 0;
    color: #a9c2cc;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.65rem, 4vw, 2.25rem);
    line-height: 1.15;
}

h2 {
    margin-bottom: 0;
    font-size: 1.4rem;
}

.market-section {
    padding: 26px 4px;
    border-bottom: 1px solid #ccd7db;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.muted {
    margin-bottom: 0;
    color: #60727c;
    font-size: 0.86rem;
    text-align: right;
}

.metric-grid {
    display: grid;
    gap: 10px;
}

.four-columns {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.three-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    min-height: 132px;
    padding: 17px;
    border: 1px solid #d5dfe3;
    border-radius: 7px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgb(27 45 54 / 5%);
}

.metric span,
.metric small {
    color: #60727c;
}

.metric span {
    font-size: 0.86rem;
    font-weight: 700;
}

.metric strong {
    margin: 12px 0 8px;
    overflow-wrap: anywhere;
    font-size: clamp(1.35rem, 3vw, 2rem);
    line-height: 1.1;
}

.metric small {
    overflow-wrap: anywhere;
    font-size: 0.78rem;
}

.metric.emphasis {
    border-color: #83b79e;
    background: #edf7f1;
}

.metric.drawdown-emphasis {
    border-color: #d9aaa4;
    background: #fff6f4;
}

.drawdown-table {
    overflow: hidden;
    border: 1px solid #d5dfe3;
    border-radius: 7px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgb(27 45 54 / 5%);
}

.drawdown-header,
.drawdown-row {
    display: grid;
    grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: center;
}

.drawdown-header {
    padding: 10px 12px;
    color: #60727c;
    font-size: 0.75rem;
    font-weight: 700;
    background: #f5f8f9;
}

.drawdown-row {
    min-height: 94px;
    padding: 14px 12px;
    border-top: 1px solid #e4eaed;
}

.drawdown-row:nth-child(even) {
    background: #fafcfc;
}

.drawdown-cell {
    min-width: 0;
}

.drawdown-cell > span {
    display: none;
}

.drawdown-cell strong,
.drawdown-cell small {
    display: block;
    overflow-wrap: anywhere;
}

.drawdown-cell strong {
    font-size: 1.1rem;
    line-height: 1.25;
}

.drawdown-cell small {
    margin-top: 6px;
    color: #60727c;
    font-size: 0.75rem;
}

.drawdown-cell.decline strong {
    color: #9d2b2b;
}

.positive {
    color: #17633f;
}

.negative {
    color: #9d2b2b;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    color: #e3e9ec;
    background: #0f1518;
}

:root[data-theme="dark"] .topbar {
    background: #172126;
}

:root[data-theme="dark"] .market-section {
    border-color: #34454d;
}

:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .section-label,
:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .metric span,
:root[data-theme="dark"] .metric small,
:root[data-theme="dark"] .drawdown-cell small,
:root[data-theme="dark"] .drawdown-cell > span,
:root[data-theme="dark"] .drawdown-header {
    color: #9db0b8;
}

:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .drawdown-table {
    border-color: #34454d;
    background: #182126;
    box-shadow: 0 4px 14px rgb(0 0 0 / 18%);
}

:root[data-theme="dark"] .metric.emphasis {
    border-color: #39745a;
    background: #193027;
}

:root[data-theme="dark"] .drawdown-header,
:root[data-theme="dark"] .drawdown-row:nth-child(even) {
    background: #121b1f;
}

:root[data-theme="dark"] .drawdown-row {
    border-color: #2b3a40;
}

:root[data-theme="dark"] .positive {
    color: #77d6a5;
}

:root[data-theme="dark"] .negative,
:root[data-theme="dark"] .drawdown-cell.decline strong {
    color: #f39a94;
}

@media (max-width: 780px) {
    .shell {
        width: min(100% - 20px, 1240px);
        padding-top: 20px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px;
    }

    .topbar-actions,
    .admin-link {
        width: 100%;
    }

    .admin-link {
        text-align: center;
    }

    .muted {
        text-align: left;
    }

    .four-columns,
    .three-columns {
        grid-template-columns: 1fr;
    }

    .drawdown-header {
        display: none;
    }

    .drawdown-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px 12px;
    }

    .drawdown-cell > span {
        display: block;
        margin-bottom: 4px;
        color: #60727c;
        font-size: 0.72rem;
        font-weight: 700;
    }
}
