@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-0: #07101b;
    --bg-1: #0b1524;
    --bg-2: #111c2e;
    --bg-3: #162235;
    --card: rgba(14, 23, 38, 0.82);
    --card-strong: rgba(17, 28, 46, 0.96);

    --text-1: #edf3fb;
    --text-2: #a8b7cc;
    --text-3: #7d90ac;

    --primary: #005da7;
    --primary-2: #0b74c7;
    --accent: #f97316;
    --line: rgba(129, 152, 185, 0.24);

    /* 交易化红绿语义 */
    --up: #22c55e;
    --up-soft: rgba(34, 197, 94, 0.18);
    --down: #ef4444;
    --down-soft: rgba(239, 68, 68, 0.18);
    --warn: #f59e0b;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-1: 0 12px 32px rgba(2, 6, 23, 0.38);
    --shadow-2: 0 20px 44px rgba(2, 6, 23, 0.48);
}

body.theme-light {
    --bg-0: #f3f6fa;
    --bg-1: #f8fafc;
    --bg-2: #eef2f7;
    --bg-3: #e6ecf4;
    --card: rgba(255, 255, 255, 0.9);
    --card-strong: rgba(255, 255, 255, 0.98);

    --text-1: #0f172a;
    --text-2: #475569;
    --text-3: #64748b;

    --line: rgba(148, 163, 184, 0.28);

    --up: #16a34a;
    --up-soft: rgba(22, 163, 74, 0.14);
    --down: #dc2626;
    --down-soft: rgba(220, 38, 38, 0.12);
    --warn: #d97706;

    --shadow-1: 0 10px 28px rgba(15, 23, 42, 0.08);
    --shadow-2: 0 16px 36px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Fira Sans", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", Arial, sans-serif;
    margin: 0;
    color: var(--text-1);
    background:
        radial-gradient(1200px 560px at -10% -20%, rgba(11, 116, 199, 0.18) 0%, rgba(7, 16, 27, 0) 60%),
        radial-gradient(900px 420px at 110% -20%, rgba(249, 115, 22, 0.08) 0%, rgba(7, 16, 27, 0) 55%),
        linear-gradient(160deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2) 100%);
    min-height: 100vh;
}

body.theme-light {
    background:
        radial-gradient(1100px 480px at -10% -10%, rgba(11, 116, 199, 0.08) 0%, rgba(255, 255, 255, 0) 60%),
        radial-gradient(900px 420px at 120% -30%, rgba(0, 93, 167, 0.05) 0%, rgba(255, 255, 255, 0) 58%),
        linear-gradient(160deg, var(--bg-0), var(--bg-1) 52%, var(--bg-2) 100%);
}

.container {
    max-width: none;
    margin: 20px 18px 20px 248px;
    padding: 0 6px 24px;
    transition: margin-left .2s ease;
}

.top-nav {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: 236px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(10, 17, 30, 0.9);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-2);
    overflow-y: auto;
    transition: width .2s ease;
}

body.theme-light .top-nav {
    background: rgba(242, 246, 251, 0.95);
    box-shadow: var(--shadow-1);
}

.nav-toggle-btn {
    background: rgba(20, 32, 54, 0.88);
    border: 1px solid var(--line);
    color: var(--text-2);
    border-radius: 10px;
    height: 34px;
    cursor: pointer;
    margin-bottom: 6px;
}

body.theme-light .nav-toggle-btn {
    background: rgba(255, 255, 255, 0.95);
}

.nav-group {
    margin: 8px 4px 2px;
    font-size: 11px;
    color: var(--text-3);
    letter-spacing: .6px;
    text-transform: uppercase;
}

.nav-item {
    text-decoration: none;
    color: var(--text-2);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    transition: all .2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.nav-ico {
    width: 18px;
    text-align: center;
    opacity: .9;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    color: #edf3fb;
    background: rgba(11, 116, 199, 0.12);
    border-color: rgba(11, 116, 199, 0.22);
}

body.theme-light .nav-item:hover {
    color: #0f172a;
    background: rgba(11, 116, 199, 0.08);
    border-color: rgba(11, 116, 199, 0.2);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0,93,167,.92), rgba(11,116,199,.92));
    color: #fff;
    border-color: rgba(0, 93, 167, 0.45);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: #60a5fa;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(20, 32, 54, 0.88);
    color: var(--text-2);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
}

