:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #222635;
    --border: #2a2e3b;
    --text: #e1e4eb;
    --text-muted: #8b8fa3;
    --accent: #4f8cff;
    --accent-hover: #3b7af0;
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.1);
    --orange: #f97316;
    --purple: #a855f7;
    --purple-bg: rgba(168, 85, 247, 0.15);
    --nhl: #4f8cff;
    --hockey: #4f8cff;
    --ahl: #38bdf8;
    --khl: #e11d48;
    --weather: #a855f7;
    --nba: #f97316;
    --mlb: #22c55e;
    --nfl: #ef4444;
    --ncaab: #f59e0b;
    --soccer: #10b981;
    --crypto: #fbbf24;
    --politics: #8b5cf6;
    --olympics: #06b6d4;
    --other: #a8a29e;
    --radius: 8px;
    --radius-sm: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { color: var(--text-muted); font-size: 0.85rem; }
.balance-group {
    display: flex;
    gap: 16px;
    align-items: center;
}
.balance-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}
.balance-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.balance { font-weight: 700; font-size: 1rem; color: var(--text); }
.balance-portfolio { color: var(--green); }
.topbar-divider {
    color: var(--border);
    font-size: 1.2rem;
    font-weight: 300;
}
.daily-spend-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.daily-spend-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.daily-spend { 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    padding: 4px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 600;
}
.daily-spend.warning { 
    color: var(--yellow); 
    border-color: var(--yellow);
    background: var(--yellow-bg);
}
.daily-spend.danger { 
    color: var(--red); 
    border-color: var(--red);
    background: var(--red-bg);
}

/* ── Status Badges ── */
.status-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}
.status-connected { background: var(--green-bg); color: var(--green); }
.status-disconnected { background: var(--red-bg); color: var(--red); }

/* ── Early-exit indicator ── */
.exit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--yellow);
    cursor: default;
    margin-left: 4px;
    padding: 1px 5px;
    border: 1px solid rgba(234, 179, 8, 0.45);
    border-radius: 999px;
    vertical-align: middle;
}

/* ── Injury/suspension adjustment indicator ── */
.inj-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--yellow);
    cursor: default;
    margin-left: 4px;
    opacity: 0.85;
    /* Larger tap target on touch devices */
    min-width: 28px;
    min-height: 28px;
    vertical-align: middle;
}
.inj-note {
    color: var(--yellow);
    opacity: 0.85;
    white-space: normal;
    cursor: default;
}

.market-title-main {
    display: flex;
    align-items: center;
    gap: 6px;
}
.market-title-primary {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.market-injury-note {
    display: block;
    font-size: 0.72rem;
    line-height: 1.25;
    margin-top: 2px;
}
.market-detail-note {
    display: block;
    font-size: 0.72rem;
    line-height: 1.3;
    margin-top: 3px;
    color: var(--text-muted);
}
.rec-scout-line {
    color: var(--text-muted);
}
.b2b-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
    letter-spacing: 0.03em;
    vertical-align: middle;
}
.era-val { font-weight: 600; }
.era-good { color: var(--green); }
.era-bad { color: var(--red); }
.elo-line { opacity: 0.75; }
.bullpen-line { opacity: 0.8; }
.groq-note { color: #a78bfa; }
.rec-line-move-up { color: var(--green); font-weight: 600; }
.rec-line-move-down { color: var(--red); font-weight: 600; }
.rec-time-until { color: var(--text-muted); font-style: italic; }
.trade-score-note {
    font-weight: 600;
}
.trade-score-live {
    color: var(--yellow);
}
.trade-score-final {
    color: var(--text-muted);
}

.crypto-live-price {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: #bfdbfe;
    font-weight: 600;
}

/* ── Container ── */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── Summary Cards ── */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.card-value { font-size: 1.5rem; font-weight: 700; }
.card-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }
.card-value-sm { font-size: 0.9rem; font-weight: 400; word-break: break-all; }
.card-pnl.positive .card-value { color: var(--green); }
.card-pnl.negative .card-value { color: var(--red); }

/* ── Action Row (Scan + Sync) ── */
.action-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin: 0 auto 20px;
    padding: 22px 32px 18px;
    max-width: fit-content;
    /* gradient border trick: padding-box clips bg, border-box shows gradient */
    background:
        linear-gradient(#1c2035, #161929) padding-box,
        linear-gradient(135deg, #4f8cff 0%, #0d9488 100%) border-box;
    border: 1px solid transparent;
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(79, 140, 255, 0.12),
        0 4px 32px rgba(0, 0, 0, 0.5),
        0 0 48px rgba(79, 140, 255, 0.07);
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 12px;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.action-btn-wrap .btn {
    width: 100%;
    flex: 1;
    justify-content: center;
    align-items: center;
    padding: 11px 18px;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
}

.action-btn-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: center;
    opacity: 0.7;
    letter-spacing: 0.01em;
}

.action-divider-h {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(79,140,255,0.25) 30%, rgba(13,148,136,0.25) 70%, transparent);
    margin: 16px 0 12px;
}

.action-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    padding: 8px 16px;
}

.action-meta-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.action-meta-icon {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 14px;
    text-align: center;
}

