/* Research dashboard styles (moved from dashboard.html). */
    :root {
      color-scheme: light;
      --ink: #20291f;
      --muted: #687166;
      --paper: #f4f5ef;
      --surface: #fff;
      --rule: #dce1d7;
      --green: #23734d;
      --green-soft: #e5f1e9;
      --red: #aa4938;
      --amber: #976411;
      --mono: "SFMono-Regular", Consolas, monospace;
      --sans: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
    }
    * { box-sizing: border-box; }
    body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.45 var(--sans); }
    button { font: inherit; }
    .topbar { background: #20291f; color: #f5f5ee; border-bottom: 3px solid #91c781; }
    .topbar-inner, main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
    .topbar-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
    .brand { display: flex; align-items: center; gap: 13px; }
    .mark { width: 28px; height: 28px; border: 2px solid #a6d293; display: grid; place-items: center; color: #a6d293; font-weight: 800; }
    h1 { margin: 0; font-size: 19px; font-weight: 700; }
    .brand small { color: #c7d0c3; display: block; font-size: 11px; }
    .connection { display: flex; align-items: center; gap: 8px; color: #d3ddcf; font-size: 12px; }
    .dot { width: 8px; height: 8px; border-radius: 50%; background: #d5a642; }
    .dot.ok { background: #8ad28f; }
    main { padding: 28px 0 60px; }
    .heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 23px; }
    .heading h2 { margin: 0; font-size: 24px; font-weight: 650; }
    .heading p { margin: 5px 0 0; color: var(--muted); }
    .actions { display: flex; gap: 8px; }
    .button { border: 1px solid #aeb9a9; background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: 4px; cursor: pointer; font-weight: 650; }
    .button:hover { border-color: var(--green); }
    .button.primary { background: var(--green); border-color: var(--green); color: #fff; }
    .button.primary:hover { background: #195a3a; }
    .button:disabled { opacity: .55; cursor: wait; }
    .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 13px 0; }
    .segments { display: inline-flex; border: 1px solid #b8c1b2; padding: 3px; border-radius: 5px; background: #e9ece4; gap: 2px; }
    .segments button { border: 0; background: transparent; color: #465143; border-radius: 3px; padding: 7px 13px; cursor: pointer; }
    .segments button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px #18221724; font-weight: 700; }
    .asof { color: var(--muted); font-size: 12px; font-family: var(--mono); }
    .notice { margin: 16px 0; border-left: 3px solid #c38a27; background: #f8f0df; color: #624819; padding: 10px 13px; font-size: 12px; }
    .metrics { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--rule); margin: 18px 0 26px; }
    .metric { min-height: 76px; padding: 14px 17px; border-right: 1px solid var(--rule); }
    .metric:last-child { border: 0; }
    .metric label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
    .metric strong { display: block; margin-top: 3px; font: 600 20px/1.2 var(--mono); }
    section { margin-top: 28px; }
    .section-title { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid #9eaa98; padding-bottom: 8px; margin-bottom: 0; }
    .section-title h3 { margin: 0; font-size: 16px; }
    .section-title span { color: var(--muted); font-size: 12px; }
    .table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-top: 0; }
    table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
    th { background: #edf0e9; color: #586253; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
    th, td { padding: 11px 13px; border-bottom: 1px solid #e8ebe4; white-space: nowrap; }
    tbody tr:last-child td { border-bottom: 0; }
    td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
    .edge { color: var(--green); font-weight: 750; }
    .badge { display: inline-block; padding: 3px 7px; border-radius: 3px; background: var(--green-soft); color: #245d3e; font-size: 10px; font-weight: 700; text-transform: uppercase; }
    .badge.muted { background: #eceee9; color: #5c6558; }
    .empty { padding: 28px 16px; color: var(--muted); text-align: center; }
    .error { color: var(--red); }
    .footer { color: var(--muted); margin-top: 24px; font-size: 11px; display: flex; justify-content: space-between; border-top: 1px solid var(--rule); padding-top: 12px; }
    @media (max-width: 680px) {
      .topbar-inner, main { width: min(100% - 24px, 1180px); }
      .topbar-inner { min-height: 64px; }
      main { padding-top: 20px; }
      .heading { align-items: start; flex-direction: column; }
      .actions { width: 100%; }
      .actions .button { flex: 1; }
      .toolbar { align-items: start; flex-direction: column; }
      .segments { width: 100%; }
      .segments button { flex: 1; padding-inline: 7px; }
      .metrics { grid-template-columns: repeat(2, 1fr); }
      .metric:nth-child(2) { border-right: 0; }
      .metric:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
      .footer { flex-direction: column; gap: 5px; }
    }
    .positive-ev { font-weight:700; background:rgba(52,211,153,.10); }

    :root {
      color-scheme: dark;
      --ink: #e9eef5;
      --muted: #9aa7b7;
      --paper: #101318;
      --surface: #171c23;
      --rule: #303a47;
      --green: #5d9cff;
      --green-soft: #1d3450;
      --red: #ff827d;
      --amber: #d8ab58;
    }
    body { background: radial-gradient(ellipse at 85% -20%, #202c3a 0, transparent 38%), var(--paper); color: var(--ink); }
    .topbar { background: #11161d; color: var(--ink); border-bottom: 1px solid #334253; }
    .mark { border-color: #d6e0ed; color: #d6e0ed; border-radius: 8px; }
    .brand small, .connection { color: var(--muted); }
    .dot.ok { background: #73d0a0; }
    .button { background: #1b222b; border-color: #394655; color: var(--ink); border-radius: 9px; min-height: 42px; }
    .button:hover { border-color: #6ea6f5; background: #222d39; }
    .button.primary { background: #316eb8; border-color: #4385d3; color: #fff; }
    .button.primary:hover { background: #3c7fce; }
    .toolbar { border-color: var(--rule); }
    .segments { background: #171d25; border-color: #354150; border-radius: 10px; }
    .segments button { color: #aab5c3; min-height: 40px; border-radius: 7px; }
    .segments button[aria-pressed="true"] { background: #2a3d55; color: #f2f6fc; box-shadow: none; }
    .notice { background: #26231c; color: #dfc68f; border-radius: 0 9px 9px 0; border-color: #bd9140; }
    .metrics { background: #171c23; border-color: var(--rule); border-radius: 14px; overflow: hidden; }
    .metric { border-color: var(--rule); }
    .section-title { border-color: #394655; }
    .table-wrap { background: #171c23; border-color: var(--rule); border-radius: 0 0 12px 12px; }
    th { background: #202833; color: #aab8c9; }
    th, td { border-color: #29323d; }
    .badge { background: #1d3450; color: #a9ccff; border-radius: 999px; }
    .badge.muted { background: #262d36; color: #a7b0bc; }
    .empty { color: var(--muted); }
    .edge { color: #8dbdff; }
    .footer { border-color: var(--rule); }
    .filter-toolbar { display:flex; align-items:center; gap:10px; }
    #filter-button { display:inline-flex; align-items:center; gap:9px; }
    #active-filter-count { min-width:21px; height:21px; padding:0 6px; display:inline-grid; place-items:center; border-radius:999px; background:#74aaff; color:#101820; font:700 11px var(--mono); }
    #active-filter-count[hidden] { display:none; }
    #filter-state-label { color:var(--muted); font-size:11px; }
    .filter-state-row { display:flex; justify-content:space-between; gap:14px; margin-top:10px; color:var(--muted); font-size:11px; }
    #filter-drawer[hidden] { display:none; }
    #filter-drawer { position:fixed; inset:0; z-index:50; }
    #filter-scrim { position:absolute; inset:0; width:100%; height:100%; border:0; background:#05080dc9; backdrop-filter:blur(5px); }
    .filter-dialog { position:absolute; top:18px; right:18px; bottom:18px; width:min(620px, calc(100% - 36px)); display:flex; flex-direction:column; background:#171c23; border:1px solid #3a4655; border-radius:18px; box-shadow:0 24px 90px #0009; animation:drawer-in .22s ease-out; }
    @keyframes drawer-in { from { transform:translateX(22px); opacity:.7; } to { transform:translateX(0); opacity:1; } }
    .drawer-head { flex:none; padding:21px 24px 15px; border-bottom:1px solid var(--rule); }
    .drawer-headline { display:flex; align-items:center; justify-content:space-between; gap:10px; }
    .drawer-head h2 { margin:0; font-size:20px; }
    .drawer-head p { margin:6px 0 0; color:var(--muted); font-size:12px; }
    .drawer-head-actions { display:flex; align-items:center; gap:8px; }
    .text-button { border:0; background:transparent; color:#8dbdff; cursor:pointer; min-height:40px; padding:8px 10px; font-weight:650; }
    .text-button:hover { color:#c0dcff; }
    /* Consensus EV, PEV and Edge share one column; PEV/Edge sort buttons sit under the EV sort. */
    th.value-col .sort-subs { display:flex; gap:2px; }
    th.value-col .sort-subs .text-button { min-height:28px; padding:2px 10px; font-size:11px; font-weight:600; }
    .hide-league { min-height:0; padding:0 6px; margin-left:4px; opacity:.4; font-weight:700; line-height:1; }
    .hide-league:hover { opacity:1; color:#ff9a9a; }
    #hidden-league-row[hidden] { display:none; }
    .filter-body { flex:1; overflow-y:auto; padding:14px 18px 24px; overscroll-behavior:contain; }
    .filter-row { width:100%; display:grid; grid-template-columns:minmax(0,1fr) auto 18px; align-items:center; gap:12px; text-align:left; padding:14px 15px; margin:0 0 8px; color:var(--ink); background:#1d242d; border:1px solid #303b48; border-radius:12px; min-height:58px; cursor:pointer; }
    .filter-row:hover { border-color:#5d8dc6; background:#222c37; }
    .filter-row-summary { color:#9baabd; font-size:12px; text-align:right; }
    .chevron { color:#8292a5; font-size:20px; }
    .filter-subpanel { display:flex; flex-direction:column; gap:13px; }
    .subpanel-tools { display:flex; justify-content:space-between; }
    .option-list { display:flex; flex-direction:column; gap:4px; }
    .option-group { color:#8ca2bd; font-size:11px; font-weight:750; letter-spacing:.06em; text-transform:uppercase; padding:12px 9px 5px; }
    .check-row { min-height:48px; display:flex; align-items:center; gap:12px; padding:9px 12px; border:1px solid #2b3541; background:#1b222b; border-radius:9px; cursor:pointer; }
    .check-row input { width:19px; height:19px; accent-color:#6ea6f5; }
    .control-label { display:flex; flex-direction:column; gap:7px; color:#aab6c5; font-size:12px; }
    .control-input { width:100%; min-height:44px; border:1px solid #3b4755; border-radius:9px; background:#10151b; color:var(--ink); padding:10px 12px; font:inherit; }
    .control-input:focus { outline:2px solid #5d9cff; outline-offset:1px; }
    .two-inputs { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
    .preset-row { display:flex; flex-wrap:wrap; gap:8px; }
    .preset { min-height:39px; padding:8px 12px; border:1px solid #3b4858; background:#202832; color:#d5deea; border-radius:999px; cursor:pointer; }
    .preset.selected, .preset:hover { border-color:#70a8f6; background:#233a55; }
    .subcopy { color:var(--muted); margin:0; font-size:12px; line-height:1.5; }
    .drawer-footer { flex:none; padding:14px 20px max(14px, env(safe-area-inset-bottom)); border-top:1px solid var(--rule); background:#171c23; border-radius:0 0 18px 18px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
    .preview-count { color:#aab6c5; font-size:12px; }
    .footer-actions { display:flex; gap:8px; }
    .warning-chip { display:inline-block; margin:2px 3px 2px 0; color:#e4c681; font-size:10px; }
    body.drawer-open { overflow:hidden; }
    .topbar { position:sticky; top:0; z-index:20; }
    .quick-filters { display:flex; flex-direction:column; gap:8px; margin:0 0 14px; }
    .qf-row { display:flex; align-items:flex-start; gap:12px; }
    .qf-label { flex:none; width:52px; padding-top:8px; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.06em; }
    .chips { display:flex; flex-wrap:wrap; gap:6px; }
    .chip { min-height:34px; padding:5px 13px; border:1px solid #3b4858; background:#1b222b; color:#c5d0de; border-radius:999px; cursor:pointer; font:inherit; font-size:12px; }
    .chip:hover { border-color:#70a8f6; }
    .chip[aria-pressed="true"] { background:#2a3d55; border-color:#5d9cff; color:#fff; font-weight:650; }
    .chip.stale { opacity:.55; border-style:dashed; }
    .chip .live { display:inline-block; width:6px; height:6px; margin-right:6px; border-radius:50%; background:#73d0a0; }
    .eta { font-family:var(--mono); font-weight:650; }
    .header-controls { padding:6px 14px; border:1px solid #2b3643; border-radius:999px; background:#151b22; }
    .metric strong { font-size:24px; }
    .metric:nth-child(3) strong { color:#8dbdff; }
    .metric:nth-child(4) strong { color:#73d0a0; }
    tbody tr { transition:background .12s; }
    tbody tr:hover { background:#1d2631; }
    .table-wrap { max-height:620px; overflow:auto; }
    th { position:sticky; top:0; z-index:1; }
    .scan-note { margin:0 0 14px; padding:10px 14px; border:1px solid #3a3426; border-left:3px solid #bd9140; border-radius:0 9px 9px 0; background:#211e17; color:#dfc68f; font-size:12px; }
    .scan-note[hidden] { display:none; }
    .scan-note.ok { border-color:#24402f; border-left-color:#73d0a0; background:#16221c; color:#a6dcbf; }
    .eta.soon { color:#e4c681; }
    .eta.live { color:#ff827d; }
    .sub { display:block; color:var(--muted); font-size:11px; }
    .header-controls { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
    .hc { display:flex; align-items:center; gap:8px; color:var(--muted); font-size:12px; }
    .hc .control-input { width:auto; min-height:34px; padding:4px 8px; }
    .arb-title { flex-wrap:wrap; align-items:center; gap:10px; }
    .arb-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
    .arb-controls .control-input { width:88px; }
    @media (min-width:1100px) {
      .topbar-inner, main { width:min(1600px, calc(100% - 64px)); }
      .metrics { grid-template-columns:repeat(4, 1fr); }
      th, td { padding:10px 16px; }
    }
    @media (max-width:680px) { .header-controls { gap:10px; } .topbar-inner { flex-wrap:wrap; padding:8px 0; } }
    @media (max-width:680px) {
      .filter-toolbar { width:100%; flex-direction:column; align-items:stretch; }
      .filter-toolbar { display:grid; grid-template-columns:1fr 1.4fr; }
      #scan { grid-column:1 / -1; }
      #filter-button { justify-content:center; }
      .filter-state-row { flex-direction:column; gap:3px; }
      .filter-dialog { inset:0; width:100%; border-radius:0; border:0; }
      .drawer-head { padding-top:max(16px, env(safe-area-inset-top)); }
      .drawer-footer { border-radius:0; }
      .footer-actions { flex:1; }
      .footer-actions .button { flex:1; }
      .filter-row { min-height:62px; padding-inline:12px; }
    }
    .positive-ev { font-weight:700; background:rgba(52,211,153,.10); }
