/* Pick Sequence tab — matches ygbuff dark theme */
:root {
    --bg-dark: #111827;
    --bg-light: #1f2937;
    --card-bg: #1e293b;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-blue-soft: rgba(59, 130, 246, 0.15);
    --accent-orange: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --hover-bg: rgba(59, 130, 246, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
}
body { padding: 16px 20px 60px; }

.psq-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
    border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-bottom: 16px;
    flex-wrap: wrap;
}
.psq-header h1 { font-size: 22px; font-weight: 600; }
.psq-header .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.psq-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 999px;
    padding: 6px 14px; cursor: pointer; user-select: none; font-size: 13px;
}
.psq-toggle .switch {
    width: 32px; height: 18px; border-radius: 999px; background: #374151;
    position: relative; transition: background .15s;
}
.psq-toggle .switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: #9ca3af;
    transition: left .15s, background .15s;
}
.psq-toggle.on .switch { background: var(--accent-blue-soft); }
.psq-toggle.on .switch::after { left: 16px; background: var(--accent-blue); }

.psq-controls {
    display: grid; grid-template-columns: 1.5fr 1.5fr 1fr auto; gap: 10px;
    margin-bottom: 10px;
}
.psq-controls + .psq-controls {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    margin-bottom: 18px;
}
.psq-field input[type="date"] {
    flex: 1; background: transparent; color: var(--text-primary); border: none; outline: none;
    font-size: 13px; font-family: inherit; color-scheme: dark;
}
.psq-reset-btn {
    background: transparent; color: var(--text-muted); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 12px;
}
.psq-reset-btn:hover { color: var(--text-primary); border-color: var(--accent-blue); }