.action-meta-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
    min-width: 68px;
    text-align: right;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.action-meta-value {
    font-size: 0.75rem;
    color: var(--text);
}

.action-meta-muted {
    color: var(--text-muted);
}

.action-meta-detail {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Button icons */
.btn-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary button - main actions */
.btn-primary { 
    background: var(--accent); 
    color: #fff; 
}
.btn-primary:focus-visible:not(:disabled) { 
    background: var(--accent-hover); 
}

/* Secondary button - less important actions */
.btn-secondary { 
    background: var(--bg-hover); 
    color: var(--text); 
    border: 1px solid var(--border);
}
.btn-secondary:focus-visible:not(:disabled) {
    border-color: var(--text-muted);
}

/* Sync button — teal */
.btn.btn-sync {
    background: #0d9488;
    color: #fff;
    border: none;
}
.btn.btn-sync:focus-visible:not(:disabled) {
    background: #0f766e;
}
.btn.btn-sync:disabled {
    background: #0d9488;
    opacity: 0.5;
}

/* Refresh button — slate */
.btn.btn-refresh {
    background: #334155;
    color: #e2e8f0;
    border: none;
}
.btn.btn-refresh:hover:not(:disabled) {
    background: #475569;
}
.btn.btn-refresh:focus-visible:not(:disabled) {
    background: #475569;
}

/* Outline button - tertiary actions */
.btn-outline { 
    background: transparent; 
    border: 1px solid var(--border); 
    color: var(--text-muted); 
}
.btn-outline:focus-visible:not(:disabled) { 
    border-color: var(--text); 
    color: var(--text); 
}

/* Success button - positive actions */
.btn-success { 
    background: var(--green); 
    color: #fff; 
}
.btn-success:focus-visible:not(:disabled) { 
    background: #1ea34e; 
}

/* Danger button - destructive actions */
.btn-danger { 
    background: var(--red); 
    color: #fff; 
}
.btn-danger:focus-visible:not(:disabled) { 
    background: #dc2626; 
}

/* BUY button - table action */
.btn-buy {
    background: var(--accent);
    color: #fff;
    padding: 6px 14px;
    font-size: 0.8rem;
    transition: transform 0.08s ease, background 0.15s ease;
}
.btn-buy:active, .btn-caution:active {
    transform: scale(0.93);
}
.btn-loading {
    background: #444 !important;
    color: rgba(255,255,255,0.7) !important;
    cursor: not-allowed;
    pointer-events: none;
    min-width: 80px;
}
.btn-loading::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
.qty-input {
    width: 100%;
    max-width: 48px;
    min-width: 34px;
    padding: 2px 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.85rem;
    text-align: center;
}
.qty-input:focus {
    outline: none;
    border-color: var(--accent);
}
.btn-buy:focus-visible:not(:disabled) {
    background: var(--accent-hover);
}
.btn-caution {
    background: #b8860b;
    color: #fff;
}
.btn-caution:focus-visible:not(:disabled) {
    background: #d4a017;
}

/* Small button */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Extra-small button */
.btn-xs {
    padding: 3px 10px;
    font-size: 0.75rem;
}

/* Expand/collapse all bar */
.section-controls-bar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.rec-action-cell {
    min-width: 98px;
}

.rec-action-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.rec-action-stack .btn {
    width: 100%;
    justify-content: center;
}

.rec-skip-btn {
    margin-left: 0;
}

/* Full width button */
.btn-full { 
    width: 100%; 
    justify-content: center; 
}

/* ── Actions + Sync combined bar ── */
.actions-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
}
.actions-spacer { flex: 1; min-width: 8px; }
.last-scan-info { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }

.sync-status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.sync-status-text {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text);
}

.sync-detail { color: var(--text-muted); }
.sync-error { color: var(--red); }

