/* ==============================================================
   STRATEGIES DASHBOARD — light pro theme
   Same design family as static/market/market.css (ff-* tokens):
   Inter, white cards, soft-tint badges, dark navy sidebar.
   Class names are unchanged from the original dark theme so the
   template's JS-rendered markup keeps working.
   ============================================================== */

:root {
    --st-bg: #f7f9fc;
    --st-bg-card: #ffffff;
    --st-bg-card-2: #f8fafc;
    --st-sidebar-bg: #0f1b2e;
    --st-sidebar-border: rgba(255, 255, 255, 0.08);
    --st-primary: #1a365d;
    --st-accent: #16a34a;
    --st-accent-soft: #dcfce7;
    --st-accent-deep: #166534;
    --st-accent-blue: #2c7be5;
    --st-accent-yellow: #d97706;
    --st-accent-red: #dc2626;
    --st-accent-purple: #7c3aed;
    --st-text-1: #1f2937;
    --st-text-2: #6b7280;
    --st-text-3: #9ca3af;
    --st-border: #e5e7eb;
    --st-border-soft: #eef1f6;
    --st-shadow-card: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --st-sidebar-w: 240px;
    --st-radius: 12px;
    --st-radius-sm: 8px;
    --st-font: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== LAYOUT ===== */
.st-app-layout {
    display: grid;
    grid-template-columns: var(--st-sidebar-w) 1fr;
    min-height: calc(100vh - 60px);
    width: 100%;
    background: var(--st-bg);
    font-family: var(--st-font);
    color: var(--st-text-1);
}

/* ===== SIDEBAR (stays dark — house pattern, like the Vahan SPA) ===== */
.st-sidebar {
    background: linear-gradient(180deg, #12203a 0%, var(--st-sidebar-bg) 100%);
    border-right: 1px solid var(--st-border);
    display: flex;
    flex-direction: column;
    padding: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.st-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--st-sidebar-border);
}

.st-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #22c55e, #15803d);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.st-brand-text .brand-name {
    font-size: 14px;
    font-weight: 700;
    color: #f1f5f9;
    display: block;
}

.st-brand-text .brand-sub {
    font-size: 11px;
    color: #94a3b8;
    display: block;
}

.st-sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 2px;
}

.st-sidebar-nav .nav-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    padding: 8px 12px 4px;
}

.st-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--st-radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.st-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f8fafc;
}

.st-nav-item.active {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(34, 197, 94, 0.08));
    color: #4ade80;
    font-weight: 600;
}

.st-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.st-main {
    padding: 24px 28px;
    min-width: 0;
}

.st-page {
    display: none;
}

.st-page.active {
    display: block;
}

/* ===== HEADER ===== */
.st-page-header {
    margin-bottom: 22px;
}

.st-page-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--st-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.st-page-header h2 svg {
    width: 22px;
    height: 22px;
    color: var(--st-accent-blue);
    flex-shrink: 0;
}

.st-page-header .st-subtitle {
    font-size: 13px;
    color: var(--st-text-2);
    margin-top: 4px;
}

/* ===== METRIC CARDS ===== */
.st-metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
/* Six cards share one row on a wide page, three a row below it: on the 1,144px strategies page
   they were 5 + 1, the sixth alone (TEXT_CARD_WIDTH.md, 11 Nov 2026). */
@media (min-width: 1100px) {
    .st-metrics-row:has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .st-metrics-row:is(:has(> :nth-child(7):last-child), :has(> :nth-child(8):last-child)) {
        grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 761px) and (max-width: 1099.98px) {
    .st-metrics-row:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.st-metric-card {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 14px 18px;
    border-left: 4px solid var(--st-accent);
    box-shadow: var(--st-shadow-card);
}

.st-metric-card.blue { border-left-color: var(--st-accent-blue); }
.st-metric-card.red { border-left-color: var(--st-accent-red); }
.st-metric-card.yellow { border-left-color: var(--st-accent-yellow); }
.st-metric-card.purple { border-left-color: var(--st-accent-purple); }
.st-metric-card.green { border-left-color: var(--st-accent); }

.st-metric-title,
.st-metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--st-text-2);
    margin-bottom: 4px;
}

