:root {
    --bg-0: #070b14;
    --bg-1: #0c1220;
    --bg-2: #121c31;
    --bg-3: #1a2742;
    --line: #243558;
    --line-soft: #1b2a46;
    --text: #e8f0ff;
    --text-dim: #9db1d8;
    --text-muted: #6f86b2;
    --blue: #53a7ff;
    --cyan: #4cd6c8;
    --green: #32d67b;
    --amber: #ffbf5f;
    --red: #ff6b6b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "SF Mono", "IBM Plex Mono", "JetBrains Mono", monospace;
    color: var(--text);
    background:
        radial-gradient(circle at 15% -20%, #1b2e55 0%, transparent 55%),
        radial-gradient(circle at 85% -20%, #153447 0%, transparent 45%),
        var(--bg-0);
    min-height: 100vh;
    line-height: 1.45;
}

a {
    color: inherit;
}

.hidden {
    display: none !important;
}

.btn-primary,
.btn-secondary,
.btn-small {
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--bg-3);
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-small:hover {
    transform: translateY(-1px);
    border-color: var(--blue);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #1f4d89 0%, #173a67 100%);
    border-color: #285e9f;
}

.btn-secondary,
.btn-small {
    padding: 10px 14px;
    background: var(--bg-2);
}

.btn-loader {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: #d7e8ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-container {
    margin-top: 12px;
}

.progress-bar {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    overflow: hidden;
    background: #12203a;
    border: 1px solid var(--line-soft);
}

.progress-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--blue));
    transition: width 0.35s ease;
}

.progress-text {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.report-content {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #0f1727 0%, #0c1322 100%);
    padding: 16px;
    white-space: pre-wrap;
    font-size: 0.8rem;
    max-height: 52vh;
    overflow-y: auto;
    color: #d6e5ff;
}

.market-radar-page .radar-shell {
    max-width: 1280px;
    margin: 14px auto;
    padding: 10px;
}

.market-radar-page .radar-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #101a2d 0%, #0d1524 100%);
}