body.theme-light .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.95);
}

.theme-toggle-btn:hover {
    color: var(--text-1);
    border-color: rgba(11, 116, 199, 0.3);
}

.theme-toggle-state {
    color: #93c5fd;
}

body.theme-light .theme-toggle-state {
    color: var(--primary);
}

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

.header-row > div:first-child {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px 18px;
    box-shadow: var(--shadow-1);
}

.ol-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 14px;
    padding: 22px 24px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(16, 24, 40, 0.92), rgba(11, 21, 36, 0.86));
    box-shadow: var(--shadow-2);
}

body.theme-light .ol-topbar {
    background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(243,246,251,0.96));
}

.ol-kicker {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #7dd3fc;
}

.ol-subtitle {
    max-width: 680px;
    font-size: 14px;
}

.ol-topbar > div:first-child {
    flex: 1 1 420px;
}

.ol-top-actions {
    display: flex;
    flex: 1 1 560px;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.ol-summary-strip {
    width: min(100%, 620px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.ol-summary-mini {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255,255,255,0.045);
    box-shadow: var(--shadow-1);
}

body.theme-light .ol-summary-mini {
    background: rgba(15,23,42,0.035);
}

.ol-summary-mini span,
.ol-summary-mini small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ol-summary-mini span {
    margin-bottom: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-3);
}

.ol-summary-mini strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    line-height: 1.2;
    color: var(--text-1);
}

.ol-summary-mini small {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-2);
}

.ol-pill-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
}

body.theme-light .ol-pill-group {
    background: rgba(15,23,42,0.03);
}

.ol-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    color: #ffffff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(0,93,167,.92), rgba(11,116,199,.92));
    box-shadow: 0 8px 24px rgba(0,93,167,0.22);
}

.ol-pill.muted {
    background: transparent;
    color: var(--text-2);
    box-shadow: none;
}

body.theme-light .ol-pill:not(.muted) {
    color: #ffffff;
}

.ol-pill-group.compact {
    padding-left: 12px;
}

.ol-chip-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-3);
}

.ol-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.ol-summary-card {
    padding: 18px 18px 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--card);
    box-shadow: var(--shadow-1);
}

.ol-summary-label {
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-3);
}

.ol-summary-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.4px;
    color: var(--text-1);
}

.ol-summary-hint {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-2);
}

h1 {
    margin: 0 0 8px;
    font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 28px;
    letter-spacing: .2px;
    color: var(--text-1);
}

h3 {
    color: var(--text-1);
}

.muted {
    color: var(--text-2);
    margin: 4px 0;
}

.level-switch {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.button {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #ffffff;
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    transition: all .2s ease;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.36);
}

.button.secondary {
    background: rgba(20, 32, 54, 0.88);
    color: #dbe8ff;
    border: 1px solid var(--line);
    box-shadow: none;
}

.button.secondary:hover {
    background: rgba(30, 46, 76, 0.95);
    border-color: rgba(59, 130, 246, 0.45);
}

body.theme-light .button.secondary {
    background: #ffffff;
    color: #334155;
    border-color: #dbe3ef;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.theme-light .button.secondary:hover {
    background: #eef6ff;
    color: #0f172a;
    border-color: #bfdbfe;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.status-card,
.insight-card,
.disclaimer-card,
.chart-wrap,
.table-wrap table,
.kline-hover-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-1);
}

.status-card {
    padding: 14px;
}

.status-card.compact {
    min-width: 320px;
}

.status-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.status-card p {
    margin: 5px 0;
    font-size: 14px;
}

.status-reason {
    margin-top: 6px;
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 12px;
    line-height: 1.45;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-2);
    border: 1px solid var(--line);
}