.st-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--st-primary);
}

.st-metric-sub {
    font-size: 11px;
    color: var(--st-text-3);
    margin-top: 2px;
}

/* ===== SECTION ===== */
.st-section {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 20px;
    margin-bottom: 22px;
    box-shadow: var(--st-shadow-card);
}

.st-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 15px;
    font-weight: 700;
    color: var(--st-primary);
    border-bottom: 1px solid var(--st-border-soft);
    padding-bottom: 10px;
    margin-bottom: 16px;
}

.st-section-header svg {
    width: 16px;
    height: 16px;
    color: var(--st-accent-blue);
    flex-shrink: 0;
}

.st-section-desc {
    color: var(--st-text-2);
    font-size: 13px;
    margin: -8px 0 12px 0;
}

/* ===== TABLES ===== */
.st-table-wrap {
    overflow-x: auto;
}

.st-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.st-table th {
    background: var(--st-bg-card-2);
    color: var(--st-text-2);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--st-border);
    white-space: nowrap;
    cursor: pointer;
}

.st-table th:hover {
    color: var(--st-text-1);
}

.st-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s, background 0.2s;
}

.st-table th.sortable:hover {
    background: var(--st-border-soft);
    color: var(--st-accent-blue);
}

.st-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--st-border-soft);
    color: var(--st-text-1);
    white-space: nowrap;
}

.st-table tr:hover td {
    background: var(--st-bg-card-2);
}

.st-table tr.reliable td {
    background: rgba(22, 163, 74, 0.05);
}

/* Numeric columns (NUMBER_ALIGNMENT.md). These tables are built in the browser, so
   static/market/numalign.js adds .num to every column of figures as a table appears. */
.st-table { font-variant-numeric: tabular-nums; }
.st-table th.num, .st-table td.num { text-align: right; }

.st-table .positive { color: var(--st-accent); font-weight: 600; }
.st-table .negative { color: var(--st-accent-red); font-weight: 600; }
.st-table .neutral { color: var(--st-accent-yellow); }

/* ===== BADGES (soft tints, market-pages style) ===== */
.st-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.st-badge.reliable {
    background: var(--st-accent-soft);
    color: var(--st-accent-deep);
}

.st-badge.other {
    background: #f1f5f9;
    color: #475569;
}

/* ===== FILTERS ===== */
.st-filters {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.st-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.st-filter-group label {
    font-size: 12px;
    color: var(--st-text-2);
    font-weight: 500;
}

.st-filter-group input[type="range"] {
    width: 120px;
    accent-color: var(--st-accent);
}

.st-filter-group input[type="checkbox"] {
    accent-color: var(--st-accent);
    width: 16px;
    height: 16px;
}

.st-filter-group select {
    background: var(--st-bg-card);
    color: var(--st-text-1);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    padding: 5px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.st-filter-group select:focus {
    outline: none;
    border-color: var(--st-accent-blue);
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.12);
}

/* ===== CHARTS ===== */
.st-chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.st-chart-box {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 16px;
    height: 320px;
    box-shadow: var(--st-shadow-card);
}

.st-chart-box canvas {
    max-height: 280px !important;
}

.st-chart-box.full {
    grid-column: 1 / -1;
}

.st-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--st-text-2);
    margin-bottom: 12px;
}

/* ===== STOCK SELECT ===== */
.st-stock-select-wrap {
    margin-bottom: 20px;
}

.st-stock-select-wrap select {
    background: var(--st-bg-card);
    color: var(--st-text-1);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    width: 300px;
    max-width: 100%;
    cursor: pointer;
}

.st-stock-select-wrap select:focus {
    outline: none;
    border-color: var(--st-accent-blue);
}

