/* Light/dark mode: the top nav bar (.brand-nav) deliberately stays a fixed
   dark color in both themes — it already uses btn-outline-light/dropdown-menu
   throughout, and re-verifying every one of those against a light background
   across all pages isn't worth it for a toolbar that reads fine dark either
   way. Only the page content (cards, tables, body) actually switches, driven
   by these variables + the [data-bs-theme] selector set on <html> by theme.js.
   IMPORTANT: a fixed-dark background alone isn't enough — Bootstrap's own
   .nav-link/.navbar-brand text color follows the nearest data-bs-theme
   ancestor, which in light mode meant dark text on this still-dark
   background (invisible). Fixed by putting data-bs-theme="dark" directly on
   the <nav> in _Layout.cshtml, which scopes Bootstrap's component colors
   (and this file's --panel/--border-color/etc. variables) to dark for that
   whole subtree regardless of the page's theme. The same pattern is used on
   the two Indicator Settings modals (Market/Details.cshtml, Screener/Index.cshtml)
   that use bg-dark/btn-close-white — any future "always dark" component
   needs this same explicit data-bs-theme="dark", not just a hardcoded
   background color.
   That attribute alone wasn't enough for the modals, though: unlike
   .nav-link/.navbar-brand (which Bootstrap wires as `color: var(--bs-navbar-color)`,
   re-resolved per data-bs-theme), .modal-content never gets its own `color`
   rule from Bootstrap — its text just inherits body's already-computed color.
   Redefining --body-color on a nested [data-bs-theme] subtree doesn't
   retroactively recolor an inherited property; something within that subtree
   has to actually reference var(--body-color) for the recompute to happen.
   The rule below on .modal-content is that reference. */
:root,
[data-bs-theme="dark"] {
    --up: #16c784;
    --down: #ea3943;
    --panel: #161a25;
    --panel-2: #1d2230;
    --border-color: #232838;
    --muted: #9aa3b2;
    --hover-bg: #1b2030;
    --body-bg: #0d1018;
    --body-color: #e6e9ef;
    --chart-tick: #8a93a6;
    --chart-grid: #1f2533;
    --chart-legend: #cbd2df;
}

[data-bs-theme="light"] {
    --up: #0e8a5a;
    --down: #d1293b;
    --panel: #ffffff;
    --panel-2: #f0f2f7;
    --border-color: #dde1ea;
    --muted: #5b6472;
    --hover-bg: #eef1f7;
    --body-bg: #f4f5f9;
    --body-color: #1c2029;
    --chart-tick: #5b6472;
    --chart-grid: #e2e5ec;
    --chart-legend: #333a47;
}

