:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-strong: #f9fbff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #dbe4ef;
    --brand: #0f766e;
    --brand-soft: #ecfdf5;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --buy: #10b981;
    --week: #2563eb;
    --open: #d97706;
    --recent: #7c3aed;
    --positive: #0f766e;
    --negative: #dc2626;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

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

button,
select {
    font: inherit;
}

.page-shell {
    width: min(1520px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(360px, 0.8fr);
    gap: 20px;
    margin-bottom: 18px;
}

.brand-block,
.system-panel,
.metric-card,
.table-section,
.options-hero,
.option-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.brand-block {
    padding: 34px 38px;
}

.eyebrow,
.panel-kicker,
.table-kicker,
.metric-label,
.option-card span {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.74rem;
    font-weight: 800;
    color: var(--brand);
}

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

h1 {
    max-width: 11ch;
    margin-top: 14px;
    font-size: clamp(2.2rem, 3.4vw, 3.4rem);
    line-height: 0.98;
    letter-spacing: -0.05em;
}

h2 {
    margin-top: 10px;
    font-size: clamp(1.35rem, 2.2vw, 1.9rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

h3 {
    margin-top: 14px;
    font-size: 1.3rem;
    letter-spacing: -0.04em;
}

.hero-text,
.scan-note,
.metric-card small,
.stock-subline,
.subtle-meta,
.option-card p,
.empty-state p {
    color: var(--muted);
    line-height: 1.7;
}

.hero-text {
    max-width: 54ch;
    margin-top: 16px;
    font-size: 0.98rem;
}

.hero-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 26px;
}

.hero-strip div {
    display: grid;
    gap: 3px;
    padding: 14px 18px;
    border-radius: 8px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
}

.hero-strip strong {
    font-size: 1.05rem;
    letter-spacing: -0.04em;
}

.hero-strip span {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.system-panel {
    padding: 26px;
}

.field-label {
    display: block;
    margin: 18px 0 10px;
    font-size: 0.9rem;
    font-weight: 800;
}

select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 16px;
    background: var(--surface-strong);
    color: var(--ink);
    outline: none;
}

.rdx-trade-status {
    min-width: 104px;
    padding: 8px 10px;
    font-size: 0.86rem;
    font-weight: 800;
}

.scan-note {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    font-size: 0.92rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 13px 20px;
    background: var(--brand);
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    background: #115e59;
}

button:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

button.ghost {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
}

button.ghost:hover {
    background: var(--surface-strong);
}

.tabs-bar {
    display: flex;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    width: fit-content;
    margin-bottom: 18px;
}

.tab-button {
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    padding: 12px 20px;
}

.tab-button:hover {
    background: var(--surface-strong);
    color: var(--ink);
    transform: none;
}

.tab-button.active {
    background: var(--ink);
    color: #ffffff;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card {
    padding: 22px 24px;
}

.metric-card strong {
    display: block;
    margin: 14px 0 8px;
    font-size: clamp(2rem, 4vw, 2.8rem);
    letter-spacing: -0.06em;
}

.table-section {
    padding: 26px;
}

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

.subtle-meta {
    margin-top: 8px;
    font-size: 0.92rem;
}

.status-stack {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.status-pill {
    margin: 0;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 0.82rem;
    font-weight: 800;
}

.status-pill.active {
    background: #eff6ff;
    color: var(--week);
}

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

.status-pill.secondary {
    background: var(--surface-strong);
    color: var(--muted);
    border: 1px solid var(--line);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

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

th,
td {
    padding: 16px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    background: var(--surface-strong);
}

tbody tr:hover td {
    background: #f8fafc;
}

.stock-name {
    font-weight: 800;
}

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

.stock-name-trigger {
    display: inline-block;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    text-decoration: none;
}

.stock-name-trigger:hover,
.stock-name-trigger:focus-visible {
    color: var(--week);
    text-decoration: underline;
    transform: none;
}

.stock-subline {
    margin-top: 4px;
    font-size: 0.84rem;
}

.stock-preview-card {
    position: fixed;
    z-index: 40;
    width: min(340px, calc(100vw - 24px));
    padding: 12px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stock-preview-label {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--muted);
}

.stock-preview-image {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
}

.badge {
    display: inline-flex;
    min-width: 78px;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    color: #ffffff;
}

.badge.buy {
    background: var(--buy);
}

.badge.week {
    background: var(--week);
}

.badge.open {
    background: var(--open);
}

.badge.recent {
    background: var(--recent);
}

.trade-meta {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--muted);
}

.positive {
    color: var(--positive);
    font-weight: 800;
}

.negative {
    color: var(--negative);
    font-weight: 800;
}

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

.empty-state {
    padding: 52px 24px;
    text-align: center;
    border-radius: 8px;
    background: var(--surface-strong);
    border: 1px dashed var(--line);
}

.failure-samples {
    margin-top: 16px;
    color: var(--warn);
}

.hidden {
    display: none;
}

.options-hero {
    padding: 34px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.option-card {
    padding: 24px;
    background: var(--surface-strong);
    box-shadow: none;
}

.option-card p {
    margin-top: 14px;
}

.chart-page-shell {
    width: min(1480px, calc(100% - 32px));
    padding-top: 24px;
}

.chart-page-header {
    margin-bottom: 18px;
}

.chart-viewer {
    padding: 18px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.chart-viewer svg {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 1080px) {
    .app-header {
        grid-template-columns: 1fr;
    }

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

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

    .brand-block,
    .system-panel,
    .metric-card,
    .table-section,
    .options-hero {
        border-radius: 8px;
        padding: 22px;
    }

    h1 {
        max-width: none;
    }

    .tabs-bar {
        width: 100%;
        border-radius: 8px;
    }

    .tab-button {
        flex: 1;
    }

    .metrics,
    .options-grid {
        grid-template-columns: 1fr;
    }

    .section-head {
        display: block;
    }

    .status-stack {
        justify-content: flex-start;
        margin-top: 14px;
    }
}