.status-reason.error {
    background: rgba(127, 29, 29, 0.2);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

body.theme-light .status-reason {
    background: #f8fafc;
    color: #475569;
    border-color: #dbe3ef;
}

body.theme-light .status-reason.error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.status {
    font-weight: 700;
    text-transform: uppercase;
}

.status.success { color: var(--up); }
.status.error { color: var(--down); }
.status.running { color: var(--warn); }

.search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-row input,
.stock-sector-search-row input,
.range-filter input[type="date"] {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-1);
    background: rgba(9, 16, 29, 0.85);
}

.search-row input { flex: 1; }

body.theme-light .search-row input,
body.theme-light .stock-sector-search-row input,
body.theme-light .range-filter input[type="date"],
body.theme-light input,
body.theme-light select,
body.theme-light textarea {
    background: #ffffff;
    color: #0f172a;
    border-color: #dbe3ef;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.theme-light input::placeholder,
body.theme-light textarea::placeholder {
    color: #94a3b8;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.insight-card {
    padding: 10px 12px;
}

.insight-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 2px 0 6px;
}

.insight-card h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.insight-actions {
    display: flex;
    gap: 6px;
}

.mini-btn {
    border: 1px solid var(--line);
    background: rgba(20, 32, 54, 0.88);
    color: var(--text-2);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.mini-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

body.theme-light .mini-btn {
    background: #ffffff;
    color: #475569;
    border-color: #dbe3ef;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.theme-light .mini-btn:hover {
    background: #eef6ff;
    color: #0f172a;
    border-color: #bfdbfe;
}

body.theme-light .mini-btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.insight-chart { width: 100%; height: 260px; }

.tv-chart-box {
    width: 100%;
    height: 420px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.overall-breadth-card { margin-bottom: 12px; padding: 8px; }
.overall-breadth-card h3 { margin: 2px 4px 6px; }
.overall-breadth-chart { width: 100%; height: 220px; }
.l2-flow-rank-card { margin-bottom: 12px; }

.table-wrap { overflow-x: auto; }

.compact-table,
table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    background: transparent;
}

.compact-table { font-size: 13px; }

.compact-table th,
.compact-table td,
th, td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(129, 152, 185, 0.18);
    white-space: nowrap;
    text-align: left;
    vertical-align: middle;
    color: var(--text-1);
}

th,
.compact-table th {
    background: rgba(21, 34, 58, 0.86);
    font-weight: 700;
    color: #b9cbed;
}

body.theme-light th,
body.theme-light .compact-table th {
    background: rgba(241, 245, 249, 0.95);
    color: #334155;
}

.sortable-th {
    display: inline-block;
    width: 100%;
    color: #d5e4ff;
    text-decoration: none;
    font-weight: 700;
}

body.theme-light .sortable-th {
    color: #334155;
}

.sortable-th:hover,
.compact-table td a:hover,
.stock-sector-line a:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.compact-table td a,
.stock-sector-line a { color: #60a5fa; text-decoration: none; }

.empty {
    text-align: center;
    color: var(--text-3);
    padding: 24px;
}

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.flash.success {
    background: var(--up-soft);
    color: #dcfce7;
    border-color: rgba(34, 197, 94, 0.4);
}

.flash.error {
    background: var(--down-soft);
    color: #fee2e2;
    border-color: rgba(239, 68, 68, 0.42);
}

.tag {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
}

.tag.up { background: var(--up-soft); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.36); }
.tag.down { background: var(--down-soft); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.36); }

.chart-wrap {
    position: relative;
    padding: 10px;
    overflow: hidden;
}

.chart-toolbar {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.palette-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(12, 22, 38, 0.86);
}

.palette-switch .muted {
    margin: 0 2px 0 0;
    font-size: 12px;
}

.range-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(12, 22, 38, 0.86);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px;
}

.range-filter .range-sep {
    color: var(--text-3);
    font-weight: 700;
}

.range-filter .button.secondary {
    padding: 7px 10px;
    font-size: 13px;
}

.heatmap-canvas {
    width: 100%;
    height: 900px;
}

.disclaimer-card {
    margin-top: 12px;
    padding: 12px 14px;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.65;
}