/* ===== Searchable stock combobox ===== */
.st-combo {
    position: relative;
    width: 320px;
    max-width: 100%;
}
.st-combo-input {
    background: var(--st-bg-card);
    color: var(--st-text-1);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.st-combo-input:focus {
    border-color: var(--st-accent-blue);
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.12);
}
.st-combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    max-height: 320px;
    overflow-y: auto;
    z-index: 70;
    box-shadow: 0 10px 28px rgba(16, 24, 40, 0.14);
}
.st-combo-group {
    padding: 8px 14px 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--st-text-3);
    background: var(--st-bg-card-2);
    position: sticky;
    top: 0;
}
.st-combo-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13.5px;
    color: var(--st-text-1);
    border-bottom: 1px solid var(--st-border-soft);
}
.st-combo-opt:last-child { border-bottom: none; }
.st-combo-opt:hover,
.st-combo-opt.active {
    background: #e7f0fc;
    color: var(--st-primary);
}
.st-combo-sym { font-weight: 600; }
.st-combo-badge {
    font-size: 11px;
    color: var(--st-text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== STRATEGY INFO ===== */
.st-info-card {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--st-shadow-card);
}

.st-info-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--st-primary);
    margin-bottom: 12px;
}

.st-info-card p, .st-info-card li {
    font-size: 14px;
    color: var(--st-text-2);
    line-height: 1.7;
}

.st-info-card ul {
    padding-left: 20px;
}

.st-info-card .highlight {
    color: var(--st-accent-deep);
    font-weight: 600;
}

.st-info-card .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.st-info-card .stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--st-border-soft);
}

.st-info-card .stat-label {
    color: var(--st-text-2);
    font-size: 13px;
}

.st-info-card .stat-value {
    color: var(--st-text-1);
    font-weight: 600;
    font-size: 13px;
}

/* ===== LOADING ===== */
.st-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--st-text-3);
    font-size: 14px;
}

.st-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--st-border);
    border-top-color: var(--st-accent);
    border-radius: 50%;
    animation: st-spin 0.8s linear infinite;
    margin-right: 10px;
}

@keyframes st-spin {
    to { transform: rotate(360deg); }
}

/* ===== EMPTY STATE ===== */
.st-empty {
    text-align: center;
    padding: 40px;
    color: var(--st-text-3);
    font-size: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .st-app-layout {
        grid-template-columns: 1fr;
    }
    .st-sidebar {
        position: fixed;
        left: -260px;
        top: 60px;
        z-index: 999;
        width: var(--st-sidebar-w);
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
        transition: left 0.3s;
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.35);
    }
    .st-sidebar.open {
        left: 0;
    }
    .st-main {
        padding: 16px;
    }
    .st-chart-row {
        grid-template-columns: 1fr;
    }
    .st-metrics-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .st-mobile-toggle {
        display: block !important;
    }

    /* ---- wide data tables on a phone ----
       These stay TABLES rather than becoming stacked cards like
       /category/corporate-actions. The rows here are screener hits,
       holdings and trade logs, and the reader compares the same metric
       DOWN many rows; a 10-column screener as cards is ~160px per stock,
       so comparing two stocks means scrolling past everything between
       them. Cards win when a row is one thing you read on its own, which
       these are not. What was missing is a way to keep your place while
       dragging sideways. */
    .st-table-wrap {
        -webkit-overflow-scrolling: touch;
        /* a sideways drag that runs past the end of the table must not
           become a browser back-gesture or pan the page behind it */
        overscroll-behavior-x: contain;
        /* right-edge shade that appears only while there is more table to
           reach: the cover layer is positioned against the CONTENT
           (attachment: local) so it slides over the shadow exactly when
           you hit the far right */
        background:
            linear-gradient(to left, var(--st-bg-card) 42%, rgba(255, 255, 255, 0))
                right center / 34px 100% no-repeat local,
            radial-gradient(farthest-side at 100% 50%, rgba(16, 24, 40, .16), rgba(16, 24, 40, 0))
                right center / 13px 100% no-repeat scroll;
    }

    /* Pin the identity column. Without it, dragging out to column 8 leaves
       a row of bare numbers with nothing saying which stock they belong to
       — which is the actual reason these tables are hard to read on a
       phone. box-shadow rather than border-right: a border-collapse table
       drops borders on sticky cells. Backgrounds must be OPAQUE here or
       the scrolled-under columns show through the pinned one. */
    .st-table th:first-child,
    .st-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--st-bg-card);
        /* the soft half of this is not decoration: it makes the pinned
           column read as sitting ABOVE the rest, so the part-scrolled
           column beside it looks like it is passing underneath rather
           than like a clipped cell */
        box-shadow: 1px 0 0 var(--st-border), 7px 0 7px -7px rgba(16, 24, 40, .28);
    }
    .st-table th:first-child { background: var(--st-bg-card-2); z-index: 3; }
    /* opaque equivalents of the translucent row tints above */
    .st-table tr.reliable td:first-child { background: #f3faf6; }
    .st-table tr:hover td:first-child { background: var(--st-bg-card-2); }

    /* fit more columns per screenful */
    .st-table th { padding: 8px 10px; }
    .st-table td { padding: 8px 10px; font-size: 12.5px; }
}

