:root {
    color-scheme: dark;
    --page: #20242f;
    --header: #363b4b;
    --nav: #4c5263;
    --panel: #202530;
    --panel-alt: #262c38;
    --border: #424a5c;
    --text: #d1d4dc;
    --muted: #9299aa;
    --link: #4aa8ff;
    --gain: #00c875;
    --loss: #ff5b6b;
    --purple: #2c1958;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
    min-width: 320px;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
a { color: inherit; }
.positive { color: var(--gain) !important; }
.negative { color: var(--loss) !important; }
.link { color: var(--link); }

.site-header { background: var(--header); }
.masthead {
    min-height: 96px;
    padding: 10px 3.1% 7px;
}
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #f5f6f8;
    text-decoration: none;
    vertical-align: top;
}
.wordmark > span {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 35px;
    font-weight: 700;
    line-height: 45px;
    letter-spacing: -1.8px;
}
.wordmark > span::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 0 22px 2px;
    border-radius: 50%;
    background: #4aa8ff;
}
.wordmark small {
    color: #b9bfcb;
    font-size: 9px;
    font-weight: 700;
    line-height: 10px;
    letter-spacing: 1.5px;
}
.header-search {
    display: flex;
    width: 380px;
    height: 32px;
    align-items: center;
    gap: 7px;
    margin-top: 6px;
    border: 1px solid #50586a;
    border-radius: 5px;
    background: #343a49;
    color: var(--muted);
}
.header-search span { padding-left: 9px; font-size: 18px; transform: rotate(-20deg); }
.header-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
}
.header-search input::placeholder { color: #8991a4; }

.nav-row {
    display: flex;
    min-height: 31px;
    align-items: stretch;
    justify-content: space-between;
    padding: 0 3.1%;
    background: var(--nav);
}
.nav-row nav {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-row nav::-webkit-scrollbar { display: none; }
.nav-row nav a, .nav-row nav span, .nav-meta span, .nav-meta time {
    display: flex;
    align-items: center;
    padding: 0 8px;
    white-space: nowrap;
    font-weight: 700;
}
.nav-row nav a { text-decoration: none; }
.nav-row nav a:hover, .nav-row nav a:focus-visible {
    background: #596174;
    color: #fff;
}
.nav-row nav a.active { background: #626a7d; color: #fff; }
.nav-row nav span { cursor: default; }
.nav-meta { display: flex; flex: 0 0 auto; align-items: center; font-size: 10px; }
.market-state { border-radius: 10px; margin: 5px 2px; background: #2c3240; }
.state-open { color: var(--gain); }
.state-pre-market { color: #f6c85f; }
.state-closed { color: #d5d8e0; }
.announcement {
    min-height: 40px;
    padding: 11px 20px;
    background: var(--purple);
    color: #ded9ef;
    text-align: center;
    font-weight: 700;
}

.dashboard-main, .screener-main {
    width: 94%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 16px 0 28px;
}
.panel {
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--panel);
}
.market-brief {
    display: flex;
    min-height: 58px;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 9px 12px;
    font-size: 13px;
}
.brief-time, .stale-label { color: var(--muted); }
.stale-label { margin-left: auto; font-size: 10px; text-transform: uppercase; }

.index-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 28px;
    margin-bottom: 12px;
}
.index-card { min-width: 0; padding: 8px 8px 5px; }
.index-card header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: baseline;
    padding: 0 3px 2px;
}
.index-card header strong { color: #aeb5c6; font-size: 14px; }
.index-card header span { color: var(--muted); font-size: 10px; }
.index-card header b { text-align: right; font-size: 12px; }
.candle-chart { display: block; width: 100%; height: 137px; overflow: visible; }
.chart-grid line { stroke: #303744; stroke-width: 1; stroke-dasharray: 2 3; }
.candle-up line, .candle-up rect { stroke: var(--gain); fill: var(--gain); }
.candle-down line, .candle-down rect { stroke: var(--loss); fill: var(--loss); }
.index-card footer { display: flex; justify-content: space-around; color: #778094; font-size: 9px; }
.unavailable { display: grid; min-height: 90px; place-items: center; color: var(--muted); }

.breadth-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 55px;
    margin: 0 26px 12px;
}
.breadth-card { padding: 7px; }
.breadth-card > div { display: flex; justify-content: space-between; gap: 6px; }
.breadth-card small { color: var(--muted); }
.breadth-card b { font-size: 10px; }
.breadth-track {
    height: 7px;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--loss);
}
.breadth-track i { display: block; height: 100%; background: var(--gain); }
.breadth-track.breadth-empty { background: #3a4150; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.35fr) minmax(310px, .95fr);
    gap: 12px 16px;
}
.dashboard-grid > .panel { min-width: 0; overflow: hidden; }
.dashboard-grid h2 {
    margin: 0;
    color: #d8dbe2;
    font-size: 11px;
}
.market-tables {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 8px 10px 10px;
}
.mover-column { min-width: 0; }
.mover-column table { table-layout: fixed; }
.mover-column td, .mover-column th { overflow: hidden; text-overflow: ellipsis; }
.mover-column h2 { margin: 0 0 4px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { color: #aab0bf; text-align: left; font-size: 10px; font-weight: 600; }
td, th { padding: 3px 4px; white-space: nowrap; }
td:not(:first-child), th:not(:first-child) { text-align: right; }
tbody tr:hover { background: #2a303d; }

.heatmap { grid-row: span 2; min-height: 330px; padding: 8px; }
.heatmap > h2 { margin-bottom: 5px; }
.heatmap > h2 small { color: #f6c85f; }
.heatmap-groups { display: flex; height: 302px; gap: 2px; overflow: hidden; }
.heatmap-sector {
    display: flex;
    min-width: 78px;
    flex: 1 1 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #151923;
}
.heatmap-sector h3 {
    margin: 0;
    padding: 2px 4px;
    overflow: hidden;
    background: #566676;
    color: #fff;
    font-size: 8px;
    white-space: nowrap;
    text-transform: uppercase;
}
.heatmap-cells { display: flex; height: 100%; flex-direction: column; gap: 1px; }
.heat-cell {
    display: grid;
    min-height: 28px;
    place-content: center;
    padding: 2px;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px #111;
}
.heat-positive { background: rgba(0, 150, 82, var(--intensity)); }
.heat-negative { background: rgba(190, 52, 55, var(--intensity)); }
.heat-cell strong { font-size: 10px; }
.heat-cell span { font-size: 8px; }

.signals { padding: 8px 10px; }
.signals h2, .sector-panel h2, .headlines h2, .index-summary h2,
.events-panel h2, .earnings-panel h2, .market-stats h2 {
    margin-bottom: 6px;
    color: var(--muted);
}
.signal-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 18px; }
.signal-columns > div { display: grid; grid-template-columns: 72px 1fr auto; padding: 2px 0; }
.signal-columns > div > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-columns b { color: var(--link); font-weight: 400; }
.signal-columns em { font-style: normal; }
.sector-panel, .index-summary { padding: 8px 10px; }
.sector-panel { overflow-x: auto !important; }
.sector-table { min-width: 720px; table-layout: auto; }
.sector-table td:first-child { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.sector-table td:nth-last-child(-n + 2) { font-size: 10px; }
.headlines { padding: 8px 10px; }
.headlines h2 small { color: #f6c85f; }
.headlines ul { margin: 0; padding: 0; list-style: none; }
.headlines li { display: grid; grid-template-columns: 64px 1fr 90px; gap: 7px; padding: 3px 0; }
.headlines li > span, .headlines li > small { color: var(--muted); }
.headlines li > small { text-align: right; }
.headlines a { overflow: hidden; color: var(--link); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.recent-title { margin-top: 14px !important; }
.recent-quotes { display: flex; flex-wrap: wrap; gap: 6px 15px; }
.recent-quotes span { white-space: nowrap; }
.internal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 6px;
    border: 1px solid #303744;
}
.internal-grid div {
    display: grid;
    gap: 3px;
    padding: 7px;
    border-right: 1px solid #303744;
}
.internal-grid div:last-child { border-right: 0; }
.internal-grid span { color: var(--muted); font-size: 8px; text-transform: uppercase; }
.internal-grid strong { font-size: 13px; }
.events-panel, .earnings-panel, .market-stats { padding: 8px 10px; }
.events-panel h2 small { color: #f6c85f; }
.event-list { display: grid; gap: 1px; }
.event-row {
    display: grid;
    grid-template-columns: 48px 58px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
    min-height: 38px;
    padding: 4px 2px;
    border-bottom: 1px solid #303744;
}
.event-row:last-child { border-bottom: 0; }
.event-row time { color: #aeb5c6; font-weight: 700; }
.event-row > div { min-width: 0; }
.event-row strong, .event-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-row strong { color: var(--link); font-size: 11px; }
.event-row small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.event-type {
    padding: 3px 4px;
    border-radius: 3px;
    color: #fff;
    text-align: center;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
}
.event-market { background: #316a99; }
.event-corporate { background: #815b2b; }
.earnings-scroll { overflow-x: auto; }
.earnings-panel table { min-width: 550px; table-layout: fixed; }
.earnings-panel th:nth-child(1) { width: 55px; }
.earnings-panel th:nth-child(2) { width: 92px; }
.earnings-panel th:nth-child(3) { width: 95px; }
.earnings-panel td:nth-child(3) {
    overflow: hidden;
    color: #b9bfcb;
    text-align: left;
    text-overflow: ellipsis;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border: 1px solid #303744;
}
.stats-grid > div {
    display: grid;
    gap: 5px;
    min-height: 60px;
    align-content: center;
    padding: 8px 10px;
    border-right: 1px solid #303744;
}
.stats-grid > div:last-child { border-right: 0; }
.stats-grid span {
    color: var(--muted);
    font-size: 9px;
    text-transform: uppercase;
}
.stats-grid strong { font-size: 15px; font-variant-numeric: tabular-nums; }

.screener-main { padding-top: 14px; }
.screener-panel { overflow: hidden; border: 1px solid var(--border); border-radius: 4px; background: var(--panel); }
.screener-toolbar {
    display: grid;
    grid-template-columns: 150px minmax(220px, 1fr) minmax(180px, .65fr) auto;
    gap: 10px;
    align-items: end;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}
.screener-toolbar > strong { align-self: center; font-size: 13px; }
.filter-control { display: grid; gap: 4px; }
.filter-control label { color: var(--muted); font-size: 10px; }
.filter-control input, .filter-control select {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 3px;
    outline: 0;
    background: #181d27;
    color: var(--text);
    padding: 0 8px;
}
.toolbar-actions { display: flex; gap: 6px; }
.button {
    display: inline-flex;
    height: 28px;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.button-primary { border-color: #357bb9; background: #357bb9; color: #fff; }
.button-secondary { background: #252b37; color: var(--muted); }
.table-heading { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table-heading div { display: flex; gap: 8px; align-items: baseline; }
.table-heading h2 { margin: 0; font-size: 11px; }
.table-heading span { color: var(--muted); font-size: 10px; }
.table-scroll { max-height: calc(100vh - 200px); overflow: auto; }
.table-scroll table { min-width: 920px; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; padding: 7px 9px; background: #303644; }
.table-scroll tbody td { padding: 6px 9px; border-bottom: 1px solid #303644; }
.table-scroll tbody tr:nth-child(even) { background: var(--panel-alt); }
.ticker { color: var(--link); }
.company-name { font-weight: 700; }
.muted-cell { color: var(--muted); }
.number-cell { text-align: right !important; }
.empty-state { height: 160px; color: var(--muted); text-align: center !important; }
.empty-state strong, .empty-state span { display: block; }

@media (max-width: 1100px) {
    .nav-meta time { display: none; }
    .index-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .breadth-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 12px; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .market-tables, .headlines, .market-stats { grid-column: 1 / -1; }
    .heatmap { grid-row: auto; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid > div:nth-child(3) { border-right: 0; }
    .stats-grid > div:nth-child(-n + 3) { border-bottom: 1px solid #303744; }
}

@media (max-width: 760px) {
    .masthead { min-height: auto; padding: 8px 12px; }
    .wordmark > span { font-size: 34px; }
    .header-search { width: 100%; }
    .nav-row { padding: 0; }
    .nav-meta { display: none; }
    .dashboard-main, .screener-main { width: calc(100% - 20px); }
    .index-grid, .breadth-grid, .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
    .market-tables { grid-template-columns: 1fr; }
    .heatmap-groups { overflow-x: auto; }
    .heatmap-sector { flex: 0 0 100px; }
    .headlines li { grid-template-columns: 55px 1fr; }
    .headlines li small { display: none; }
    .internal-grid { grid-template-columns: repeat(2, 1fr); }
    .internal-grid div:nth-child(2) { border-right: 0; }
    .internal-grid div:nth-child(-n + 2) { border-bottom: 1px solid #303744; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid > div:nth-child(3) { border-right: 1px solid #303744; }
    .stats-grid > div:nth-child(2n) { border-right: 0; }
    .stats-grid > div { border-bottom: 1px solid #303744; }
    .stats-grid > div:nth-last-child(-n + 2) { border-bottom: 0; }
    .screener-toolbar { grid-template-columns: 1fr; }
}