.disclaimer-card strong {
    color: #f1f6ff;
}

.page-footer {
    margin-top: 14px;
    color: var(--text-3);
    font-size: 13px;
    text-align: right;
}

a { color: #c8daff; }

.stock-row { cursor: crosshair; }

.stock-sector-search {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.stock-sector-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stock-sector-search-row input { flex: 1; }

.stock-sector-hint { margin-top: 6px; }

.stock-sector-result {
    margin-top: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(9, 16, 29, 0.7);
    padding: 8px 10px;
}

.stock-sector-item {
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}

.stock-sector-item:last-child { border-bottom: 0; }

.stock-sector-title {
    font-weight: 700;
    color: #f1f6ff;
    margin-bottom: 4px;
}

.stock-sector-line {
    margin: 3px 0;
    color: var(--text-2);
    line-height: 1.45;
}

.kline-hover-panel {
    position: fixed;
    z-index: 9999;
    width: 460px;
    height: 300px;
    padding: 8px 10px;
}

.kline-title {
    font-size: 13px;
    color: var(--text-2);
    margin: 2px 0 6px;
}

.kline-chart { width: 100%; height: 260px; }

.rank-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rank-subtitle {
    margin: 0 0 8px;
    color: #c9d8f5;
    font-size: 13px;
}

/* Home portal style (toptraders-like, dark) */
.portal-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    color: var(--text-1);
    box-shadow: var(--shadow-1);
}

.portal-panel .muted,
.portal-panel h3,
.portal-panel a {
    color: var(--text-1);
}

.portal-top-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.portal-tab {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(20, 32, 54, 0.88);
    color: var(--text-2);
    text-decoration: none;
    font-size: 13px;
}

.portal-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: rgba(96, 165, 250, 0.45);
    color: #fff;
}

body.theme-light .portal-tab {
    background: #f8fafc;
    border-color: #dbe3ef;
    color: #475569;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.theme-light .portal-tab:hover {
    background: #eef6ff;
    border-color: #bfdbfe;
    color: #0f172a;
}

body.theme-light .portal-tab.active {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    border-color: rgba(37, 99, 235, 0.32);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.portal-search-row {
    display: flex;
    gap: 8px;
    max-width: 620px;
    margin: 2px auto 14px;
}

.portal-search-row input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(9, 16, 29, 0.85);
    color: var(--text-1);
}

.portal-search-btn {
    width: 46px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(20, 32, 54, 0.88);
    color: #fff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

body.theme-light .portal-search-row input {
    background: #ffffff;
    border-color: #dbe3ef;
    color: #0f172a;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

body.theme-light .portal-search-row input::placeholder {
    color: #94a3b8;
}

body.theme-light .portal-search-btn {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    border-color: rgba(37, 99, 235, 0.3);
    color: #ffffff !important;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.portal-section {
    margin-top: 14px;
}

.portal-section-title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    padding-left: 8px;
    border-left: 3px solid #60a5fa;
    color: #dbe8ff;
}

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

.portal-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(9, 16, 29, 0.78);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    text-decoration: none;
    min-height: 76px;
    transition: transform 300ms cubic-bezier(.2,.8,.2,1), box-shadow 300ms cubic-bezier(.2,.8,.2,1), border-color 300ms ease;
    will-change: transform;
}

body.theme-light .portal-card {
    background: rgba(248, 250, 252, 0.95);
}

.portal-logo {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.22), rgba(52, 211, 153, 0.18));
    border: 1px solid rgba(148, 163, 184, 0.24);
    color: #bfdbfe;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 1px;
    overflow: hidden;
    transition: transform 300ms cubic-bezier(.2,.8,.2,1);
}