.st-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1001;
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.4);
}

/* ===== STRATEGY LAB (famous strategies) ===== */
.st-nav-badge {
    margin-left: auto;
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 6px;
}

.st-lab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: 16px;
}

.st-lab-card {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-card);
    padding: 18px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.st-lab-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.10);
    border-color: #c7d2fe;
}

.st-lab-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.st-lab-fam {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef1f6;
    color: #64748b;
}

.st-lab-fam.fam-trend    { background: #dbeafe; color: #1d4ed8; }
.st-lab-fam.fam-momentum { background: #ffedd5; color: #c2410c; }
.st-lab-fam.fam-meanrev  { background: #ede9fe; color: #6d28d9; }
.st-lab-fam.fam-fund     { background: #dcfce7; color: #15803d; }

.st-lab-live {
    font-size: 11px;
    font-weight: 600;
    color: var(--st-accent);
    white-space: nowrap;
}

.st-lab-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--st-text-1);
}

.st-lab-origin {
    font-size: 11.5px;
    color: var(--st-text-3);
    font-style: italic;
    margin-top: -4px;
}

.st-lab-desc {
    font-size: 12.5px;
    color: var(--st-text-2);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.st-lab-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

.st-lab-chip {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--st-bg-card-2);
    border: 1px solid var(--st-border-soft);
    border-radius: var(--st-radius-sm);
    padding: 6px 10px;
    min-width: 72px;
}

.st-lab-chip span {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--st-text-3);
    font-weight: 600;
}

.st-lab-chip strong {
    font-size: 13px;
    color: var(--st-text-1);
}

.st-lab-chip.good strong { color: var(--st-accent); }
.st-lab-chip.bad strong  { color: var(--st-accent-red); }

.st-lab-cta {
    margin-top: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--st-accent-blue);
}

.st-lab-back {
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    color: var(--st-text-1);
    font-family: var(--st-font);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    margin-bottom: 4px;
}

.st-lab-back:hover { border-color: var(--st-accent-blue); color: var(--st-accent-blue); }

.st-lab-editorial p {
    font-size: 13.5px;
    line-height: 1.7;
    color: #374151;
    margin: 0 0 12px;
}

.st-lab-editorial p:last-child { margin-bottom: 0; }

.st-lab-asof {
    background: #eef1f6;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: #64748b;
    margin-left: 8px;
    font-weight: 500;
}

.st-lab-coname {
    font-size: 11px;
    color: var(--st-text-3);
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.st-export-btn {
    margin-left: auto;
    background: var(--st-bg-card);
    border: 1px solid var(--st-border);
    border-radius: var(--st-radius-sm);
    color: var(--st-text-2);
    font-family: var(--st-font);
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 12px;
    cursor: pointer;
}

.st-export-btn:hover { border-color: var(--st-accent-blue); color: var(--st-accent-blue); }

.st-sym-link {
    color: var(--st-accent-blue);
    text-decoration: none;
}

.st-sym-link:hover { text-decoration: underline; }

@media (max-width: 900px) {
    .st-lab-grid { grid-template-columns: 1fr; }
}