.sync-status-bar.sync-ok { border-color: rgba(34, 197, 94, 0.45); }
.sync-status-bar.sync-pending { border-color: rgba(234, 179, 8, 0.45); }
.sync-status-bar.sync-error { border-color: rgba(239, 68, 68, 0.55); }
.sync-status-bar.sync-offline { border-color: rgba(107, 114, 128, 0.45); }

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.table-wrapper::-webkit-scrollbar { display: none; }
/* Briefing table */
.briefing-section .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.briefing-table th, .briefing-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.briefing-table th { line-height: 1.25; overflow: visible; text-align: left; padding: 7px 12px; }
.briefing-table td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; min-width: 140px; max-width: 220px; } /* Description */
.briefing-table th:nth-child(15), .briefing-table td:nth-child(15) { position: sticky; right: 0; background: var(--bg-card); box-shadow: -4px 0 8px rgba(0,0,0,0.2); z-index: 1; }  /* Action */
.briefing-table thead th:nth-child(15) { background: var(--bg); }
.briefing-table td:nth-child(2) {
    overflow: hidden;
    white-space: nowrap;
}
.briefing-table td:nth-child(2) .category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}
.briefing-table .market-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
}
.briefing-table .opp-analysis {
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: top;
    min-width: 160px;
    max-width: 260px;
    padding-top: 2px;
}
.briefing-table .opp-analysis .market-detail-note,
.briefing-table .opp-analysis .inj-note {
    margin-top: 5px;
    line-height: 1.35;
}
.briefing-table .opp-analysis .market-detail-note:first-child,
.briefing-table .opp-analysis .inj-note:first-child {
    margin-top: 0;
}
.briefing-table .market-title-main {
    align-items: flex-start;
    gap: 6px;
}
.briefing-table .market-title-primary {
    display: block;
    white-space: normal;
    line-height: 1.35;
    font-size: 0.9rem;
    overflow: visible;
    text-overflow: clip;
}
.crypto-price-link {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}
.crypto-price-link:hover,
.crypto-price-link:focus-visible {
    color: var(--accent-hover);
    text-decoration: underline;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
th {
    text-align: left;
    padding: 7px 8px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 7px 8px;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }

.market-title {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.edge-cell { color: var(--green); font-weight: 600; }
.profit-cell { font-weight: 600; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.loading-value {
    color: var(--text-muted);
    font-style: italic;
    animation: loading-pulse 1.4s ease-in-out infinite;
}
@keyframes loading-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Category Badges ── */
.category-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.cat-nhl { background: rgba(79, 140, 255, 0.15); color: var(--nhl); }
.cat-hockey { background: rgba(79, 140, 255, 0.15); color: var(--hockey); }
.cat-ahl { background: rgba(56, 189, 248, 0.15); color: var(--ahl); }
.cat-khl { background: rgba(225, 29, 72, 0.15); color: var(--khl); }
.cat-weather { background: rgba(168, 85, 247, 0.15); color: var(--weather); }
.cat-nba { background: rgba(249, 115, 22, 0.15); color: var(--nba); }
.cat-mlb { background: rgba(34, 197, 94, 0.15); color: var(--mlb); }
.cat-nfl { background: rgba(239, 68, 68, 0.15); color: var(--nfl); }
.cat-ncaab { background: rgba(245, 158, 11, 0.15); color: var(--ncaab); }
.cat-soccer { background: rgba(16, 185, 129, 0.15); color: var(--soccer); }
.cat-crypto { background: rgba(251, 191, 36, 0.15); color: var(--crypto); }
.cat-politics { background: rgba(139, 92, 246, 0.15); color: var(--politics); }
.cat-olympics { background: rgba(6, 182, 212, 0.15); color: var(--olympics); }
.cat-other { background: rgba(168, 162, 158, 0.15); color: var(--other); }

/* ── Confidence Tier Badges ── */
.tier-badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
}
.tier-badge.tier-high { background: var(--green-bg); color: var(--green); }
.tier-badge.tier-medium { background: var(--yellow-bg); color: var(--yellow); }
.tier-badge.tier-high-roi { background: var(--purple-bg); color: var(--purple); font-size: 0.7em; margin-right: 4px; }
.tier-badge.tier-caution { background: var(--red-bg); color: var(--orange); }
.tier-badge.tier-skip {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Row tinting by tier */
tr.tier-high td { border-left: 3px solid var(--green); }
tr.tier-medium td { border-left: 3px solid var(--yellow); }
tr.tier-caution td { border-left: 3px solid var(--orange); }
tr.manual-trade-row td:first-child { border-left: 3px solid rgba(148, 163, 184, 0.45); }
tr.manual-trade-row td { background: rgba(148, 163, 184, 0.06); }

/* In-progress game warning */
tr.game-in-progress td { opacity: 0.6; }
tr.game-in-progress td:first-child { border-left: 3px solid var(--orange) !important; }
.in-progress-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse-orange 1.5s ease-in-out infinite;
}
@keyframes pulse-orange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.event-date-sub {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 2px;
}

/* Status */
.status-filled { color: var(--green); }
.status-won { color: var(--green); }
.status-lost { color: var(--red); }
.status-pending { color: var(--yellow); }
.status-resting { color: var(--yellow); }
.status-cancelled { color: var(--text-muted); }
.status-pushed { color: var(--text-muted); }
.status-failed { color: var(--red); }
.status-exited { color: var(--orange); }
.has-tooltip { cursor: default; text-decoration: underline dotted; }

/* ── Section Headers ── */
section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.count-badge {
    font-size: 0.75rem;
    background: var(--accent);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.briefing-section, .trades-section, .pnl-section { margin-bottom: 32px; }

.timeline-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.section-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
/* Stats sections (Model/Manual Trades) — toolbar spans full width above cards grid */
.stats-toolbar {
    grid-column: 1 / -1;
    margin-top: 16px;
    margin-bottom: 0;
}
.filter-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.section-header-row h2 { margin-bottom: 0; }

.filter-input {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--sans);
    min-width: 180px;
    transition: border-color 0.15s;
}
.filter-input:focus {
    outline: none;
    border-color: var(--accent);
}

.period-filter-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.global-period-filter {
    grid-column: unset;
    margin-bottom: 20px;
}
.period-filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
}
.period-filter-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.filter-select {
    padding: 5px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--sans);
    cursor: pointer;
    transition: border-color 0.15s;
}
.filter-select:focus { outline: none; border-color: var(--accent); }
/* Wider period select with centered text for the "All" state */
.period-select {
    min-width: 140px;
    text-align: center;
}
.period-select option { text-align: left; }


