  :root { --bg:#fff; --fg:#111; --muted:#666; --line:#ddd; --head:#f4f4f4; --proj:#1a5fb4; --stale:#b45309; --down:#b91c1c; --hi:#eef4fb; --gain:#15803d; --held:#dff3e4; }
  @media (prefers-color-scheme: dark) {
    :root { --bg:#141518; --fg:#e8e8e8; --muted:#9a9a9a; --line:#2c2e33; --head:#1d1f24; --proj:#7cb4ff; --stale:#f5a524; --down:#f87171; --hi:#1b2633; --gain:#4ade80; --held:#163021; }
  }
  * { box-sizing: border-box; }
  body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.4 -apple-system, system-ui, sans-serif; }
  .top { position:sticky; top:0; background:var(--bg); border-bottom:1px solid var(--line); padding:10px 16px; z-index:2; }
  .quote { display:flex; flex-wrap:wrap; gap:6px 18px; align-items:baseline; }
  .quote .sym { font-size:22px; font-weight:600; }
  .quote .px { font-size:22px; font-variant-numeric: tabular-nums; }
  .quote .chg { font-size:18px; font-weight:600; font-variant-numeric: tabular-nums; color:var(--muted); }
  .quote .chg.up { color:var(--gain); }
  .quote .chg.dn { color:var(--down); }
  .quote .tag { font-size:12px; padding:1px 6px; border:1px solid var(--line); border-radius:4px; color:var(--muted); }
  .quote .tag.live { color:#15803d; border-color:#15803d; }
  .muted { color:var(--muted); }
  .down { color:var(--down); font-weight:600; }
  .rate { display:inline-flex; align-items:center; gap:6px; }
  td.fair { font-weight:600; color:var(--proj); }
  .rate input { width:5.5em; font:inherit; padding:2px 4px; background:var(--bg); color:var(--fg); border:1px solid var(--line); border-radius:4px; }
  .chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
  .chip { font-size:12px; padding:3px 8px; border:1px solid var(--line); border-radius:12px; text-decoration:none; color:var(--fg); white-space:nowrap; }
  .chip b { color:var(--proj); font-variant-numeric: tabular-nums; }
  main { padding: 8px 16px 40px; }
  section { margin: 22px 0; }
  h2 { font-size:16px; margin:0 0 6px; display:flex; flex-wrap:wrap; gap:6px 16px; align-items:baseline; }
  h2 .proj { color:var(--proj); }
  h2 .asof { font-weight:normal; font-size:12px; color:var(--muted); }
  h2 .asof.stale { color:var(--stale); }
  table { border-collapse:collapse; font-variant-numeric: tabular-nums; width:100%; max-width:760px; }
  th, td { text-align:right; padding:3px 8px; border-bottom:1px solid var(--line); white-space:nowrap; }
  th { background:var(--head); font-weight:600; }
  td:first-child, th:first-child { text-align:right; font-weight:600; }
  #main.by-strike tr.projline td { border-bottom:2px solid var(--proj); }
  th.sortable { cursor:pointer; user-select:none; -webkit-user-select:none; }
  th.sortable:hover, th.sorted { color:var(--proj); }
  tr.near td { background:var(--hi); }
  tr.held td { background:var(--held); }            /* after .near: a held row stays green */
  td.dim { color:var(--muted); }
  tr.noask:not(.ordered) { display:none; }
  tr.nofair:not(.held):not(.ordered) { display:none; }
  /* a working order on this contract: amber edge + a tag after the strike, from data-order. Chain strikes are
     LEFT-aligned (Michael, 09-23) so a tag can never shift a strike out of line. */
  #main td:first-child, #main th:first-child { text-align:left; }
  tr.ordered td:first-child { box-shadow:inset 3px 0 0 var(--stale); }
  td[data-order]::after { content:attr(data-order); margin-left:6px; padding:0 4px; font-size:11px; font-weight:600;
                          color:var(--stale); border:1px solid var(--stale); border-radius:4px; white-space:nowrap; }     /* fair <= 0: out of the money at the landing (held rows stay) */
  section.empty .tw { display:none; }
  section.empty h2::after { content:attr(data-why); font-weight:normal; font-size:12px; color:var(--muted); }
  td.pos { color:var(--gain); font-weight:600; }
  td.neg { color:var(--muted); }
  @media (max-width:600px) { th, td { padding:3px 5px; } .hide-sm { display:none; } }

  /* login page */
  main.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
  main.login h1 { font-size: 20px; margin: 0 0 12px; }
  main.login label { display:block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
  main.login input { display:block; width:100%; font: inherit; font-size: 16px; padding: 8px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; }
  main.login button { margin-top: 14px; width: 100%; font: inherit; font-size: 16px; padding: 9px; border: 0; border-radius: 6px; background: var(--proj); color: #fff; }
  main.login .err { color: var(--down); min-height: 1.2em; margin: 0; }

  /* buy column + order ticket */
  [hidden] { display:none !important; }
  td.buycol { text-align:center; }
  button.buy { font:inherit; font-size:12px; padding:2px 10px; border-radius:5px; border:1px solid var(--gain);
               color:var(--gain); background:transparent; cursor:pointer; }
  button.buy:hover { background:var(--gain); color:#fff; }
  dialog#ticket { padding:0; border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--fg);
                  width:min(420px, calc(100vw - 32px)); }
  dialog#ticket::backdrop { background:rgba(0,0,0,.45); }
  dialog#ticket > div { padding:16px 18px; }
  dialog#ticket h3 { margin:0 0 10px; font-size:17px; }
  .t-quote { display:flex; flex-wrap:wrap; gap:6px 18px; align-items:baseline; font-size:16px; font-variant-numeric:tabular-nums; }
  .t-quote .muted { font-size:12px; }
  dialog#ticket label { display:block; margin:12px 0 0; color:var(--muted); font-size:13px; }
  dialog#ticket select, dialog#ticket input { display:block; width:100%; margin-top:4px; font:inherit; font-size:16px;
                  padding:7px 8px; background:var(--bg); color:var(--fg); border:1px solid var(--line); border-radius:6px; }
  .qty { display:flex; gap:6px; margin-top:4px; }
  .qty input { text-align:center; margin-top:0 !important; }
  .t-figs { display:flex; gap:32px; margin:16px 0 0; }
  #t-breakdown { display:block; margin-top:2px; }
  #t-total, #t-roi { display:block; font-size:24px; font-weight:600; font-variant-numeric:tabular-nums; }
  #t-breakdown { font-size:12px; }
  .t-err { color:var(--down); min-height:1.2em; margin:8px 0 0; font-size:13px; }
  .t-actions { display:flex; gap:8px; justify-content:flex-end; margin-top:14px; }
  .t-actions button, .qty button { font:inherit; font-size:16px; padding:8px 16px; border-radius:6px; cursor:pointer;
                  border:1px solid var(--line); background:var(--head); color:var(--fg); }
  .qty button { width:48px; padding:6px 0; font-size:20px; }
  button.primary { background:var(--gain); border-color:var(--gain); color:#fff; font-weight:600; }
  button.primary:disabled { opacity:.4; cursor:not-allowed; }
  .mode, .banner { margin:0 0 10px; padding:6px 10px; border-radius:6px; font-size:12px; font-weight:600; }
  .mode.sim, .banner.sim { color:var(--stale); border:1px solid var(--stale); }
  .mode.live, .banner.live { color:var(--down); border:1px solid var(--down); }
  button.primary.live { background:var(--down); border-color:var(--down); }
  #t-summary { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; margin:0; font-size:14px; }
  #t-summary dt { color:var(--muted); }
  #t-summary dd { margin:0; font-variant-numeric:tabular-nums; }

  /* phones: the table is wider than the screen, so it scrolls sideways inside its own box (the page
     never does), with strike pinned left and Buy pinned right so both stay reachable */
  .tw { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  @media (max-width:600px) {
    .tw td:first-child, .tw th:first-child, .tw td.buycol, .tw th.buycol { position:sticky; z-index:1; background:var(--bg); }
    .tw td:first-child, .tw th:first-child { left:0; }
    .tw td.buycol, .tw th.buycol { right:0; }
    .tw th:first-child, .tw th.buycol { background:var(--head); }
    .tw tr.near td:first-child, .tw tr.near td.buycol { background:var(--hi); }
    .tw tr.held td:first-child, .tw tr.held td.buycol { background:var(--held); }
  }

  /* account + holdings: pinned right on wide screens, above the chains on phones */
  .layout { display:grid; grid-template-columns:minmax(0, 1fr); }
  aside#holdings { order:-1; padding:4px 16px 12px; border-bottom:1px solid var(--line); }
  @media (min-width:1180px) {
    .layout { grid-template-columns:minmax(0, 800px) minmax(380px, 1fr); align-items:start; }
    aside#holdings { order:0; position:sticky; top:var(--top-h, 120px); max-height:calc(100vh - var(--top-h, 120px));
                     overflow:auto; border-bottom:0; border-left:1px solid var(--line); }
  }
  #holdings h3 { font-size:16px; margin:12px 0 6px; display:flex; gap:10px; align-items:baseline; }
  #holdings h3 .asof { font-size:12px; font-weight:normal; }
  #holdings h4 { font-size:13px; margin:12px 0 4px; color:var(--muted); font-weight:600; }
  .acct { display:flex; flex-wrap:wrap; gap:4px 16px; font-size:14px; font-variant-numeric:tabular-nums; }
  table.hold { max-width:none; }
  table.hold th, table.hold td { padding:3px 6px; font-size:13px; }
  table.hold td:last-child, table.hold th:last-child { position:sticky; right:0; background:var(--bg); }
  table.hold th:last-child { background:var(--head); }
  table.hold td:first-child, table.hold th:first-child { text-align:left; }
  td.loss { color:var(--down); font-weight:600; }
  #t-total-label, #t-roi-label { display:block; font-size:12px; }
  #t-roi.pos { color:var(--gain); }
  #t-roi.neg { color:var(--down); }
  button.sell { font:inherit; font-size:12px; padding:2px 10px; border-radius:5px; border:1px solid var(--down);
                color:var(--down); background:transparent; cursor:pointer; }
  button.sell:hover { background:var(--down); color:#fff; }
  button.cancel-order { font:inherit; font-size:12px; padding:2px 10px; border-radius:5px; border:1px solid var(--muted);
                        color:var(--fg); background:transparent; cursor:pointer; }
  button.cancel-order:hover { background:var(--muted); color:var(--bg); }
  button.cancel-order:disabled { opacity:.6; cursor:default; }

  /* options panel: its own header (underlying toggle, quote, that underlying's decay rate, chips) */
  .panelhead { padding:4px 0 8px; border-bottom:1px solid var(--line); background:var(--bg); }
  @media (min-width:1180px) { .panelhead { position:sticky; top:var(--top-h, 44px); z-index:2; } }
  .symsel { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
  .symsel button { font:inherit; font-size:18px; font-weight:600; padding:3px 12px; border:0; background:transparent;
                   color:var(--muted); cursor:pointer; }
  .symsel button + button { border-left:1px solid var(--line); }
  .symsel button.on { background:var(--proj); color:#fff; }
  .symsel .pill { display:inline-block; min-width:20px; margin-left:6px; padding:0 6px; border-radius:10px; box-sizing:border-box;
                  font-size:12px; line-height:20px; text-align:center; vertical-align:2px; background:var(--proj); color:#fff; }
  .symsel button.on .pill { background:#fff; color:var(--proj); }
  .symsel .pill[hidden] { display:none; }
  #main.no-buy .buycol { display:none; }

/* the re-login control that replaces "Gateway down" (09-28) */
#relogin { font:inherit; font-size:13px; padding:2px 12px; border-radius:6px; border:1px solid var(--down);
           background:var(--down); color:#fff; cursor:pointer; margin-left:6px; }
#relogin:disabled { opacity:.6; cursor:default; }
#relogin-msg { font-size:13px; margin-left:6px; }

/* the semi-automatic buy (09-28): Probe button in each strip header + its dialog (same look as the ticket) */
button.probe-btn { font:inherit; font-size:12px; padding:2px 10px; border-radius:5px; border:1px solid var(--proj);
                   color:var(--proj); background:transparent; cursor:pointer; margin-left:6px; }
button.probe-btn:hover { background:var(--proj); color:#fff; }
/* buy to cover (10-08): button on an expiring in-the-money put + its dialog (the ticket's look) */
table.hold .left { text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
button.cover { font:inherit; font-size:12px; padding:2px 10px; border-radius:5px; border:1px solid var(--proj);
               color:var(--proj); background:transparent; cursor:pointer; margin-left:4px; white-space:nowrap; }
button.cover:hover { background:var(--proj); color:#fff; }
dialog#cover { padding:0; border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--fg); width:min(480px, 96vw); }
dialog#cover::backdrop { background:rgba(0,0,0,.45); }
dialog#cover > div { padding:16px 18px; }
dialog#cover h3 { margin:0 0 10px; font-size:17px; }
dialog#cover label { display:block; margin:12px 0 0; color:var(--muted); font-size:13px; }
dialog#cover select, dialog#cover input { display:block; width:100%; margin-top:4px; font:inherit; font-size:16px;
                padding:7px 8px; background:var(--bg); color:var(--fg); border:1px solid var(--line); border-radius:6px; }
#cv-what, #cv-note { font-size:13px; }
#cv-itm.pos { color:var(--gain); } #cv-itm.down { color:var(--down); font-weight:600; }
.cv-cmp { width:100%; margin-top:14px; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.cv-cmp td { padding:6px 0; border-bottom:1px solid var(--line); }
.cv-cmp td + td { text-align:right; font-weight:600; }
.cv-warn { color:var(--down); font-size:13px; margin:6px 0 0; }
#cv-err.pos { color:var(--gain); }
dialog#probe { padding:0; border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--fg);
               width:min(720px, 96vw); }
dialog#probe::backdrop { background:rgba(0,0,0,.45); }
dialog#probe > div { padding:16px 18px; }
dialog#probe h3 { margin:0 0 10px; font-size:17px; }
.pb-params { display:flex; flex-wrap:wrap; gap:8px 14px; }
.pb-params label { display:flex; flex-direction:column; font-size:13px; color:var(--muted); }
.pb-params input, .pb-params select { font:inherit; font-size:14px; width:9em; padding:3px 6px; background:var(--bg); color:var(--fg);
                                      border:1px solid var(--line); border-radius:4px; margin-top:2px; }
#pb-basis, #pb-status { font-size:13px; margin:10px 0 6px; }
#pb-table { width:100%; }
dialog#probe .tw { max-height:45vh; overflow:auto; }
#pb-status.pos, #pb-body td.pos { color:var(--gain); font-weight:600; }
#pb-status.down { color:var(--down); }
