:root {
    --bg: #f4efe7;
    --surface: rgba(255, 251, 246, 0.9);
    --surface-strong: #fffdf9;
    --surface-dark: #122622;
    --ink: #1b1a17;
    --muted: #625b50;
    --accent: #0f6d66;
    --accent-soft: rgba(15, 109, 102, 0.12);
    --warning: #b66a1d;
    --danger: #a13636;
    --positive: #0f6d66;
    --shadow: 0 28px 72px rgba(47, 39, 24, 0.13);
    --border: rgba(56, 47, 32, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 109, 102, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(182, 106, 29, 0.16), transparent 24%),
        linear-gradient(180deg, #e8dcc9 0%, #f4efe7 44%, #faf7f1 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

code {
    font-family: "IBM Plex Mono", Consolas, monospace;
}

.page-shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 56px;
}

.hero {
    display: grid;
    grid-template-columns: 1.6fr 0.9fr;
    gap: 22px;
    margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.summary-card,
.panel {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.hero-copy {
    padding: 34px;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255, 252, 248, 0.96), rgba(246, 237, 225, 0.92));
}

.hero-panel {
    display: grid;
    gap: 14px;
    padding: 20px;
    border-radius: 30px;
    color: #f5f3ee;
    background:
        linear-gradient(160deg, rgba(12, 38, 35, 0.95), rgba(18, 58, 53, 0.92)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
}

.eyebrow,
.panel-kicker,
.summary-label,
.signal-label {
    margin: 0 0 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 700;
}

.eyebrow,
.panel-kicker {
    color: var(--accent);
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.5rem, 4vw, 4.8rem);
    line-height: 0.96;
}

.hero-alerts {
    display: grid;
    gap: 12px;
    margin: 18px 0 22px;
    padding: 16px;
    border-radius: 22px;
    background: rgba(27, 26, 23, 0.04);
    border: 1px solid rgba(27, 26, 23, 0.08);
}

.hero-alerts-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    font-size: 0.94rem;
    font-weight: 700;
}

.hero-alert-list {
    display: grid;
    gap: 10px;
}

.hero-alert-item {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid rgba(27, 26, 23, 0.08);
}

.hero-alert-item.is-error {
    background: rgba(161, 54, 54, 0.07);
    border-color: rgba(161, 54, 54, 0.18);
}

.hero-alert-item.is-warning {
    background: rgba(182, 106, 29, 0.08);
    border-color: rgba(182, 106, 29, 0.18);
}

.hero-alert-item h4,
.hero-alert-item p {
    margin: 0;
}

.hero-alert-item p {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.5;
}

.hero-alert-meta {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.84rem;
}

.tab-switcher {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px;
    border-radius: 999px;
    background: rgba(27, 26, 23, 0.06);
}

.tab-button,
.timeframe-button {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.tab-button {
    min-height: 48px;
    padding: 0 18px;
    font-weight: 700;
    color: var(--muted);
    background: transparent;
}

.tab-button:hover,
.timeframe-button:hover {
    transform: translateY(-1px);
}

.tab-button.is-active,
.timeframe-button.is-active {
    color: #fffdf8;
    background: var(--ink);
    box-shadow: 0 12px 26px rgba(27, 26, 23, 0.18);
}

.timeframe-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.timeframe-button {
    min-height: 38px;
    padding: 0 14px;
    color: var(--muted);
    background: rgba(27, 26, 23, 0.06);
}

.signal-card {
    padding: 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.signal-label {
    display: block;
    color: rgba(245, 243, 238, 0.72);
}

.dashboard {
    display: grid;
    gap: 22px;
}

.dashboard-view {
    display: grid;
    gap: 22px;
}

.dashboard-view.is-hidden {
    display: none;
}

.summary-grid,
.content-grid {
    display: grid;
    gap: 18px;
}

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

.summary-card {
    padding: 22px;
    border-radius: 24px;
    background: var(--surface);
}

.summary-label {
    color: var(--muted);
}

.summary-card h2 {
    margin: 0 0 10px;
    font-size: clamp(1.7rem, 2.4vw, 2.6rem);
}

.summary-note {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.panel {
    padding: 22px;
    border-radius: 26px;
    background: var(--surface);
}

.panel-full {
    width: 100%;
}

.panel-span-2 {
    grid-column: span 2;
}

.panel-chart {
    overflow: hidden;
}

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

.panel-header h3 {
    margin: 0;
    font-size: 1.42rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.84rem;
    font-weight: 700;
}

.chart-stage {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(27, 26, 23, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(245, 239, 231, 0.88));
}

.chart-stage-large {
    min-height: 380px;
}

.dashboard-chart {
    display: block;
    width: 100%;
    height: 380px;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    line-height: 1.7;
}

.chart-empty.is-hidden {
    display: none;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-top: 14px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.legend-swatch {
    width: 20px;
    height: 4px;
    border-radius: 999px;
}

.legend-portfolio {
    background: var(--accent);
}

.legend-benchmark {
    background: var(--warning);
}

.legend-average {
    background: #c54747;
}

.legend-reserve {
    background: var(--ink);
}

.legend-baseline {
    background: #2f4f7f;
}

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

.live-grid,
.backtest-grid {
    align-items: start;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid rgba(27, 26, 23, 0.08);
    background: var(--surface-strong);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

thead {
    background: rgba(15, 109, 102, 0.06);
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(27, 26, 23, 0.08);
}

th {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

tbody tr {
    cursor: pointer;
}

tbody tr:hover {
    background: rgba(15, 109, 102, 0.04);
}

tbody tr.is-selected {
    background: rgba(15, 109, 102, 0.1);
}

.list-feed,
.metric-stack {
    display: grid;
    gap: 12px;
}

.feed-item,
.metric-item {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px solid rgba(27, 26, 23, 0.08);
}

.feed-item h4,
.feed-item p,
.metric-item p {
    margin: 0;
}

.feed-item p,
.metric-item p {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.55;
}

.feed-meta,
.metric-meta {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.feed-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: baseline;
}

.feed-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(27, 26, 23, 0.06);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.metric-row strong {
    text-align: right;
}

.empty-state {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px dashed rgba(27, 26, 23, 0.14);
    color: var(--muted);
    line-height: 1.6;
}

.positive {
    color: var(--positive);
}

.negative {
    color: var(--danger);
}

.neutral {
    color: var(--ink);
}

.status-ok {
    color: #e9fff3;
    background: rgba(76, 188, 133, 0.2);
}

.status-warning {
    color: #fff4e8;
    background: rgba(182, 106, 29, 0.2);
}

.status-error {
    color: #ffe9e9;
    background: rgba(161, 54, 54, 0.2);
}

@media (max-width: 1120px) {
    .hero,
    .summary-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .panel-span-2 {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 18px, 1320px);
        padding-top: 18px;
    }

    .hero-copy,
    .hero-panel,
    .summary-card,
    .panel {
        padding: 18px;
        border-radius: 22px;
    }

    .chart-stage-large,
    .dashboard-chart {
        min-height: 320px;
        height: 320px;
    }

    th,
    td {
        padding: 12px;
    }
}