.trade-action-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ── Empty State ── */
.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    color: var(--text-muted);
}

/* ── Login ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}
.login-header { text-align: center; margin-bottom: 24px; }
.login-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }
.login-header .tagline { margin-top: 4px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}
.form-group input:focus { border-color: var(--accent); }

.alert { padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.9rem; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-warning {
    background: rgba(245, 166, 35, 0.12);
    color: #f3c46b;
    border: 1px solid rgba(245, 166, 35, 0.35);
}
.scan-health-alert {
    margin-top: -6px;
}
.scan-health-title {
    font-weight: 700;
    margin-bottom: 6px;
}
.scan-health-item {
    font-size: 0.84rem;
    line-height: 1.45;
}
.scan-health-item + .scan-health-item {
    margin-top: 4px;
}

/* ── CAUTION Confirm Panel ── */
.caution-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    width: 340px;
    max-width: calc(100vw - 40px);
    background: var(--bg-card);
    border: 1px solid #b8860b;
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease;
}
.caution-panel-header {
    font-weight: 700;
    font-size: 1rem;
    color: #f5a623;
    margin-bottom: 6px;
}
.caution-panel-market {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.caution-panel-reason {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 16px;
}
.caution-panel-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.caution-confirm-btn {
    background: #f5a623;
    color: #000;
    border: none;
    font-weight: 600;
}
.caution-confirm-btn:focus-visible:not(:disabled) {
    background: #d4a017;
}

/* ── Custom tooltips (tap only) ── */
.tt {
    position: absolute;
    z-index: 9999;
    background: #1e2330;
    color: #e2e8f0;
    border: 1px solid #3a4256;
    border-radius: 5px;
    padding: 5px 9px;
    font-size: 0.78rem;
    line-height: 1.4;
    max-width: 260px;
    pointer-events: none;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.12s ease;
}
.tt.tt-visible { opacity: 1; }

/* ── Toast Notifications ── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}
.toast-success { background: var(--green); color: #fff; }
.toast-error { background: var(--red); color: #fff; }
.toast-info { background: var(--accent); color: #fff; }
.toast-warning { background: #b8860b; color: #fff; }

/* ── Action Confirmation Modal ── */
.action-confirm-backdrop[hidden] {
    display: none !important;
}
.action-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 84px 20px 20px;
    background: transparent;
    pointer-events: none;
}
.action-confirm-modal {
    position: relative;
    width: min(420px, calc(100vw - 32px));
    background: linear-gradient(180deg, rgba(31, 37, 54, 0.98), rgba(20, 24, 36, 0.98));
    border: 1px solid rgba(79, 140, 255, 0.35);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    padding: 22px 22px 18px;
    animation: modalPopIn 0.22s ease;
    pointer-events: auto;
}
.action-confirm-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.14);
    color: #86efac;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.action-confirm-badge[hidden] {
    display: none !important;
}
.action-confirm-title {
    font-size: 1.12rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 10px;
    padding-right: 28px;
    line-height: 1.3;
}
.action-confirm-message {
    font-size: 0.95rem;
    color: #cbd5e1;
    line-height: 1.55;
    min-height: 1.5em;
}
.action-confirm-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}
.action-confirm-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,0.02);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
}
.action-confirm-close:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes modalPopIn {
    from { transform: translateY(10px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ── Liquidity Page ── */
.liq-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.liq-desc { font-size: 0.87rem; color: var(--text-muted); margin: 0; max-width: 600px; }
.liq-actions { display: flex; gap: 8px; flex-shrink: 0; }
.liq-params { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; font-size: 0.87rem; flex-wrap: wrap; }
.liq-param { color: var(--text); }
.liq-section { margin-bottom: 32px; }
.liq-section h3 { font-size: 1rem; font-weight: 600; margin: 0 0 12px; }
.liq-ui-note { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 14px; max-width: 560px; line-height: 1.4; }
.liq-card-note { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; opacity: 0.9; }
.kalshi-source-of-truth { margin-bottom: 14px; padding: 12px 14px; background: rgba(34, 197, 94, 0.08); border: 1px solid rgba(34, 197, 94, 0.35); border-radius: var(--radius); }
.kalshi-source-of-truth-standalone { margin-bottom: 20px; padding: 12px 14px; background: rgba(34, 197, 94, 0.08); border: 1px solid rgba(34, 197, 94, 0.35); border-radius: var(--radius); }
.kalshi-source-of-truth-standalone .kalshi-stat { display: inline-block; margin-right: 16px; font-size: 0.9rem; }
.liq-estimate-tag { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); }

/* Filter bar */
.liq-filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.liq-search { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; color: var(--text); font-size: 0.87rem; width: 240px; outline: none; }
.liq-search:focus { border-color: var(--blue); }
.liq-filter-pills { display: flex; gap: 4px; }
.pill { background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 4px 12px; font-size: 0.78rem; color: var(--text-muted); cursor: pointer; transition: all 0.15s; }
.pill:focus-visible { border-color: var(--text-muted); }
.pill-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.liq-toggle { font-size: 0.82rem; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 4px; }

/* Sortable column headers */
.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable:focus-visible { color: var(--text); }
.sort-arrow { font-size: 0.65rem; }

/* Category badges */
.cat-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; }
.cat-weather { background: rgba(96,165,250,0.15); color: #60a5fa; }
.cat-other { background: rgba(168,162,158,0.15); color: #a8a29e; }
.badge { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; font-size: 0.78rem; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.side-badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 0.78rem; font-weight: 600; }
.side-yes { background: rgba(78,205,150,0.15); color: var(--green); }
.side-no { background: rgba(220,80,80,0.15); color: var(--red); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:focus-visible { background: rgba(220,80,80,0.1); }
.empty-state { color: var(--text-muted); font-size: 0.9rem; padding: 20px 0; }

/* ── Settings Page ── */
.settings-form { max-width: 800px; }
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}
.settings-section h2 { margin-bottom: 8px; }
.section-desc { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}
.form-group select:focus { border-color: var(--accent); }
.form-hint { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 8px 0; }
.toggle-label input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}
.toggle-text { font-size: 0.9rem; }
.settings-actions { display: flex; gap: 12px; }
.alert-success { background: var(--green-bg); color: var(--green); padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.9rem; }

/* ── Category Success Rate Card ── */
.card-category-rates {
    grid-column: 1 / -1;
}
.category-rate-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}
.category-rate-row {
    display: grid;
    grid-template-columns: 72px 1fr 52px 72px 72px;
    align-items: center;
    gap: 10px;
}
.category-rate-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.category-rate-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.cat-bar-hockey  { background: var(--hockey); }
.cat-bar-nhl    { background: var(--nhl); }
.cat-bar-ahl    { background: var(--ahl); }
.cat-bar-khl    { background: var(--khl); }
.cat-bar-weather { background: var(--weather); }
.cat-bar-nba     { background: var(--nba); }
.cat-bar-mlb     { background: var(--mlb); }
.cat-bar-nfl     { background: var(--nfl); }
.cat-bar-ncaab   { background: var(--ncaab); }
.cat-bar-soccer  { background: var(--soccer); }
.cat-bar-crypto  { background: var(--crypto); }
.cat-bar-politics { background: var(--politics); }
.cat-bar-olympics { background: var(--olympics); }
.cat-bar-other   { background: var(--other); }
.category-rate-pct {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
    color: var(--text);
}
.category-rate-wl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}
.category-rate-pnl {
    font-size: 0.82rem;
    font-weight: 600;
    text-align: right;
}
.category-rate-pnl.pnl-pos { color: var(--green); }
.category-rate-pnl.pnl-neg { color: var(--red); }

