/* ─── SwingBot · Terminal Amber Design System ─────────────────
   IBM Plex Mono throughout. Near-black. Single amber accent.
   Bloomberg-terminal utilitarian aesthetic.
   ──────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600&display=swap');

/* ── Dark theme (default, softened for eye comfort) ── */
:root {
    --bg: #181818;
    --bg1: #202020;
    --bg2: #272727;
    --bg3: #303030;
    --border: #383838;
    --border2: #464646;

    --tx: #f0f0f0;
    --tx2: #a0a0a0;
    --tx3: #606060;

    --amber: #f0a500;
    --amber-dim: rgba(240, 165, 0, 0.10);
    --amber-mid: rgba(240, 165, 0, 0.25);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.10);

    --font: 'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
    --topbar-h: 44px;
    --strip-h: 32px;
    --toolbar-h: 36px;
}

/* ── Light theme ── */
[data-theme="light"] {
    --bg: #f5f4ef;
    --bg1: #ffffff;
    --bg2: #eeece6;
    --bg3: #e4e2db;
    --border: #d8d6ce;
    --border2: #c8c6be;

    --tx: #1c1c1c;
    --tx2: #5c5c5c;
    --tx3: #a0a0a0;

    --amber: #b86e00;
    --amber-dim: rgba(184, 110, 0, 0.08);
    --amber-mid: rgba(184, 110, 0, 0.18);
    --green: #16803c;
    --green-dim: rgba(22, 128, 60, 0.10);
    --red: #c82020;
    --red-dim: rgba(200, 32, 32, 0.08);
}

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

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--tx);
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── Topbar ─────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-h);
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    overflow: hidden;
}

.brand {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--amber);
    flex-shrink: 0;
    user-select: none;
}

.sep {
    width: 1px;
    height: 18px;
    background: var(--border2);
    flex-shrink: 0;
}

.spacer {
    flex: 1;
}

/* ─── RSI Conditions ─────────────────────────────────────────── */

.conditions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cond {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cond-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--tx2);
    letter-spacing: 0.1em;
    width: 12px;
    text-align: center;
}

.cond select,
.cond input[type="number"] {
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--tx);
    font-family: var(--font);
    font-size: 11px;
    padding: 2px 4px;
    outline: none;
    transition: border-color 0.15s;
    height: 24px;
}

.cond select {
    margin-left: 10px;
    width: 34px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: center;
    border-radius: 2px;
}

.cond input[type="number"] {
    width: 40px;
    text-align: center;
    border-radius: 2px;
    -moz-appearance: textfield;
}

.cond input[type="number"]::-webkit-inner-spin-button,
.cond input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.cond select:focus,
.cond input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 1px var(--amber-dim);
}

/* ─── Search ─────────────────────────────────────────────────── */

.search-wrap {
    position: relative;
    flex-shrink: 0;
}

.search-input {
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--tx);
    font-family: var(--font);
    font-size: 11px;
    padding: 2px 8px;
    height: 24px;
    width: 180px;
    outline: none;
    border-radius: 2px;
    transition: border-color 0.15s, width 0.2s;
}

.search-input::placeholder {
    color: var(--tx3);
}

.search-input:focus {
    border-color: var(--amber);
    width: 220px;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    min-width: 260px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    z-index: 200;
    display: none;
    max-height: 220px;
    overflow-y: auto;
}

.search-dropdown.active {
    display: block;
}

.search-item {
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--bg3);
}

.search-item .sym {
    font-size: 11px;
    font-weight: 600;
    color: var(--amber);
}

.search-item .co {
    font-size: 10px;
    color: var(--tx2);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Topbar chips & buttons ─────────────────────────────────── */

.chip {
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--tx2);
    font-family: var(--font);
    font-size: 10px;
    padding: 2px 8px;
    height: 22px;
    cursor: pointer;
    border-radius: 11px;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
}

.chip:hover,
.chip.has-stocks {
    border-color: var(--amber);
    color: var(--amber);
}