.portal-logo.is-fallback {
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.portal-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.portal-card-body {
    min-width: 0;
}

.portal-card strong {
    display: block;
    color: var(--text-1);
    font-size: 14px;
    margin-bottom: 4px;
}

.portal-card span {
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.4;
}

.portal-card:hover {
    transform: translateY(-3px) scale(1.01);
    border-color: #60a5fa;
    box-shadow: 0 14px 26px rgba(30, 64, 175, 0.2);
}

.portal-card:active {
    transform: translateY(-1px) scale(1.005);
    box-shadow: 0 8px 18px rgba(30, 64, 175, 0.16);
}

.portal-card:hover .portal-logo {
    transform: scale(1.06);
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 12px;
    align-items: start;
}

.workspace-main {
    min-width: 0;
}

.workspace-side {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 10px;
}

body.nav-collapsed .top-nav {
    width: 72px;
}

body.nav-collapsed .container {
    margin-left: 100px;
}

body.nav-collapsed .nav-group,
body.nav-collapsed .nav-label {
    display: none;
}

body.nav-collapsed .nav-item {
    justify-content: center;
    padding-left: 6px;
    padding-right: 6px;
}

body.nav-collapsed .nav-item.active::before {
    left: 2px;
    top: 6px;
    bottom: 6px;
}

@media (max-width: 1100px) {
    .container {
        margin-left: 18px;
    }
    .top-nav {
        position: static;
        width: 100%;
        height: auto;
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .nav-toggle-btn {
        width: 56px;
    }
    body.nav-collapsed .top-nav {
        width: 100%;
    }
    body.nav-collapsed .container {
        margin-left: 18px;
    }
    body.nav-collapsed .nav-group,
    body.nav-collapsed .nav-label {
        display: inline;
    }
    body.nav-collapsed .nav-item {
        justify-content: flex-start;
        min-height: auto;
    }

    .header-row,
    .ol-topbar {
        flex-direction: column;
        align-items: stretch;
    }
    .ol-top-actions {
        align-items: flex-start;
        width: 100%;
    }
    .ol-summary-strip {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .ol-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .status-card.compact {
        min-width: 0;
    }
    .workspace-grid {
        grid-template-columns: 1fr;
    }
    .workspace-side {
        position: static;
    }
}

@media (max-width: 960px) {
    .insight-grid,
    .rank-grid-2col {
        grid-template-columns: 1fr;
    }

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

    .insight-title-row {
        flex-wrap: wrap;
    }

    .stock-sector-search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-toolbar {
        position: static;
        margin-bottom: 10px;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .portal-cards {
        grid-template-columns: 1fr;
    }
    .ol-summary-strip,
    .ol-summary-grid {
        grid-template-columns: 1fr;
    }
    .ol-pill-group {
        flex-wrap: wrap;
        border-radius: 18px;
    }
}

@media (hover: none) {
    .portal-card:hover,
    .portal-card:active {
        transform: none;
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* --- Global back-to-top button --- */
.back-to-top {
  position: fixed; bottom: 28px; right: 28px; z-index: 900;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(11, 116, 199, 0.85); color: #fff;
  border: none; font-size: 20px; line-height: 1;
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  transform: translateY(12px);
  display: flex; align-items: center; justify-content: center;
}
.back-to-top.visible {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.back-to-top:hover { background: rgba(11, 116, 199, 1); transform: scale(1.08); }
.back-to-top:active { transform: scale(0.95); }
body.theme-light .back-to-top { background: rgba(30, 64, 175, 0.82); }
body.theme-light .back-to-top:hover { background: rgba(30, 64, 175, 1); }

/* Light theme hardening across pages */
body.theme-light .button.secondary,
body.theme-light select,
body.theme-light .range-filter .button.secondary {
    background: #ffffff !important;
    background-image: none !important;
    color: #334155 !important;
    border-color: #dbe3ef !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

body.theme-light .button.secondary:hover,
body.theme-light select:hover,
body.theme-light .range-filter .button.secondary:hover {
    background: #eef6ff !important;
    color: #0f172a !important;
    border-color: #bfdbfe !important;
}

body.theme-light .search-row input,
body.theme-light .stock-sector-search-row input,
body.theme-light .range-filter input[type="date"],
body.theme-light input,
body.theme-light textarea {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #dbe3ef !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

body.theme-light .range-filter,
body.theme-light .palette-switch {
    background: rgba(248, 250, 252, 0.94) !important;
    border-color: #dbe3ef !important;
}

body.theme-light th,
body.theme-light .compact-table th,
body.theme-light .rank-table th,
body.theme-light .rank-table th:first-child {
    background: rgba(241, 245, 249, 0.96) !important;
    color: #334155 !important;
}

body.theme-light .rank-table td,
body.theme-light .rank-table th,
body.theme-light .rank-table td:first-child {
    color: #334155 !important;
}

body.theme-light .rank-table tr:nth-child(even) td,
body.theme-light .rank-table td:first-child {
    background: rgba(248, 250, 252, 0.9) !important;
}

body.theme-light .sortable-th,
body.theme-light .rank-table th.sortable {
    color: #334155 !important;
}

body.theme-light .rank-table th.sortable:hover,
body.theme-light .sortable-th:hover {
    color: #2563eb !important;
}

/* Light theme: stock sector search result card */
body.theme-light .stock-sector-result {
    background: #ffffff !important;
    border-color: #dbe3ef !important;
    color: #334155 !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

body.theme-light .stock-sector-item {
    border-bottom-color: #e2e8f0 !important;
}

body.theme-light .stock-sector-title {
    color: #0f172a !important;
}

body.theme-light .stock-sector-line {
    color: #475569 !important;
}

body.theme-light .stock-sector-line strong {
    color: #334155 !important;
}

body.theme-light .stock-sector-line a {
    color: #2563eb !important;
    font-weight: 700;
}

body.theme-light .stock-sector-line a:hover {
    color: #1d4ed8 !important;
}

/* Unified blue pill button style (light theme) */
body.theme-light .button,
body.theme-light .button.secondary,
body.theme-light .mini-btn,
body.theme-light .portal-tab,
body.theme-light .ol-pill,
body.theme-light select.button.secondary {
    border-radius: 999px !important;
}

body.theme-light .button.secondary,
body.theme-light .mini-btn,
body.theme-light .portal-tab,
body.theme-light .ol-pill.muted,
body.theme-light select.button.secondary {
    background: linear-gradient(180deg, #ffffff, #f8fbff) !important;
    background-image: linear-gradient(180deg, #ffffff, #f8fbff) !important;
    color: #475569 !important;
    border-color: #dbeafe !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), inset 0 0 0 1px rgba(255, 255, 255, 0.72) !important;
}

body.theme-light .button.secondary:hover,
body.theme-light .mini-btn:hover,
body.theme-light .portal-tab:hover,
body.theme-light .ol-pill.muted:hover,
body.theme-light select.button.secondary:hover {
    background: #eff6ff !important;
    background-image: none !important;
    color: #1d4ed8 !important;
    border-color: #93c5fd !important;
}

body.theme-light .button:not(.secondary),
body.theme-light .button.active,
body.theme-light .button.secondary.active,
body.theme-light .market-btn.active,
body.theme-light .profile-btn.active,
body.theme-light .focus-btn.active,
body.theme-light .preset-btn.active,
body.theme-light .mini-btn.active,
body.theme-light .portal-tab.active,
body.theme-light .ol-pill:not(.muted) {
    background: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    background-image: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    color: #ffffff !important;
    border-color: rgba(37, 99, 235, 0.28) !important;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22) !important;
}

body.theme-light .button:not(.secondary):hover,
body.theme-light .button.active:hover,
body.theme-light .button.secondary.active:hover,
body.theme-light .market-btn.active:hover,
body.theme-light .profile-btn.active:hover,
body.theme-light .focus-btn.active:hover,
body.theme-light .preset-btn.active:hover,
body.theme-light .mini-btn.active:hover,
body.theme-light .portal-tab.active:hover,
body.theme-light .ol-pill:not(.muted):hover {
    background: linear-gradient(135deg, #0284c7, #1d4ed8) !important;
    background-image: linear-gradient(135deg, #0284c7, #1d4ed8) !important;
    color: #ffffff !important;
}

body.theme-light .ol-pill-group {
    padding: 4px !important;
    border-color: #dbeafe !important;
    background: rgba(248, 250, 252, 0.92) !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}