/* ── Category sort header ── */
.category-sort-header {
    display: grid;
    grid-template-columns: 72px 1fr 52px 72px 72px;
    gap: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-top: 8px;
    margin-bottom: 2px;
}
.category-sort-btn {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    user-select: none;
    transition: color 0.15s;
}
.category-sort-btn--left { justify-content: flex-start; text-align: left; }
.category-sort-btn:focus-visible { color: var(--text); }
.category-sort-btn.sort-active { color: var(--text); }
.category-sort-btn .sort-arrow { font-size: 0.6rem; opacity: 0.7; }

.date-cell { white-space: nowrap; font-size: 0.85rem; color: var(--text-muted); vertical-align: middle; }
.event-time { font-size: 0.78rem; opacity: 0.75; }

/* ── Full Analysis ── */
.analysis-section { margin-top: 32px; }
.collapsible-header {
    cursor: pointer; user-select: none;
    display: flex; align-items: center; gap: 12px;
}
.collapsible-header:focus-visible { color: var(--accent); }
.toggle-icon { font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; }
.analysis-note { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.backtest-section { margin-top: 32px; }
.backtest-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 12px 0; }
.backtest-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.backtest-card h3 { font-size: 0.95rem; margin-bottom: 8px; color: var(--text-muted); }
.backtest-placeholder { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }
.mini-table { width: 100%; font-size: 0.85rem; margin-top: 8px; border-collapse: collapse; }
.mini-table th, .mini-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.mini-table th { color: var(--text-muted); font-weight: 500; }
.analysis-table { border-collapse: collapse; }
.analysis-table th { border-bottom: 2px solid var(--border); font-weight: 600; white-space: nowrap; overflow: visible; }
.analysis-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.analysis-table td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; min-width: 180px; max-width: 280px; } /* Description */
.analysis-table .notes-cell { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; font-size: 0.75rem; color: var(--text-muted); min-width: 160px; max-width: 240px; }
.analysis-table td:nth-child(9) { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; font-size: 0.75rem; color: #a78bfa; min-width: 120px; max-width: 200px; }
.analysis-table th:nth-child(10), .analysis-table td:nth-child(10) { position: sticky; right: 0; z-index: 2; background: var(--bg-card); box-shadow: -10px 0 14px -14px rgba(0,0,0,0.85); }
.analysis-table th:nth-child(10) { z-index: 3; }
.analysis-table .market-title {
    white-space: normal;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.analysis-table .market-title-primary {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.analysis-trade-cell {
    white-space: normal;
}
.analysis-trade-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.analysis-trade-meta {
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--text-muted);
}
.analysis-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.08);
}
.analysis-action-filtered {
    background: rgba(148, 163, 184, 0.12);
}
.analysis-action-too-small {
    color: #d97706;
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
}
/* ── Fixed-layout tables: column widths defined by <colgroup>, never by content ── */
.briefing-table,
.analysis-table,
#historyTable,
#openTradesTable {
    table-layout: fixed;
}
.trades-table {
    table-layout: fixed;
}
#tradesTable th,
#tradesTable td,
#historyTable th,
#historyTable td,
#openTradesTable th,
#openTradesTable td {
    vertical-align: top;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#tradesTable th,