.market-radar-page .eyebrow {
    color: var(--amber);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.market-radar-page h1 {
    font-size: 1.25rem;
    margin-top: 3px;
}

.market-radar-page .subtitle {
    font-size: 0.76rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.market-radar-page .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link {
    text-decoration: none;
    color: var(--text-dim);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.72rem;
    background: #0f1a2d;
}

.nav-link:hover {
    color: var(--text);
    border-color: var(--blue);
}

.status {
    font-size: 0.72rem;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #0f1a2d;
    color: var(--text-dim);
}

.status.healthy {
    color: var(--green);
    border-color: #1e5b45;
}

.status.error {
    color: var(--red);
    border-color: #633030;
}

.clock {
    color: var(--text-dim);
    font-size: 0.72rem;
}

.ticker-strip,
.control-strip {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0e1628;
    padding: 10px 12px;
}

.ticker-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.ticker-label {
    color: var(--amber);
    border: 1px solid #5a4625;
    background: #2e2516;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
}

.ticker-item {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    color: var(--text-dim);
    border: 1px solid var(--line-soft);
    background: #101c33;
}

.control-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.chip-group {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.chip {
    font-size: 0.68rem;
    color: var(--text-dim);
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 4px 8px;
    background: #101c33;
}

.chip.danger {
    color: #ff9f9f;
    border-color: #6f3535;
    background: #2a1518;
}

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

.grid-panels {
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px;
}

.panel {
    grid-column: span 3;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    background: linear-gradient(180deg, #10192c 0%, #0d1524 100%);
    min-height: 150px;
}

.panel.wide {
    grid-column: span 6;
    min-height: 128px;
}

.panel h3 {
    font-size: 0.82rem;
    margin-bottom: 4px;
    color: #dcebff;
}

.panel-sub {
    color: var(--text-muted);
    font-size: 0.68rem;
    margin-bottom: 8px;
}

.metric-list {
    list-style: none;
    display: grid;
    gap: 6px;
}

.metric-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 7px;
    border: 1px solid var(--line-soft);
    border-radius: 7px;
    background: #0f1a30;
    font-size: 0.7rem;
}

.metric-list span {
    color: var(--text-dim);
}

.metric-list strong {
    color: #cce2ff;
    font-weight: 500;
    text-align: right;
}

.metric-list.mini li {
    padding: 5px 6px;
    font-size: 0.66rem;
}

.metric-label {
    display: flex;
    align-items: center;
    gap: 7px;
}

.sparkline {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #14243d;
    overflow: hidden;
    border: 1px solid #203253;
}

.sparkline-fill {
    height: 100%;
    width: 60%;
    background: linear-gradient(90deg, #36d17b, #59d7bf);
}

.metric-value {
    display: flex;
    align-items: center;
    gap: 7px;
}

.value {
    color: #d8e8ff;
}

.change {
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    font-size: 0.62rem;
}

.change.up {
    color: #79f0a7;
    border-color: #2a6a4a;
    background: #163325;
}

.change.down {
    color: #ff9d9d;
    border-color: #6a3232;
    background: #31191b;
}

.change.flat {
    color: #d2ddf1;
    border-color: #405475;
    background: #192741;
}

.split-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mini-title {
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.option-table-wrap {
    margin-top: 8px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    overflow: auto;
}

.option-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: 0.68rem;
}

.trade-board .option-table {
    min-width: 860px;
}

.option-table thead {
    background: #13213b;
}

.option-table th,
.option-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 7px;
    text-align: left;
    color: var(--text-dim);
}

.option-table tbody tr:last-child td {
    border-bottom: none;
}

.option-table td strong {
    color: #d8e8ff;
}

.warning-note {
    color: #ffbcbc;
}

.signal-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.signal {
    border: 1px solid #2a456d;
    color: #9ec5ff;
    background: #11203a;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 0.7rem;
}

.report-mini-list {
    list-style: none;
    display: grid;
    gap: 6px;
}

.report-mini-list li {
    border: 1px solid var(--line-soft);
    border-radius: 7px;
    background: #0f1a30;
}

.report-mini-list a,
.report-mini-list span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px;
    text-decoration: none;
    font-size: 0.7rem;
    color: var(--text-dim);
}

.report-mini-list strong {
    color: var(--cyan);
}

.report-stage {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #0f1727 0%, #0c1322 100%);
    padding: 20px;
}

.empty-state {
    text-align: center;
}

.empty-state h2 {
    font-size: 1rem;
}

.empty-state p {
    margin: 10px auto 0;
    max-width: 840px;
    color: var(--text-dim);
    font-size: 0.78rem;
}

.sections-preview {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.sections-preview span {
    font-size: 0.68rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 4px 9px;
    background: #111d32;
    color: var(--text-dim);
}

/* Shared pages (history/report) */
.container {
    width: min(1120px, 96vw);
    margin: 18px auto;
}

header {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0f1829;
    padding: 14px;
}

header h1 {
    font-size: 1rem;
}

main {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #0f1829;
    padding: 14px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.search-form {
    display: flex;
    gap: 8px;
}

.search-input {
    min-width: 220px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #12203a;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    font-size: 0.8rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--blue);
}

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

.report-card {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: #111d32;
    padding: 12px;
}

.report-meta {
    display: flex;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.report-preview {
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 0.78rem;
}

.report-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.btn-outline {
    background: transparent;
}

.btn-danger {
    color: #ffc2c2;
    border-color: #62353d;
    background: #2a1518;
}

.btn-link {
    color: var(--blue);
    text-decoration: none;
    font-size: 0.78rem;
}

.pagination {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
}

.page-info,
.report-count {
    color: var(--text-muted);
    font-size: 0.72rem;
}

@media (max-width: 1000px) {
    .panel,
    .panel.wide {
        grid-column: span 6;
    }

    .split-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .market-radar-page .radar-shell {
        padding: 8px;
    }

    .market-radar-page .radar-header {
        flex-direction: column;
    }

    .panel,
    .panel.wide {
        grid-column: span 12;
    }

    .controls {
        width: 100%;
    }

    .btn-primary,
    .btn-secondary {
        flex: 1;
        justify-content: center;
    }

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