.crypto-front-wrap {
    max-width: 1360px;
    margin: 1.5rem auto 3rem auto;
    padding: 0 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.crypto-front-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.35rem 1.75rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.15);
    margin-bottom: 1.25rem;
}
.crypto-front-title {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.crypto-front-title h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.01em;
}
.crypto-front-title p {
    margin: 0.25rem 0 0 0;
    font-size: 0.88rem;
    color: #94a3b8;
}
.crypto-front-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}
.crypto-tab-btn {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 1rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.crypto-tab-btn:hover {
    background: rgba(51, 65, 85, 0.9);
    color: #ffffff;
}
.crypto-tab-btn.active {
    background: #2563eb;
    border-color: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.crypto-admin-btn {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 1.1rem;
    border-radius: 8px;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
    transition: transform 0.15s, opacity 0.15s;
}
.crypto-admin-btn:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

/* Telemetry Macro Cards (5 cards matching format_positions_summary_html) */
.positions-telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}
.telemetry-card {
    background: var(--card-bg, var(--bg-secondary, #1e293b));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    border-left: 4px solid #2196f3;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
.telemetry-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #94a3b8);
    font-weight: 700;
}
.telemetry-val {
    font-size: 1.12rem;
    font-weight: 800;
    color: var(--text-main, var(--text-primary, #f8fafc));
    margin-top: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls Rows */
.positions-controls-card {
    background: var(--card-bg, var(--bg-secondary, #1e293b));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.positions-top-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
}
.ctrl-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.ctrl-field.grow {
    flex: 1 1 260px;
}
.ctrl-field label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ctrl-input,
.ctrl-select {
    height: 42px;
    padding: 0 0.85rem;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg-color, var(--bg-primary, #0f172a));
    color: var(--text-main, var(--text-primary, #f8fafc));
    box-sizing: border-box;
}
.positions-row-btn {
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0 1.1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.86rem;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: all 0.15s ease;
    box-sizing: border-box;
}
.positions-row-btn.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}
.positions-row-btn.btn-primary:hover {
    opacity: 0.94;
}
.positions-row-btn.btn-up {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}
.positions-row-btn.btn-up:hover {
    opacity: 0.94;
}
.positions-row-btn.btn-secondary {
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-main, var(--text-primary, #f8fafc));
}
.positions-row-btn.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.24);
}
.positions-status-bar {
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text-secondary, #cbd5e1);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    margin-bottom: 0.85rem;
}
.positions-signals-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, rgba(148, 163, 184, 0.18));
}
.signal-checks-wrap {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    flex: 1 1 auto;
}
.signal-check-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.42rem 0.72rem;
    border-radius: 7px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.35);
    color: var(--text-main, var(--text-primary, #e2e8f0));
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}
.signal-check-pill:hover {
    border-color: #3b82f6;
}
.signal-check-pill input {
    margin: 0;
    cursor: pointer;
    accent-color: #2563eb;
}
.signal-quick-btns {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Matrix Table */
.crypto-table-card {
    background: var(--card-bg, var(--bg-secondary, #1e293b));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    border-radius: 14px;
    padding: 1rem 1.15rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.crypto-market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}
.crypto-market-table th {
    text-align: left;
    padding: 0.75rem 0.65rem;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #94a3b8);
    border-bottom: 2px solid var(--border-color, rgba(148, 163, 184, 0.22));
    white-space: nowrap;
}
.crypto-market-table td {
    padding: 0.68rem 0.65rem;
    border-bottom: 1px solid var(--border-color, rgba(148, 163, 184, 0.12));
    color: var(--text-main, var(--text-primary, #f1f5f9));
    vertical-align: middle;
    white-space: nowrap;
}
.crypto-market-table tr:hover td {
    background: rgba(59, 130, 246, 0.06);
}
.coin-icon-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    display: inline-block;
}
.coin-fallback-badge {
    display: inline-flex;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #334155;
    color: #f8fafc;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
}
.watch-star-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.12rem;
    line-height: 1;
    color: #64748b;
    padding: 0.12rem 0.28rem;
    border-radius: 6px;
    transition: transform 0.15s ease, color 0.15s ease;
    vertical-align: middle;
}
.watch-star-btn:hover {
    color: #fbbf24;
    transform: scale(1.18);
}
.watch-star-btn.starred {
    color: #f59e0b;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.35);
}
.positions-row-btn.btn-watchlist {
    border-color: rgba(245, 158, 11, 0.38);
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.1);
}
.positions-row-btn.btn-watchlist:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: #f59e0b;
}
.positions-row-btn.btn-watchlist.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.3);
}
.watch-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.18);
}
[data-theme="light"] .positions-row-btn.btn-watchlist {
    color: #b45309;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(217, 119, 6, 0.4);
}
[data-theme="light"] .positions-row-btn.btn-watchlist.active {
    color: #ffffff;
}
.positions-row-btn.btn-tr {
    border-color: rgba(227, 10, 23, 0.42);
    color: #fca5a5;
    background: rgba(227, 10, 23, 0.12);
}
.positions-row-btn.btn-tr:hover {
    background: rgba(227, 10, 23, 0.22);
    border-color: #e30a17;
}
.positions-row-btn.btn-tr.active {
    background: linear-gradient(135deg, #e30a17, #b91c1c);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(227, 10, 23, 0.35);
}
[data-theme="light"] .positions-row-btn.btn-tr {
    color: #b91c1c;
    background: rgba(227, 10, 23, 0.1);
    border-color: rgba(227, 10, 23, 0.38);
}
[data-theme="light"] .positions-row-btn.btn-tr.active {
    color: #ffffff;
}
.empty-setup-cta {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary, #94a3b8);
    white-space: normal !important;
}

/* ===================================================================
   LIGHT MODE OVERRIDES ([data-theme="light"]) — Dark mode untouched
   =================================================================== */
[data-theme="light"] .crypto-front-hero {
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    color: #0f172a;
    border: 1px solid #cbd5e1;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}
[data-theme="light"] .crypto-front-title h1 {
    color: #0f172a;
}
[data-theme="light"] .crypto-front-title p {
    color: #475569;
}
[data-theme="light"] .crypto-tab-btn {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}
[data-theme="light"] .crypto-tab-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}
[data-theme="light"] .crypto-tab-btn.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}
[data-theme="light"] .telemetry-card,
[data-theme="light"] .positions-controls-card,
[data-theme="light"] .crypto-table-card {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}
[data-theme="light"] .telemetry-label,
[data-theme="light"] .ctrl-field label,
[data-theme="light"] .crypto-market-table th {
    color: #475569;
}
[data-theme="light"] .telemetry-val,
[data-theme="light"] .crypto-market-table td {
    color: #0f172a;
}
[data-theme="light"] .crypto-market-table th {
    border-bottom-color: #cbd5e1;
}
[data-theme="light"] .crypto-market-table td {
    border-bottom-color: #e2e8f0;
}
[data-theme="light"] .crypto-market-table tr:hover td {
    background: rgba(37, 99, 235, 0.05);
}
[data-theme="light"] .ctrl-input,
[data-theme="light"] .ctrl-select {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}
[data-theme="light"] .ctrl-input::placeholder {
    color: #64748b;
}
[data-theme="light"] .positions-row-btn.btn-secondary {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}
[data-theme="light"] .positions-row-btn.btn-secondary:hover {
    background: #e2e8f0;
    color: #0f172a;
}
[data-theme="light"] .positions-status-bar {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}
[data-theme="light"] .positions-signals-bar {
    border-top-color: #e2e8f0;
}
[data-theme="light"] .signal-check-pill {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}
[data-theme="light"] .signal-check-pill:hover {
    background: #f1f5f9;
    border-color: #2563eb;
}
[data-theme="light"] .coin-fallback-badge {
    background: #e2e8f0;
    color: #1e293b;
}
[data-theme="light"] .empty-setup-cta {
    color: #475569;
}
/* High-contrast badge & signal text adjustments in Light Mode */
[data-theme="light"] .sig-text-strong-up {
    color: #047857 !important;
}
[data-theme="light"] .sig-text-mod-up {
    color: #0369a1 !important;
}
[data-theme="light"] .sig-text-low {
    color: #1d4ed8 !important;
}
[data-theme="light"] .sig-text-neutral {
    color: #475569 !important;
}
[data-theme="light"] .sig-text-mod-down {
    color: #b45309 !important;
}
[data-theme="light"] .sig-text-strong-down {
    color: #b91c1c !important;
}
[data-theme="light"] .sig-badge-strong-up {
    color: #047857 !important;
    background: rgba(16, 185, 129, 0.16) !important;
    border-color: rgba(5, 150, 105, 0.4) !important;
}
[data-theme="light"] .sig-badge-mod-up {
    color: #0369a1 !important;
    background: rgba(14, 165, 233, 0.16) !important;
    border-color: rgba(3, 105, 161, 0.38) !important;
}
[data-theme="light"] .sig-badge-low {
    color: #1d4ed8 !important;
    background: rgba(37, 99, 235, 0.13) !important;
    border-color: rgba(29, 78, 216, 0.35) !important;
}
[data-theme="light"] .sig-badge-neutral {
    color: #475569 !important;
    background: rgba(100, 116, 139, 0.14) !important;
    border-color: rgba(71, 85, 105, 0.35) !important;
}
[data-theme="light"] .sig-badge-mod-down {
    color: #b45309 !important;
    background: rgba(245, 158, 11, 0.18) !important;
    border-color: rgba(180, 83, 9, 0.4) !important;
}
[data-theme="light"] .sig-badge-strong-down {
    color: #b91c1c !important;
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(185, 28, 28, 0.4) !important;
}
[data-theme="light"] .ls-long-val {
    color: #047857 !important;
}
[data-theme="light"] .ls-short-val {
    color: #dc2626 !important;
}
[data-theme="light"] .ls-ratio-sub {
    color: #475569 !important;
}

.sig-lbl-short {
    display: none;
}

/* ===================================================================
   MOBILE STREAMLINED VERSION (@media max-width: 768px)
   Hides T-1, T-2, Top Position L/S, Top Account L/S, Open Interest
   and compacts the top hero, telemetry cards, and filter controls.
   =================================================================== */
@media (max-width: 768px) {
    .crypto-front-wrap {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin: 0.75rem auto 2rem auto;
        padding: 0 0.5rem;
        overflow-x: hidden;
    }
    .crypto-front-hero {
        box-sizing: border-box;
        max-width: 100%;
        padding: 0.85rem 0.9rem;
        gap: 0.65rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
    }
    .crypto-front-title {
        gap: 0.55rem;
        width: 100%;
        min-width: 0;
    }
    .crypto-front-title > span {
        font-size: 1.5rem !important;
        flex-shrink: 0;
    }
    .crypto-front-title > div {
        min-width: 0;
        flex: 1;
    }
    .crypto-front-title h1 {
        font-size: 0.98rem;
        line-height: 1.25;
        overflow-wrap: break-word;
    }
    .crypto-front-title p {
        display: none;
    }
    .crypto-front-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
    }
    .crypto-tab-btn,
    .crypto-admin-btn {
        height: 36px;
        padding: 0 0.5rem;
        font-size: 0.76rem;
        justify-content: center;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .crypto-admin-btn {
        grid-column: 1 / -1;
    }

    /* Compact 2x2 Telemetry Grid on Mobile */
    .positions-telemetry-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
        margin-bottom: 0.7rem;
    }
    .telemetry-card {
        min-width: 0;
        padding: 0.5rem 0.55rem;
        border-radius: 8px;
    }
    .telemetry-card.mobile-hide-card {
        display: none;
    }
    .telemetry-label {
        font-size: 0.62rem;
    }
    .telemetry-val {
        font-size: 0.8rem;
        line-height: 1.25;
        margin-top: 0.2rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: break-word;
    }

    /* Streamlined Top Controls & Signal Filter Bar */
    .positions-controls-card {
        box-sizing: border-box;
        max-width: 100%;
        padding: 0.65rem;
        border-radius: 10px;
        margin-bottom: 0.7rem;
        overflow: hidden;
    }
    .positions-top-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.45rem;
        margin-bottom: 0.55rem;
    }
    .ctrl-field {
        min-width: 0;
    }
    .ctrl-field.grow {
        grid-column: 1 / -1;
    }
    .ctrl-field label {
        font-size: 0.66rem;
    }
    .ctrl-input,
    .ctrl-select,
    .positions-top-bar .positions-row-btn {
        width: 100%;
        min-width: 0;
        height: 36px;
        font-size: 0.76rem;
        padding: 0 0.55rem;
        box-sizing: border-box;
    }
    .positions-status-bar {
        display: none;
    }
    .positions-signals-bar {
        padding-top: 0.5rem;
        gap: 0.5rem;
    }
    .signal-checks-wrap {
        width: 100%;
        gap: 0.3rem;
    }
    .signal-check-pill {
        padding: 0.25rem 0.42rem;
        font-size: 0.68rem;
        border-radius: 6px;
    }
    .signal-quick-btns {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.4rem;
    }
    .signal-quick-btns .positions-row-btn {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 36px;
        padding: 0.3rem 0.4rem;
        font-size: 0.73rem;
        white-space: normal;
        text-align: center;
        line-height: 1.15;
        gap: 0.3rem;
    }

    /* Hide T-1, T-2, Top Position L/S, Top Account L/S, Open Interest on Mobile */
    .col-mobile-hide {
        display: none !important;
    }
    .crypto-table-card {
        box-sizing: border-box;
        max-width: 100%;
        padding: 0.45rem 0.3rem;
        border-radius: 10px;
        overflow: hidden;
    }
    .crypto-market-table th {
        padding: 0.42rem 0.22rem;
        font-size: 0.61rem;
        white-space: normal;
        line-height: 1.15;
    }
    .crypto-market-table td {
        padding: 0.42rem 0.22rem;
        font-size: 0.72rem;
    }
    .watch-star-btn {
        font-size: 0.95rem;
        padding: 0 2px;
    }
    .coin-icon-img,
    .coin-fallback-badge {
        width: 19px;
        height: 19px;
    }
    .asset-cell-links {
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }
    .asset-chart-ico {
        font-size: 10px !important;
    }
    .sig-lbl-full {
        display: none;
    }
    .sig-lbl-short {
        display: inline;
    }
    .exp-sig-badge {
        padding: 2px 5px !important;
        font-size: 0.68rem !important;
    }
    .ls-pair-wrap {
        display: inline-flex;
        flex-direction: column;
        line-height: 1.2;
        font-size: 0.67rem;
    }
    .ls-pair-sep {
        display: none;
    }
    .funding-badge {
        padding: 2px 4px !important;
        font-size: 0.66rem !important;
    }
}