#historyTable th,
#openTradesTable th {
    line-height: 1.2;
    overflow: visible; /* keep sort arrows visible */
}
/* Description and pick: wrap instead of clip */
#tradesTable td:nth-child(4),
#historyTable td:nth-child(4),
#openTradesTable td:nth-child(4),
#historyTable td:nth-child(5),
#openTradesTable td:nth-child(5),
.briefing-table td:nth-child(3),
.briefing-table td:nth-child(4),
.analysis-table td:nth-child(3) {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-overflow: clip;
}
#tradesTable .date-cell,
#historyTable .date-cell,
#openTradesTable .date-cell,
#tradesTable .event-time,
#historyTable .event-time,
#openTradesTable .event-time {
    font-size: 0.84rem;
    line-height: 1.35;
}
#tradesTable .event-time,
#historyTable .event-time,
#openTradesTable .event-time {
    opacity: 1;
}
/* Tighten padding on Opened/Event columns to minimize gap between them */
#tradesTable td:nth-child(1), #tradesTable td:nth-child(2),
#historyTable td:nth-child(1), #historyTable td:nth-child(2),
#openTradesTable td:nth-child(1), #openTradesTable td:nth-child(2) {
    padding-right: 4px;
}
#tradesTable .category-badge,
#historyTable .category-badge {
    font-size: 0.7rem;
    padding: 3px 7px;
}
.market-badge-cell {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 3px;
}
#tradesTable .market-title-primary,
#historyTable .market-title,
#openTradesTable .market-title-primary {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
}
#tradesTable .market-detail-note,
#historyTable .market-detail-note {
    font-size: 0.72rem;
}
#tradesTable tfoot .totals-row td,
#historyTable tfoot .totals-row td {
    font-size: 0.84rem;
}