.psq-header-actions { display: flex; align-items: center; gap: 10px; }
.psq-view-toggle {
    display: inline-flex; background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; overflow: hidden;
}
.psq-view-toggle .vt-btn {
    background: transparent; color: var(--text-muted); border: none;
    padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.psq-view-toggle .vt-btn.active { background: var(--accent-blue); color: #fff; }
.psq-view-toggle .vt-btn:not(.active):hover { color: var(--text-primary); }

/* Aggregated view */
.agg-grid {
    display: grid; gap: 8px;
}
.agg-col {
    background: rgba(255,255,255,0.02); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 6px; min-width: 0;
}
.agg-col-head {
    font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase;
    text-align: center; padding: 4px 0 6px; border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px; font-weight: 600;
}
.agg-col-head .opener-tag {
    color: var(--accent-blue); font-weight: 400; font-size: 9px; display: block; margin-top: 2px;
}
.agg-col-body { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.agg-cell {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 4px; border-radius: 4px;
}
.agg-cell:hover { background: var(--hover-bg); }
.agg-cell .img {
    width: 44px; height: 25px; border-radius: 3px;
    background-size: cover; background-position: center;
    background-color: #0b1220; flex-shrink: 0;
}
.agg-cell .agg-stat {
    font-size: 11px; color: var(--text-secondary); font-weight: 600;
    white-space: nowrap;
}
.agg-cell .agg-stat .wr-high { color: #22c55e; }
.agg-cell .agg-stat .wr-mid { color: #facc15; }
.agg-cell .agg-stat .wr-low { color: #ef4444; }
.agg-empty { text-align: center; color: var(--text-muted); font-size: 11px; padding: 12px 0; }
.psq-field {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px;
    padding: 8px 12px; display: flex; align-items: center; gap: 10px; min-height: 42px;
}
.psq-field .lbl {
    font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase;
    flex-shrink: 0;
}
.psq-field select {
    flex: 1; background: transparent; color: var(--text-primary); border: none; outline: none;
    font-size: 14px; font-family: inherit;
}
.psq-field select option { background: var(--bg-light); }

.psq-active-filters {
    font-size: 12px; color: var(--text-secondary); flex: 1; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.psq-active-filters .chip {
    display: inline-block; background: var(--accent-blue-soft); color: var(--accent-blue);
    padding: 2px 8px; border-radius: 12px; margin-right: 6px; font-size: 11px;
}

.psq-run-btn {
    background: var(--accent-blue); color: #fff; border: none; border-radius: 8px;
    padding: 0 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.psq-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.psq-run-btn:hover:not(:disabled) { background: #2563eb; }

.psq-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px;
}
.psq-stat {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
    padding: 12px 14px;
}
.psq-stat .k { font-size: 10px; color: var(--text-muted); letter-spacing: 1.2px; text-transform: uppercase; }
.psq-stat .v { font-size: 26px; font-weight: 600; margin-top: 4px; line-height: 1.1; }
.psq-stat .v small { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.psq-stat .v.wr-high { color: #22c55e; }
.psq-stat .v.wr-mid { color: #facc15; }
.psq-stat .v.wr-low { color: #ef4444; }

.psq-status {
    text-align: center; padding: 40px 20px; color: var(--text-muted);
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
}
.psq-status.error { color: var(--danger-color); }

.psq-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1400px) { .psq-panels { grid-template-columns: 1fr; } }

.psq-panel {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 10px;
    padding: 14px 16px;
}
.psq-panel h3 {
    font-size: 14px; font-weight: 600; margin-bottom: 4px;
    display: flex; align-items: center; gap: 8px;
}
.psq-panel h3 .side-tag {
    font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase;
    font-weight: 400;
}
.psq-panel-sub {
    font-size: 11px; color: var(--text-muted); margin-bottom: 12px;
}

.psq-table {
    width: 100%; border-collapse: collapse; table-layout: fixed;
}
.psq-table thead th {
    font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase;
    text-align: center; padding: 6px 2px; border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}
.psq-table thead th.col-team {
    width: 90px; text-align: left;
}
.psq-table thead th.col-count, .psq-table thead th.col-wr {
    width: 56px; text-align: right;
}
.psq-table tbody td {
    padding: 4px 2px; vertical-align: middle;
    border-top: 1px dashed rgba(255,255,255,0.04);
}
.team-cell {
    font-size: 11px; color: var(--text-secondary);
    line-height: 1.3; max-width: 90px;
}
.team-cell .team-chip {
    display: block; padding: 1px 4px; border-radius: 3px;
    background: rgba(255,255,255,0.04); color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 1px;
}
.team-cell .team-chip:last-child { margin-bottom: 0; }
.team-cell .team-n { color: var(--text-muted); font-weight: 600; font-size: 10px; }
.team-cell .team-empty { color: var(--text-muted); }
.psq-table tbody tr.group-start td { border-top: 1px solid rgba(255,255,255,0.10); }
.psq-table tbody tr:hover { background: var(--hover-bg); }

.hero-cell {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 28px; gap: 2px;
}
.hero-cell .img {
    width: 50px; height: 28px; border-radius: 4px;
    background-size: cover; background-position: center;
    background-color: #0b1220;
    flex-shrink: 0;
}
.hero-cell.blank { opacity: 0; pointer-events: none; }
.hero-cell.opener .img { box-shadow: 0 0 0 2px var(--accent-blue); }
.hero-cell .hg-badge {
    font-size: 9px; line-height: 1.2; font-weight: 600;
    padding: 1px 4px; border-radius: 3px;
    background: rgba(255,255,255,0.04);
    white-space: nowrap;
}
.hero-cell .hg-badge.wr-high { color: #22c55e; }
.hero-cell .hg-badge.wr-mid { color: #facc15; }
.hero-cell .hg-badge.wr-low { color: #ef4444; }

.count-cell { text-align: right; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.wr-cell { text-align: right; font-size: 13px; font-weight: 600; }
.wr-cell.wr-high { color: #22c55e; }
.wr-cell.wr-mid { color: #facc15; }
.wr-cell.wr-low { color: #ef4444; }
.wr-cell .sub { display: block; font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ==================== Mobile (≤768px) ==================== */
@media (max-width: 768px) {
    body { padding: 8px 8px 40px; font-size: 13px; }

    .psq-header { gap: 8px; padding-bottom: 8px; margin-bottom: 10px; }
    .psq-header h1 { font-size: 16px; }
    .psq-header .subtitle { font-size: 11px; }
    .psq-header-actions { gap: 6px; }
    .psq-view-toggle .vt-btn { padding: 4px 10px; font-size: 11px; }
    .psq-toggle { padding: 4px 10px; font-size: 11px; }

    /* Filter rows: 2 columns; tighter cards */
    .psq-controls,
    .psq-controls + .psq-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 6px;
        margin-bottom: 8px;
    }
    .psq-field {
        padding: 4px 8px;
        min-height: 34px;
        gap: 6px;
    }
    .psq-field .lbl { font-size: 9px; letter-spacing: 0.3px; }
    .psq-field select,
    .psq-field input[type="date"] {
        font-size: 12px;
        min-width: 0;
        width: 100%;
    }
    .psq-reset-btn { padding: 4px 8px; font-size: 11px; }
    .psq-run-btn { padding: 6px 10px; font-size: 12px; }

    /* Summary cards: 2x2 grid, compact labels */
    .psq-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        margin-bottom: 12px;
    }
    .psq-stat { padding: 6px 8px; border-radius: 8px; }
    .psq-stat .k {
        font-size: 9px;
        letter-spacing: 0.3px;
        line-height: 1.15;
    }
    .psq-stat .v { font-size: 18px; margin-top: 2px; }
    .psq-stat .v small { font-size: 10px; margin-left: 4px; }

    .psq-panel { padding: 8px 8px; }
    .psq-panel h3 { font-size: 12px; }
    .psq-panel-sub { font-size: 10px; margin-bottom: 8px; }

    /* Sequence table: shrink hero tiles + team col so 5 picks + team + count + WR fit */
    .psq-table { table-layout: auto; }
    .psq-table thead th {
        font-size: 9px;
        padding: 4px 1px;
        letter-spacing: 0.2px;
    }
    .psq-table thead th.col-team { width: 60px; }
    .psq-table thead th.col-count,
    .psq-table thead th.col-wr { width: 36px; }
    .psq-table tbody td { padding: 3px 1px; }

    .hero-cell .img { width: 30px; height: 17px; border-radius: 3px; }
    .hero-cell .hg-badge { font-size: 8px; padding: 0 2px; }

    .team-cell {
        font-size: 10px;
        max-width: 60px;
    }
    .team-cell .team-chip { padding: 0 3px; font-size: 10px; }
    .team-cell .team-n { font-size: 9px; }

    .count-cell, .wr-cell { font-size: 11px; }
    .wr-cell .sub { font-size: 9px; }

    /* Aggregated view */
    .agg-col { padding: 4px; }
    .agg-col-head { font-size: 9px; padding: 2px 0 4px; }
    .agg-cell .img { width: 30px; height: 17px; }
    .agg-cell .agg-stat { font-size: 10px; }
}
