/* OSD Quant Desk — panel styles only. The page chrome (topbar/brand/layout)
   comes from osd-tools-design.css, the SAME canonical header used by crypto.html,
   crypto-live, decision-windows, etc. This file styles only the desk panels and
   reuses design-system tokens (--bg-1, --line, --ink*, --green/--red/--amber/--blue)
   so it inherits the light/dark themes. Mono numerals use --deskmono. */
:root { --deskmono: "JetBrains Mono", ui-monospace, "IBM Plex Mono", monospace; --desk-tint: rgba(29, 78, 216, 0.10); }

/* Desk pages run full-width — override the design system's centered 1280px
   .layout cap. Safe because osd-desk.css only loads on the desk pages.
   grid-template-columns: minmax(0, 1fr) stops the single grid column from
   blowing out to max-content (which would push the whole page wider than the
   viewport on mobile). min-width:0 on the flex/grid children does the same. */
.layout { max-width: none; padding-left: 22px; padding-right: 22px; grid-template-columns: minmax(0, 1fr); }
.dgrid, .dcol, .dpanel, .page-head, .desk-toolbar, .riskstrip { min-width: 0; }

.deskmono { font-family: var(--deskmono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.lbl { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); font-weight: 600; }

/* ── desk toolbar (controls live in the page head) ── */
.desk-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill { font-family: var(--deskmono); font-size: 11px; padding: 4px 9px; border-radius: 4px; background: var(--bg-2); color: var(--ink-mute); border: 1px solid var(--line); display: flex; gap: 6px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.live { background: #10b981; }
.dot.warn { background: var(--amber); }
.dot.prod { background: var(--blue); }
button.ctl { font-family: var(--deskmono); font-size: 11px; padding: 5px 12px; border-radius: 5px; border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; }
button.ctl:hover { filter: brightness(.92); }
.ctl-lbl { font-family: var(--deskmono); font-size: 11px; color: var(--ink-mute); display: flex; gap: 5px; align-items: center; cursor: pointer; }
.desk-toolbar .clock { font-family: var(--deskmono); font-size: 11px; color: var(--ink-faint); }

/* ── risk strip ── */
.riskstrip { display: grid; grid-template-columns: repeat(8, 1fr); border: 1px solid var(--line); background: var(--bg-1); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-sm); }
.kpi { padding: 11px 13px; border-right: 1px solid var(--line); position: relative; cursor: help; }
.kpi:last-child { border-right: none; }
.kpi .v { font-family: var(--deskmono); font-variant-numeric: tabular-nums; font-size: 21px; font-weight: 500; margin-top: 3px; letter-spacing: -.02em; color: var(--ink); }
.kpi .sub { font-family: var(--deskmono); font-size: 10.5px; color: var(--ink-mute); margin-top: 2px; }
.kpi.flag { background: var(--amber-bg); }

/* ── grid + panels ── */
.dgrid { display: grid; grid-template-columns: 1.35fr 1.25fr 1fr; gap: 14px; align-items: start; }
.dpanel { background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); overflow: hidden; }
.dpanel > .head { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.dpanel > .head .lbl { font-size: 10.5px; cursor: help; }
.dpanel > .head .meta { margin-left: auto; font-family: var(--deskmono); font-size: 10.5px; color: var(--ink-mute); }
.dcol { display: flex; flex-direction: column; gap: 14px; }

/* ── blotter ── */
table.blotter { width: 100%; border-collapse: collapse; font-family: var(--deskmono); font-variant-numeric: tabular-nums; font-size: 11.5px; }
table.blotter th { text-align: right; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-mute); font-weight: 600; padding: 7px 10px 6px; border-bottom: 1px solid var(--line); cursor: help; }
table.blotter th:first-child, table.blotter td:first-child { text-align: left; }
table.blotter td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; color: var(--ink-soft); }
table.blotter tr:hover td { background: var(--bg-2); }
.tkr { font-weight: 500; color: var(--ink); }
.side-tag { font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 2px; letter-spacing: .04em; }
.side-tag.no { background: var(--desk-tint); color: var(--blue); }
.side-tag.yes { background: var(--amber-bg); color: var(--amber); }

/* ── heatmap ── */
.heat { display: grid; grid-template-columns: 54px repeat(4, 1fr); gap: 3px; padding: 12px 13px; }
.heat .hh { font-family: var(--deskmono); font-size: 9.5px; color: var(--ink-mute); display: flex; align-items: center; justify-content: center; }
.heat .rl { font-family: var(--deskmono); font-size: 11px; color: var(--ink-soft); display: flex; align-items: center; font-weight: 500; }
.cell { aspect-ratio: 2.6/1; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--deskmono); font-size: 11px; font-weight: 500; border: 1px solid var(--line); }