.action-btn {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    height: 24px;
    border: 1px solid transparent;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.action-btn.muted {
    background: transparent;
    border-color: var(--border2);
    color: var(--tx2);
}

.action-btn.muted:hover {
    border-color: var(--tx2);
    color: var(--tx);
}

.action-btn.primary {
    background: var(--amber);
    border-color: var(--amber);
    color: #000;
    font-weight: 600;
}

.action-btn.primary:hover {
    background: #ffc31a;
}

.action-btn.primary:disabled {
    background: var(--bg3);
    border-color: var(--border2);
    color: var(--tx3);
    cursor: not-allowed;
}

.action-btn.danger {
    background: var(--red-dim);
    border-color: var(--red);
    color: var(--red);
}

.action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.action-btn.rescreen {
    background: var(--amber-dim);
    border-color: var(--amber);
    color: var(--amber);
    font-weight: 600;
}

.action-btn.rescreen:hover {
    background: var(--amber-mid);
}

.action-btn.rescreen:disabled {
    background: var(--bg3);
    border-color: var(--border2);
    color: var(--tx3);
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

/* ── Mode selector (RSI / ICHI / BOTH segmented control) ── */
.mode-selector {
    display: flex;
    border: 1px solid var(--border2);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.mode-btn {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    padding: 3px 10px;
    height: 24px;
    border: none;
    border-right: 1px solid var(--border2);
    cursor: pointer;
    background: transparent;
    color: var(--tx2);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.mode-btn:last-child {
    border-right: none;
}

.mode-btn:hover {
    background: var(--bg3);
    color: var(--tx);
}

.mode-btn.active {
    background: var(--amber-dim);
    color: var(--amber);
    font-weight: 600;
}

.provider {
    font-size: 9px;
    color: var(--tx3);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.theme-btn {
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--tx2);
    font-family: var(--font);
    font-size: 13px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    line-height: 1;
    padding: 0;
}

.theme-btn:hover {
    border-color: var(--amber);
    color: var(--amber);
    background: var(--amber-dim);
}

/* ─── Stocks panel ───────────────────────────────────────────── */

.stocks-panel {
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    padding: 6px 14px;
    max-height: 96px;
    overflow-y: auto;
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.stock-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    padding: 1px 6px 1px 8px;
    font-size: 10px;
    color: var(--tx);
    border-radius: 2px;
    animation: chipIn 0.15s ease;
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.stock-chip .x {
    color: var(--tx3);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0 1px;
    transition: color 0.1s;
}

.stock-chip .x:hover {
    color: var(--red);
}

/* ─── Scan strip ─────────────────────────────────────────────── */

.scan-strip {
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    height: var(--strip-h);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 14px;
    gap: 3px;
}

.scan-bar-track {
    height: 2px;
    background: var(--border);
    border-radius: 1px;
    overflow: hidden;
}

.scan-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--amber);
    border-radius: 1px;
    transition: width 0.4s ease;
}

.scan-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scan-label {
    font-size: 9px;
    color: var(--tx2);
    letter-spacing: 0.05em;
}

.scan-symbol {
    font-size: 10px;
    color: var(--amber);
    font-weight: 500;
}

.scan-status {
    font-size: 9px;
    color: var(--tx3);
    margin-left: auto;
}

/* ─── Results section ────────────────────────────────────────── */

.results-section {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h) - var(--strip-h) - var(--toolbar-h));
}

.table-toolbar {
    height: var(--toolbar-h);
    background: var(--bg1);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    flex-shrink: 0;
}

.filter-wrap {
    position: relative;
}

.filter-input {
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--tx);
    font-family: var(--font);
    font-size: 11px;
    padding: 2px 8px;
    height: 22px;
    width: 160px;
    outline: none;
    border-radius: 2px;
    transition: border-color 0.15s;
}

.filter-input::placeholder {
    color: var(--tx3);
}