/* ── Scan loading overlay ── */
@keyframes scanLabelPulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px var(--accent), 0 0 20px var(--accent); }
    50%       { opacity: 0.55; text-shadow: 0 0 2px var(--accent); }
}
.top-progress-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    z-index: 2000;
    background: var(--bg-card);
    overflow: visible;
}
.top-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.4s ease;
    box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
}
.top-progress-label {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    pointer-events: none;
    white-space: nowrap;
    animation: scanLabelPulse 1.6s ease-in-out infinite;
}
.notes-cell { font-size: 0.8rem; color: var(--text-muted); }
.verdict-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.verdict-badge.verdict-trade { background: var(--green-bg); color: var(--green); }
.verdict-badge.verdict-slight-edge { background: rgba(251, 191, 36, 0.15); color: #d97706; }
.verdict-badge.verdict-fair-price { background: var(--card-bg); color: var(--text-muted); border: 1px solid var(--border); }
.verdict-badge.verdict-no-edge { background: var(--red-bg, rgba(220,80,80,0.1)); color: var(--red, #dc2626); }
tr.verdict-trade { background: rgba(16, 185, 129, 0.04); }
tr.verdict-no-edge { opacity: 0.6; }

/* ── Table totals footer ── */
tfoot .totals-row { border-top: 2px solid var(--border); }
tfoot .totals-row td { padding: 8px 8px; font-weight: 600; font-size: 0.84rem; }
tfoot .totals-label { color: var(--text-muted); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
tfoot .totals-metrics-row td { padding: 6px 8px; border-top: 1px dashed var(--border); background: var(--bg); }
.totals-metrics-inline-cell { display: table-cell; }
.totals-metric-item-inline { display: inline-flex; align-items: baseline; gap: 5px; margin-right: 24px; }
.totals-metric-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.totals-metric-value { font-size: 0.85rem; font-weight: 700; }
.totals-metric-sub { font-size: 0.68rem; color: var(--text-muted); font-weight: 400; }
.metric-yellow { color: #d97706; }

/* ── Sortable tables ── */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:focus-visible { color: var(--accent); }
th.sortable::after { content: ' ↕'; font-size: 0.7em; color: var(--text-muted); }
th.sortable.sort-asc::after { content: ' ↑'; color: var(--accent); }
th.sortable.sort-desc::after { content: ' ↓'; color: var(--accent); }

/* ── Manual Trades Section ── */
.section-type-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-right: 4px;
}
.manual-cards {
    margin-bottom: 24px;
}
.manual-cards-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.manual-cards-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.manual-cards-sublabel {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}
.manual-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.manual-cards-grid .card {
    border-color: var(--border);
    opacity: 0.85;
}
.manual-category-card {
    opacity: 0.85;
}

/* ── Collapsible Sections ── */
.collapsible-section {
    margin-bottom: 24px;
    overflow: visible;
}
.collapsible-section > summary {
    list-style: none;
}
.collapsible-section > summary::-webkit-details-marker {
    display: none;
}
.collapsible-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    user-select: none;
}
.collapsible-summary:focus-visible .collapsible-title {
    color: var(--accent);
}
.collapsible-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.collapsible-title::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    display: inline-block;
}
details[open] .collapsible-title::before {
    transform: rotate(90deg);
}
.collapsible-section .trades-section,
.collapsible-section .pnl-section {
    margin-top: 16px;
    margin-bottom: 0;
}

.collapsible-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

.collapsible-section .summary-cards,
.collapsible-section .manual-cards,
.collapsible-section .briefing-section {
    margin-top: 16px;
    margin-bottom: 0;
}

.cal-note {
    font-size: 11px;
    color: var(--text-muted);
    margin: 8px 0 0 0;
    font-style: italic;
}

/* ── Open Trade Losing-Position Highlight ── */
.trade-row-losing {
    background-color: rgba(239, 68, 68, 0.08) !important;
}
.trade-row-losing:hover {
    background-color: rgba(239, 68, 68, 0.14) !important;
}

/* ── Cash Out Button ── */
.cashout-cell {
    min-width: 90px;
}
.btn-cashout {
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(234, 179, 8, 0.5);
    color: var(--yellow);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-cashout:hover:not(:disabled) {
    background: var(--yellow-bg);
}
.btn-cashout:disabled {
    opacity: 0.5;
    cursor: default;
}
.cashout-confirm {
    font-size: 0.68rem;
}
.cashout-info {
    display: block;
    color: var(--text-muted);
    margin-bottom: 4px;
    line-height: 1.3;
}
.cashout-confirm-btns {
    display: flex;
    gap: 4px;
}
.btn-cashout-confirm {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--green);
    background: var(--green);
    color: #000;
    cursor: pointer;
}
.cashout-now-value { color: var(--text-muted); }
.cashout-now-value.loaded { color: var(--green); font-weight: 600; }
.btn-cashout-confirm:disabled {
    opacity: 0.6;
    cursor: default;
}
.btn-cashout-cancel {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.btn-cashout-cancel:hover {
    background: rgba(148, 163, 184, 0.1);
}

/* ── Manual Trade Row Indicator ── */
.manual-trade-row {}
.manual-trade-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 5px;
    vertical-align: middle;
    letter-spacing: 0.04em;
}

/* ── Trade View Toggle ── */
.trade-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}
.trade-view-btn {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 3px 10px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.trade-view-btn:focus-visible {
    background: var(--border);
    color: var(--text);
}
.trade-view-btn.active {
    background: var(--accent);
    color: #000;
}


/* ── Performance section ── */
.performance-section {
    display: flex;
    flex-direction: column;
    gap: 28px;
    margin-top: 16px;
}

.perf-block {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cancel collapsible-section overrides — perf-block gap handles spacing uniformly */
.perf-block .summary-cards,
.perf-block .manual-cards-grid {
    margin-top: 0;
    margin-bottom: 0;
}

/* Let gap control all spacing inside performance blocks — cancel stray margins */
.performance-section > .section-toolbar,
.perf-block .section-toolbar {
    margin-bottom: 0;
}

.perf-block-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.perf-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.perf-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 8px 18px;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.perf-tab:hover { color: var(--text-primary); }
.perf-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Outer Performance tabs (Stats | Charts | Timeline) ── */
.perf-outer-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.perf-outer-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 22px;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.perf-outer-tab:hover { color: var(--text-primary); }
.perf-outer-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 700; }
.perf-outer-panel { display: block; }
.trades-outer-tab, .models-outer-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 22px;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.trades-outer-tab:hover, .models-outer-tab:hover { color: var(--text-primary); }
.trades-outer-tab.active, .models-outer-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 700; }

/* ── P&L Chart ── */
.perf-chart-block {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
}
.perf-chart-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    align-items: center;
    margin-bottom: 14px;
}
.chart-ctrl-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.chart-ctrl-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 2px;
}
.chart-btn, .chart-period-btn, .chart-metric-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 11px;
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.chart-btn:hover, .chart-period-btn:hover, .chart-metric-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
.chart-btn.active, .chart-period-btn.active, .chart-metric-btn.active {
    color: var(--text-primary);
    border-color: var(--accent);
    background: rgba(79,156,249,0.1);
    font-weight: 600;
}
.chart-btn-model.active  { border-color: #4f9cf9; background: rgba(79,156,249,0.1); color: #4f9cf9; }
.chart-btn-manual.active { border-color: #f6a54a; background: rgba(246,165,74,0.1); color: #f6a54a; }
.perf-chart-wrap {
    width: 100%;
    min-height: 280px;
    line-height: 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {

    /* Topbar: two rows on mobile */
    .topbar { 
        padding: 8px 12px; 
        gap: 8px; 
        flex-direction: column;
        align-items: stretch;
    }
    .topbar-left {
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    .topbar-right {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
        justify-content: center;
        width: 100%;
    }
    .tagline { display: none; }
    .status-badge {
        font-size: 0.65rem;
        padding: 3px 7px;
        white-space: nowrap;
    }
    .topbar-divider { display: none; }
    .balance-group {
        gap: 12px;
        order: 1;
    }
    .balance-label { font-size: 0.65rem; }
    .balance { font-size: 0.9rem; white-space: nowrap; }
    .balance-item { align-items: center; }
    .daily-spend-wrapper { align-items: center; }
    .logo { font-size: 1rem; }
    /* Hide Liquidity nav link on mobile — accessible from Settings page */
    .topbar-right a[href="/liquidity"] { display: none; }

    /* Daily spend: sits inline with balance group, centered */
    .daily-spend-wrapper {
        gap: 6px;
        order: 2;
    }
    /* Settings and Logout buttons: second row, full width to prevent overlap */
    .topbar-right .btn {
        order: 3;
        width: 100%;
    }
    .daily-spend-label {
        font-size: 0.7rem;
    }
    .daily-spend {
        font-size: 0.75rem;
        padding: 3px 8px;
        white-space: nowrap;
    }

    /* Container */
    .container { padding: 12px; }

    /* Cards: 2-col grid, more compact */
    .summary-cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .manual-cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card { padding: 14px; }
    .card-value { font-size: 1.2rem; }
    .card-label { font-size: 0.72rem; }

    /* Category rate row: compact but keep all columns */
    .category-rate-row { grid-template-columns: 58px 1fr 42px 58px 58px; }
    .category-sort-header { grid-template-columns: 58px 1fr 42px 58px 58px; }

    /* Period filter: wrap selects */
    .period-filter-form { flex-wrap: wrap; gap: 6px; }
    .filter-select { flex: 1; min-width: 90px; font-size: 0.85rem; }
    .global-period-filter { margin-bottom: 12px; }

    /* Action row - mobile */
    .action-row {
        padding: 14px 12px 12px;
        max-width: 100%;
        width: 100%;
    }
    .action-buttons {
        gap: 8px;
        width: 100%;
        flex-direction: column;
        align-items: center;
    }
    .action-btn-wrap {
        width: fit-content;
        min-width: 220px;
        max-width: 320px;
    }
    .action-btn-sub {
        white-space: normal;
        word-break: break-word;
    }
    .action-meta-label {
        min-width: unset;
    }
    .action-meta-item {
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    /* Legacy actions bar fallback */
    .actions-bar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
    .actions-spacer { display: none; }
    .last-scan-info { font-size: 0.74rem; width: 100%; order: 10; }
    .sync-status-text { font-size: 0.76rem; width: 100%; }
    #scanBtn { flex: 1; justify-content: center; }

    /* Collapsible summary: filter goes full-width on its own line */
    .collapsible-summary { flex-wrap: wrap; gap: 6px; }
    .collapsible-summary .filter-input { order: 10; width: 100%; min-width: unset; margin-top: 2px; }

    /* Touch targets */
    .btn { touch-action: manipulation; min-height: 40px; }
    .btn-buy { padding: 8px 14px; font-size: 0.85rem; min-height: 40px; }
    .btn-sm { padding: 7px 12px; min-height: 36px; }
    .rec-action-cell { min-width: 112px; }
    .rec-action-stack { gap: 8px; }

    /* Toast: full-width */
    .toast-container { left: 12px; right: 12px; top: 12px; }
    .toast { max-width: 100%; }
    .action-confirm-backdrop { padding: 72px 14px 14px; }
    .action-confirm-modal { width: min(100%, 420px); padding: 20px 16px 16px; }
    .action-confirm-actions .btn { width: 100%; }

    /* Tables: compact cells */
    td, th { padding: 6px 7px; }

    /* Tables: auto layout on mobile so columns size to content instead of
       fighting fixed widths — prevents header text from bleeding into
       adjacent columns and gives natural spacing between cells */
    #briefingTable, #analysisDataTable, #tradesTable,
    #openTradesTable, #historyTable {
        table-layout: auto;
    }

    /* All tables: full columns, horizontal scroll, no scrollbar */
    .table-wrapper {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .table-wrapper::-webkit-scrollbar { display: none; }

    /* ── All tables: horizontal scroll, columns auto-sized by content ── */
    /* Description columns: wrap text, let all other columns size naturally */
    .briefing-table td:nth-child(3),
    .briefing-table td:nth-child(4),
    .analysis-table td:nth-child(3),
    #tradesTable td:nth-child(4),
    #openTradesTable td:nth-child(4),
    #historyTable td:nth-child(4) {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    /* Unstick sticky Action/Trade columns on mobile */
    .briefing-table th:nth-child(15), .briefing-table td:nth-child(15),
    .analysis-table th:nth-child(10), .analysis-table td:nth-child(10) {
        position: static;
        box-shadow: none;
    }

    /* Event date sub-line in Time cells */
    .event-date-sub { font-size: 0.7rem; }

    #pnlTable { min-width: 400px; width: max-content; }
    #pnlTable td, #pnlTable th { white-space: nowrap; }

    /* Settings page */
    .settings-grid { grid-template-columns: 1fr; }
    .settings-section { padding: 20px; }
    .settings-actions { flex-direction: column; }
    .settings-actions .btn { width: 100%; justify-content: center; }
    .settings-form { max-width: 100%; }
}