body {
    background: var(--body-bg);
    color: var(--body-color);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.brand-nav {
    background: #11141d;
    border-bottom: 1px solid #232838;
}

.modal-content {
    color: var(--body-color);
}

/* Laptop-width tightening: the nav used to spread its left nav-links and right
   search/bell/user cluster across the full viewport width (container-fluid),
   leaving a large dead gap in the middle on anything wider than a phone. The
   markup now caps at container-xxl and groups the right cluster with gap-2;
   these rules trim per-item spacing so the whole bar reads as one tight unit
   instead of two clusters glued to opposite edges. */
.nav-search-input {
    max-width: 200px;
}

@media (max-width: 1400px) {
    .brand-nav .navbar-nav .nav-link {
        padding-left: .55rem;
        padding-right: .55rem;
        font-size: .92rem;
    }
    .nav-search-input {
        max-width: 140px;
    }
}

.card {
    background: var(--panel);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.stat-card {
    background: linear-gradient(150deg, var(--panel-2), var(--panel));
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.stat-card .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; }

.up, .text-up { color: var(--up) !important; }
.down, .text-down { color: var(--down) !important; }

.table { color: var(--body-color); }
.table > :not(caption) > * > * { background: transparent; }
.table-hover tbody tr:hover { background: var(--hover-bg); }

.ticker-pill {
    display: inline-flex; gap: .4rem; align-items: center;
    background: var(--panel-2); border-radius: 999px; padding: .35rem .8rem; margin: .2rem;
    font-size: .85rem;
}

.index-chip { min-width: 180px; }
.mono { font-variant-numeric: tabular-nums; }
a { text-decoration: none; }
.btn-buy { background: var(--up); border: none; color: #04130c; font-weight: 600; }
.btn-sell { background: var(--down); border: none; color: #fff; font-weight: 600; }

.dashboard-widget {
    cursor: grab;
}
.dashboard-widget:active {
    cursor: grabbing;
}
.dashboard-widget-dragging {
    opacity: .55;
}
.dashboard-customize-menu {
    width: 280px;
    max-height: 420px;
    overflow-y: auto;
}
.dashboard-widget-toggles {
    display: grid;
    gap: 2px;
}
.action-needed-list {
    display: grid;
    gap: 8px;
}
.action-needed-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .6rem .7rem;
    background: var(--panel-2);
}
.min-w-0 { min-width: 0; }

.ac-menu {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1050;
    background: var(--panel-2); border: 1px solid var(--border-color); border-radius: 8px;
    margin-top: 4px; max-height: 320px; overflow-y: auto; display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.ac-item { padding: .5rem .75rem; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: var(--hover-bg); }
.ac-item .ac-sym { font-weight: 600; }
.ac-item .ac-name { color: var(--muted); font-size: .82rem; margin-left: .5rem; }
.ac-item .ac-exch {
    color: var(--muted); font-size: .7rem; border: 1px solid var(--border-color);
    border-radius: 4px; padding: 0 .3rem; margin-left: .5rem; float: right;
}

.sector-heatmap {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 84px;
    gap: 6px;
}
.sector-tile {
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    overflow: hidden;
    transition: transform .12s ease;
    cursor: pointer;
}
.sector-tile:hover, .sector-tile:focus { transform: scale(1.03); z-index: 2; box-shadow: 0 6px 18px rgba(0,0,0,.4); outline: 2px solid rgba(255,255,255,.5); outline-offset: -2px; }
.sector-tile-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .92; }
.sector-tile-pct { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sector-tile-action { font-size: .75rem; opacity: .82; white-space: nowrap; }
@media (max-width: 991px) {
    .sector-heatmap { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 575px) {
    .sector-heatmap { grid-template-columns: repeat(2, 1fr); }
}

.hbar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.hbar-label { width: 130px; flex-shrink: 0; font-weight: 600; font-size: .85rem; text-align: right; }
.hbar-track { flex: 1; background: var(--panel-2); border-radius: 4px; height: 26px; position: relative; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--up); border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; transition: width .3s ease; min-width: 2px; }
.hbar-fill.down { background: var(--down); }
.hbar-fill .hbar-value { color: #04130c; font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-value-outside { color: var(--body-color); font-weight: 700; font-size: .82rem; font-variant-numeric: tabular-nums; margin-left: 6px; white-space: nowrap; }

.pulse-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.pulse-metric {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .55rem .65rem;
    background: var(--panel-2);
    min-width: 0;
}
.pulse-metric span {
    display: block;
    color: var(--muted);
    font-size: .75rem;
}
.pulse-metric strong {
    display: block;
    font-variant-numeric: tabular-nums;
    margin-top: .15rem;
}

.watchlist-mover-list {
    display: grid;
    gap: 6px;
}
.watchlist-mover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .55rem .7rem;
    color: var(--body-color);
    background: var(--panel-2);
}
.watchlist-mover-row:hover {
    background: var(--hover-bg);
}
.saved-screen-table { font-size: .9rem; }
.dashboard-chip-list {
    display: grid;
    gap: 6px;
}
.dashboard-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .45rem .6rem;
    background: var(--panel-2);
    color: var(--body-color);
}
.dashboard-chip-main {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    color: var(--body-color);
    flex: 1;
}
.dashboard-chip:hover {
    background: var(--hover-bg);
}
.dashboard-chip strong,
.dashboard-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-snapshot {
    display: grid;
    gap: 1rem;
}
.fno-index-grid {
    display: grid;
    gap: 6px;
}
.fno-index-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    gap: .5rem;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .5rem .65rem;
    background: var(--panel-2);
    font-size: .9rem;
}
.events-table { font-size: .9rem; }

@media (max-width: 575px) {
    .fno-index-row { grid-template-columns: 1fr; }
}

.breadth-table { font-size: .85rem; white-space: nowrap; }
.breadth-table th { position: sticky; top: 0; background: var(--panel); }
.breadth-table tr[data-drilldown] { cursor: pointer; }
.breadth-table tr[data-drilldown]:hover, .breadth-table tr[data-drilldown]:focus { outline: 2px solid var(--up); outline-offset: -2px; }
.breadth-cell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