.filter-input:focus {
    border-color: var(--amber);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.tb-btn {
    background: transparent;
    border: 1px solid var(--border2);
    color: var(--tx2);
    font-family: var(--font);
    font-size: 10px;
    padding: 2px 8px;
    height: 22px;
    cursor: pointer;
    border-radius: 2px;
    letter-spacing: 0.06em;
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.tb-btn:hover,
.tb-btn.active {
    border-color: var(--amber);
    color: var(--amber);
}

.results-stats {
    font-size: 10px;
    color: var(--tx3);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ─── Table ──────────────────────────────────────────────────── */

.table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.results-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table th {
    background: var(--bg1);
    padding: 6px 10px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--tx3);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
}

.results-table th.sortable {
    cursor: pointer;
    transition: color 0.15s;
}

.results-table th.sortable:hover {
    color: var(--tx2);
}

.results-table th.sortable.sorted {
    color: var(--amber);
}

.arr {
    font-size: 7px;
    opacity: 0.4;
    margin-left: 2px;
    display: inline-block;
}

.sorted .arr {
    opacity: 1;
}

/* Column widths */
.col-rank {
    width: 34px;
}

.col-symbol {
    width: 100px;
}

.col-status {
    width: 72px;
}

.col-rsi {
    width: 72px;
}

.col-prox {
    width: 60px;
}

.col-charts {
    width: 200px;
}

.results-table td {
    padding: 5px 10px;
    font-size: 11px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.results-table tbody tr {
    transition: background 0.1s;
    animation: rowIn 0.25s ease both;
}

@keyframes rowIn {
    from {
        opacity: 0;
        transform: translateX(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.results-table tbody tr:hover {
    background: var(--bg2);
}

.results-table tbody tr.primary-match {
    background: rgba(240, 165, 0, 0.03);
}

.results-table tbody tr.primary-match:hover {
    background: rgba(240, 165, 0, 0.06);
}

/* Rank */
.td-rank {
    color: var(--tx3);
    font-size: 10px;
}

/* Symbol */
.td-symbol {
    font-weight: 600;
    font-size: 12px;
    color: var(--tx);
    letter-spacing: 0.04em;
}

/* Status dots */
.status-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot.on {
    background: var(--green);
}

.dot.off {
    background: var(--border2);
}

.status-label {
    font-size: 9px;
    color: var(--tx3);
    margin-left: 4px;
}

/* RSI values */
.rsi {
    font-size: 11px;
    font-weight: 500;
    padding: 1px 5px;
    border-radius: 2px;
    display: inline-block;
    min-width: 36px;
    text-align: center;
}

.rsi.match {
    background: var(--green-dim);
    color: var(--green);
}

.rsi.no-match {
    color: var(--tx3);
}

.rsi.na {
    color: var(--tx3);
    font-size: 9px;
}

/* Proximity */
.prox {
    font-size: 11px;
}

.prox.met {
    color: var(--green);
}

.prox.close {
    color: var(--amber);
}

.prox.far {
    color: var(--tx3);
}

/* Charts */
.chart-thumbs {
    display: flex;
    gap: 3px;
    align-items: center;
}

.chart-thumb {
    width: 56px;
    height: 34px;
    object-fit: cover;
    border: 1px solid var(--border);
    cursor: pointer;
    opacity: 0.85;
    transition: all 0.2s;
    border-radius: 1px;
    background: var(--bg2);
}

.chart-thumb:hover {
    opacity: 1;
    border-color: var(--amber);
    transform: scale(2.2);
    z-index: 20;
    position: relative;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.8);
}

.chart-label {
    font-size: 8px;
    color: var(--tx3);
    text-align: center;
    display: block;
}

/* Empty state */
.empty-cell {
    text-align: center;
    padding: 60px 20px !important;
    color: var(--tx3) !important;
    font-size: 11px !important;
    letter-spacing: 0.06em;
}

/* ─── Chart modal ────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    position: relative;
    background: var(--bg1);
    border: 1px solid var(--border2);
    padding: 28px 20px 16px;
    max-width: 92vw;
    max-height: 90vh;
}

.modal-box img {
    display: block;
    max-width: 100%;
    max-height: 75vh;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: var(--tx3);
    font-size: 14px;
    cursor: pointer;
    font-family: var(--font);
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--tx);
}

.modal-link {
    display: block;
    text-align: right;
    margin-top: 8px;
    font-size: 10px;
    color: var(--amber);
    text-decoration: none;
    letter-spacing: 0.06em;
}

.modal-link:hover {
    text-decoration: underline;
}

/* ─── Scrollbars ─────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--tx3);
}

/* ─── Select dropdown ────────────────────────────────────────── */

select option {
    background: var(--bg2);
    color: var(--tx);
}

/* ─── Focus ring ─────────────────────────────────────────────── */

:focus-visible {
    outline: 1px solid var(--amber);
    outline-offset: 1px;
}

/* ─── Responsive ─────────────────────────────────────────────── */

@media (max-width: 800px) {
    .conditions {
        gap: 6px;
    }

    .search-input {
        width: 130px;
    }

    .search-input:focus {
        width: 150px;
    }

    .chart-thumb:hover {
        transform: scale(1.5);
    }
}

/* ─── Sticky table columns ───────────────────────────────────── */

/* Symbol column — sticky at left edge */
.results-table th.col-symbol,
.results-table td.col-symbol {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg1);
}

/* Sticky header cells need higher z-index than sticky body cells */
.results-table thead th.col-symbol {
    z-index: 12;
}

/* Symbol cell — ticker + company name stacked */
.sym-ticker {
    display: block;
    font-weight: 600;
}

.sym-company {
    display: block;
    font-size: 9px;
    color: var(--tx2);
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

/* Ichimoku columns collapse to zero on small viewports — hide them.
   Users can still sort by ichi criteria via the Sort panel. */
@media (max-width: 768px) {
    .col-ichi {
        display: none;
    }
}

/* ─── Hamburger button (desktop: hidden) ─────────────────────── */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border2);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 2px;
    height: 28px;
    width: 32px;
    flex-shrink: 0;
    margin-left: auto;
    transition: border-color 0.15s;
}

.hamburger span {
    display: block;
    height: 1.5px;
    width: 18px;
    background: var(--tx2);
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.15s;
}

.hamburger:hover {
    border-color: var(--amber);
}

.hamburger:hover span {
    background: var(--amber);
}

/* X transformation when open */
.topbar.nav-open .hamburger span:nth-child(1) {
    transform: translateY(5.5px) rotate(45deg);
}

.topbar.nav-open .hamburger span:nth-child(2) {
    opacity: 0;
}

.topbar.nav-open .hamburger span:nth-child(3) {
    transform: translateY(-5.5px) rotate(-45deg);
}

/* Desktop: topbar-menu is a normal flex row (no height collapse) */
.topbar-menu {
    display: contents;  /* behaves as if children are direct flex children of topbar */
}

/* ─── Mobile breakpoint ≤ 768px ──────────────────────────────── */

@media (max-width: 768px) {
    /* Override desktop topbar — allow height to expand with menu */
    .topbar {
        height: auto;
        min-height: var(--topbar-h);
        flex-wrap: wrap;
        overflow: visible;
        padding-bottom: 0;
        align-items: center;
    }

    /* Brand stays in first row, full topbar-h */
    .brand {
        height: var(--topbar-h);
        display: flex;
        align-items: center;
    }

    /* Show hamburger */
    .hamburger {
        display: flex;
    }

    /* Collapsible menu — full width, column layout, collapsed by default */
    .topbar-menu {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, padding 0.25s ease;
        gap: 10px;
        padding: 0 14px;
        border-top: 0px solid var(--border);
    }

    /* Expanded state */
    .topbar.nav-open .topbar-menu {
        max-height: 640px;
        padding: 10px 14px;
        border-top-width: 1px;
    }

    /* Sep divs inside topbar-menu are not needed on mobile — hide them */
    .topbar-menu .sep {
        display: none;
    }

    /* Spacer not needed in column layout */
    .topbar-menu .spacer {
        display: none;
    }

    /* Conditions panel: stack as rows inside topbar-menu */
    .topbar-menu .conditions {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Action buttons: flex row, wrap if needed */
    .topbar-menu .action-btn {
        flex-shrink: 0;
    }

    /* Provider badge and theme toggle in a row at bottom of menu */
    .topbar-menu .provider,
    .topbar-menu .theme-btn {
        align-self: flex-end;
    }

    /* Search input: full width in mobile menu */
    .topbar-menu .search-wrap {
        width: 100%;
    }

    .topbar-menu .search-input {
        width: 100%;
    }

    .topbar-menu .search-input:focus {
        width: 100%;
    }

    /* Scan strip: wrap text, prevent overflow */
    .scan-meta {
        flex-wrap: wrap;
        gap: 4px;
    }

    .scan-symbol {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Results section: adjust height for variable topbar */
    .results-section {
        height: auto;
        min-height: calc(100vh - 120px);
    }

    /* Chart modal: full screen */
    .modal-box {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border: none;
        border-radius: 0;
        padding: 40px 12px 16px;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .modal-box img {
        flex: 1;
        max-width: 100%;
        max-height: calc(100vh - 80px);
        object-fit: contain;
    }
}

/* ── Conditions Accordion ────────────────────────────────────── */

/* Desktop: hide the toggle button, always show body */
.conditions-accordion {
    display: contents; /* transparent wrapper on desktop — no layout impact */
}

.conditions-toggle {
    display: none; /* hidden on desktop */
}

.conditions-body {
    display: contents; /* transparent on desktop — children flow naturally */
}

/* Mobile accordion behaviour */
@media (max-width: 768px) {
    .conditions-accordion {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0;
    }

    .conditions-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: none;
        border: 1px solid var(--border);
        border-radius: 4px;
        color: var(--tx1);
        font-family: var(--font);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.1em;
        padding: 8px 12px;
        cursor: pointer;
        text-align: left;
    }

    .conditions-toggle:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

    .conditions-arrow {
        font-size: 13px;
        transition: transform 0.2s ease;
    }

    /* Collapsed state (default on mobile — body has no .open class initially) */
    .conditions-body {
        display: flex;
        flex-direction: column;
        gap: 8px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease, padding 0.25s ease;
        padding: 0;
    }

    /* Expanded state */
    .conditions-body.open {
        max-height: 320px;
        padding: 8px 0 4px;
    }
}

/* ── Sort Panel ──────────────────────────────────────────────── */
.sort-panel {
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 6px 0 4px;
}

.sort-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 10px;
    color: var(--tx2);
    gap: 8px;
}

.sort-panel-reset {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--tx2);
    font-size: 10px;
    font-family: var(--font);
    padding: 2px 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.sort-panel-reset:hover {
    border-color: var(--amber);
    color: var(--amber);
}

.sort-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sort-chip {
    background: var(--bg1);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--tx2);
    font-family: var(--font);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.sort-chip:hover {
    border-color: var(--border2);
}

.sort-chip.active {
    border-color: var(--amber);
    color: var(--amber);
}

/* ─── Password Gate ────────────────────────────────────────────
   Full-screen overlay blocking all content until authenticated.
   Uses existing design tokens for terminal amber aesthetic.
   ──────────────────────────────────────────────────────────── */

#passwordGate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

#passwordGate.hidden {
    display: none !important;
}

.gate-box {
    background: var(--bg1);
    border: 1px solid var(--border2);
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 320px;
    max-width: 90vw;
}

.gate-brand {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--amber);
    text-align: center;
    margin-bottom: 4px;
}

.gate-subtitle {
    font-size: 10px;
    color: var(--tx3);
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
}

.gate-input {
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--tx);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 12px;
    height: 36px;
    outline: none;
    border-radius: 2px;
    transition: border-color 0.15s;
    width: 100%;
    letter-spacing: 0.12em;
}

.gate-input:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 1px var(--amber-dim);
}

.gate-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.gate-btn {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    height: 34px;
    background: var(--amber);
    border: 1px solid var(--amber);
    color: #000;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s;
}

.gate-btn:hover:not(:disabled) {
    background: #ffc31a;
}

.gate-btn:disabled {
    background: var(--bg3);
    border-color: var(--border2);
    color: var(--tx3);
    cursor: not-allowed;
}

.gate-error {
    font-size: 10px;
    color: var(--red);
    text-align: center;
    min-height: 14px;
    letter-spacing: 0.04em;
}

.gate-countdown {
    font-size: 10px;
    color: var(--amber);
    text-align: center;
    letter-spacing: 0.04em;
    line-height: 1.5;
}