/* ── charts ── */
.chartwrap { padding: 12px 13px 14px; }
svg { display: block; width: 100%; overflow: visible; }
.axisline { stroke: var(--line-strong); stroke-width: 1; }
.gridline { stroke: var(--line); stroke-width: 1; }
.tick { font-family: var(--deskmono); font-size: 9px; fill: var(--ink-mute); }
.bar { transition: opacity .2s; }

/* ── mini tables ── */
.mini { width: 100%; border-collapse: collapse; font-family: var(--deskmono); font-variant-numeric: tabular-nums; font-size: 11px; }
.mini td { padding: 5px 13px; border-bottom: 1px solid var(--line); }
.mini td:last-child, .mini td.r { text-align: right; }
.mini .k { color: var(--ink-soft); }

/* ── decision tape ── */
.dtape { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; padding: 6px 13px; border-bottom: 1px solid var(--line); font-family: var(--deskmono); font-size: 11px; align-items: baseline; }
.dtape .t { color: var(--ink-faint); font-size: 10px; }
.dtape .m { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtape .r { font-size: 9.5px; font-weight: 700; letter-spacing: .03em; }
.r.place { color: var(--green); }
.r.rej { color: var(--red); }
.r.skip { color: var(--amber); }

.dtag { font-family: var(--deskmono); font-size: 9.5px; padding: 1px 6px; border-radius: 2px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--bg-2); }
.dtag.live { color: var(--green); border-color: #a7e3c4; background: var(--green-bg); }
.dtag.off { color: var(--ink-faint); }

/* ── gate funnel (sports) ── */
.funrow { display: grid; grid-template-columns: 96px 1fr 44px; gap: 8px; align-items: center; padding: 5px 13px; border-bottom: 1px solid var(--line); font-family: var(--deskmono); font-size: 11px; }
.fname { color: var(--ink-soft); }
.fbar { height: 10px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.fbar > span { display: block; height: 100%; background: rgba(29,78,216,.45); }
.fcount { text-align: right; color: var(--ink-soft); }
.fcount.pass { color: var(--green); font-weight: 700; }
.funrow:last-child .fbar > span { background: rgba(4,120,87,.6); }

.note { font-size: 11px; color: var(--ink-mute); line-height: 1.5; }
.note b { color: var(--ink-soft); }
.callout { font-size: 11px; color: var(--ink-soft); line-height: 1.5; padding: 10px 13px; background: var(--amber-bg); border-top: 1px solid var(--line); }
.callout b { color: var(--ink); }

.desk-banner { display: none; padding: 12px 16px; border-radius: 8px; background: var(--red-bg); border: 1px solid var(--line-strong); color: var(--ink); font-size: 13px; }
.desk-banner.show { display: block; }

/* ── Responsive ──
   Tablet: collapse the 3-column grid + 8-tile strip. Phone: shrink padding,
   stack the page head + controls, and make the dense data tables scroll
   horizontally inside their panels (display:block + overflow-x) so a wide
   blotter never forces the whole page wide. */
/* Hard stop on horizontal page scroll. `clip` (not hidden) doesn't create a
   scroll container, so the sticky topbar keeps working. */
html, body { max-width: 100%; overflow-x: clip; }
@media (max-width: 1280px) { .dgrid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1024px) {
  .dgrid { grid-template-columns: 1fr; gap: 12px; }
  .riskstrip { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .layout { padding-left: 12px; padding-right: 12px; }
  .riskstrip { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 9px 11px; }
  .kpi .v { font-size: 18px; }
  /* Dense tables scroll horizontally within their panel instead of widening
     the page. display:block lets the table overflow + scroll; rows/cells keep
     their table rendering. */
  .dpanel table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  /* flex-wrap:nowrap is critical — the page's inline style sets flex-wrap:wrap,
     and column + wrap makes children flow into SIDE-BY-SIDE columns (title in
     col 1, toolbar in col 2), which is the "overlap" bug. nowrap = true stack. */
  main.layout .page-head { display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
  /* Force the controls to the full column width so they left-align and wrap
     within it (otherwise the inline align-items:flex-end leaves the toolbar
     content-width and pushed off the right edge). */
  main.layout .page-head .desk-toolbar { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  /* Topbar: the design-system mobile grid puts the brand + the 3 pgtabs + the
     user menu side-by-side, which overlaps and overflows. Override to stack:
     brand on row 1, tabs + menu wrapping on row 2. */
  header.topbar { display: flex; flex-wrap: wrap; height: auto; min-height: 0; align-items: center; gap: 6px 10px; padding: 8px 12px; }
  header.topbar .topbar-spacer { display: none; }
  header.topbar .brand-lockup { flex: 1 1 auto; min-width: 0; }
  header.topbar .brand-section { white-space: nowrap; }
  header.topbar .topbar-right { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .pgtabs { flex-wrap: wrap; margin-right: 0; }
}
@media (max-width: 400px) {
  .riskstrip { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 19px; }
  #tapeBox { height: 200px; }
}
