/* ════════════════════════════════════════════════════════════════════════════
   79-panel-gaps.css  THE PANEL SYSTEM (owner 2026-10-16, v2 2026-10-17).
   ----------------------------------------------------------------------------
   TradingView style, ONE rule for every tool: a PANEL SET is a layout
   container that holds panels. It lays its panels out with
   gap: var(--panel-gap) and paints var(--panel-gap-bg) behind them, so the
   only thing between two neighbouring panels is that gap. Panels stretch
   and squeeze to fill the set until they meet their neighbour: a panel
   keeps no margin, no outer ring or edge border and no inset of its own
   (lines INSIDE a panel, table heads and row lines, stay as they were).

     --panel-gap      the gap, one value everywhere (tokens.css)
     --panel-gap-bg   the gutter colour, both themes (tokens.css)

   §1 is the rule. §2 is the registry: the one list of panel sets (and the
   panels in them that had no surface of their own, which take the surface
   they used to sit on). A new tool joins the system by adding its set
   to the §2 lists, never with its own margins or divider lines.

   Panels docked with position:fixed (the app shell sidebar, the chart
   view's header, drawing tools, Key Stats and order column) cannot sit in a
   flex or grid set; §3 offsets them by the same --panel-gap with the gutter
   colour on the body, so they read the same. The chart and its indicator
   panes are ONE panel: nothing here touches the inside of .charts.

   Outer window edges stay flush (no gap against the viewport). Every rule
   is scoped :root:not(.phone), so the phone layout (77-phone.css) is
   untouched. SHARED: scripts/sync_shared_assets.py copies this file
   byte-identical to eva/app/web/panel-gaps.css for eva's iframed pages
   (which load it for widths over 640px only; eva has no .phone class).
   APPENDED LAST in app.html: it overrides spacing owned by earlier files.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── §1 THE RULE ───────────────────────────────────────────────────────── */
/* A panel set: gap between its panels, gutter colour behind them. */
:root:not(.phone) :is(
  .mpt:not(.mpt-pane),                     /* table pages: bar / filters / table  */
  .mpt:not(.mpt-pane) > .mpt-body,         /* table | side panel                  */
  .anr-inner.anr-stock,                    /* stock Analysts: bar / panels        */
  .anr-stock .anr-scroll,                  /*   summary row / coverage            */
  .anr-stock .anr-top,                     /*   consensus | ratings | targets     */
  #command-center .cc-canvas,              /* watchlist board: session / grid     */
  #command-center .cc-canvas > .cc-layout, /*   the board's panel grid            */
  .hm-inner,                               /* heatmap: bar / map                  */
  .um-page,                                /* consoles: top bar / page            */
  .stf-page .um-wrap, .stf-stats, .stf-grid, .stf-side,      /* traffic           */
  .dq-page .um-wrap, #data-quality-root, .dq-panels,         /* data quality      */
  .wks-grid,                               /* workspace pane grid                 */
  .hm-main, .hm-grid, .hm-row-split        /* eva: supply chain situation room    */
){
  gap:var(--panel-gap)!important;
  padding:0!important;
  align-items:stretch!important;
  background:var(--panel-gap-bg)!important;
}
/* Its panels: no margin, no outer ring or edge border; they fill the set. */
:root:not(.phone) :is(
  .mpt:not(.mpt-pane) > :is(.mpt-bar, .mpt-body, .nsc-fp, .nsc-crit, .blt-strip, .sc-filters),
  .mpt:not(.mpt-pane) > .mpt-body > :is(.mpt-scroll, .mpt-side),
  .anr-inner.anr-stock > :is(.anr-head, .anr-scroll),
  .anr-stock .anr-scroll > *, .anr-stock .anr-top > *,
  #command-center .cc-canvas > *, #command-center .cc-layout > *,
  #command-center .cc-layout > .cc-xgraph > .cc-section,
  .hm-inner > :is(.hm-bar, .hm-map),
  .um-page > *,
  .stf-page .um-wrap > *, .stf-stats > *, .stf-grid > *, .stf-side > *,
  .dq-page .um-wrap > *, #data-quality-root > *, .dq-panels > *,
  .hm-main > :is(.hm-masthead, .hm-grid), .hm-grid > *, .hm-row-split > *
){
  margin:0!important;
  border:0!important;
  box-shadow:none!important;
}

/* ── §2 Panels that had no surface of their own take the one they sat on ─ */
:root:not(.phone) .mpt:not(.mpt-pane) > :is(.mpt-bar, .nsc-crit),
:root:not(.phone) .mpt:not(.mpt-pane) > .mpt-body > .mpt-scroll{background-color:var(--mpt-bg);}
:root:not(.phone) .anr-inner.anr-stock > .anr-scroll{background-color:var(--bg-primary);}
/* The stock Analysts header row is a panel like the ones under it: their
   surface and their inset, so its title no longer sits on the sidebar's
   edge (owner 2026-10-17). */
:root:not(.phone) .anr-inner.anr-stock > .anr-head{background-color:var(--anr-panel);padding-left:var(--anr-pad);}
:root:not(.phone) .anr-stock .anr-scroll{background-color:var(--panel-gap-bg);}
:root:not(.phone) .hm-inner > .hm-bar{background-color:var(--bg-primary);}
:root:not(.phone) .um-page > :not(.um-topbar){flex:1 0 auto;background-color:var(--bg-primary);}
:root:not(.phone) :is(.stf-page, .dq-page) .um-wrap{background-color:var(--panel-gap-bg);}
:root:not(.phone) .hm-main > .hm-masthead{background-color:var(--bg-primary);padding:26px 26px 22px;max-width:none;}
:root:not(.phone) .hm-main > .hm-grid{max-width:none;}
/* eva's situation room panels were 74% see-through over the page; over the
   gutter they take that same colour, made solid. */
:root:not(.phone) .hm-grid{--hm-panel:color-mix(in srgb, var(--bg-secondary) 74%, var(--bg-primary));}
/* The last panel of a column runs to the column's end (no gutter tail). */
:root:not(.phone) :is(.stf-side, .anr-stock .anr-scroll) > :last-child{flex-grow:1;}
/* Sets that were not flex or grid boxes become columns. */
:root:not(.phone) :is(.um-page, .stf-page .um-wrap, .dq-page .um-wrap){display:flex;flex-direction:column;}
:root:not(.phone) .hm-main{display:flex;flex-direction:column;}

/* Table pages: the table's top meets the panel above at the gap. The old
   hairline over the table (and the side panel's left divider) are gone;
   the one line under the column head stays, drawn by the scroller itself
   so it still runs under the scrollbar gutter, and on the side panel's
   head strip, so the line is the same y across both panels. */
:root:not(.phone) .mpt:not(.mpt-pane) > .mpt-body::before{content:none;}
:root:not(.phone) .mpt:not(.mpt-pane) > .mpt-body:has(> .mpt-scroll > table:first-child > thead, > .mpt-scroll > :first-child > table:first-child > thead){background-image:none;}
:root:not(.phone) .mpt:not(.mpt-pane) > .mpt-body:has(> .mpt-scroll > table:first-child > thead, > .mpt-scroll > :first-child > table:first-child > thead) > .mpt-scroll{
  background-image:linear-gradient(var(--border-default), var(--border-default));
  background-repeat:no-repeat;background-size:100% 1px;
  background-position:0 calc(var(--mpt-colhead) - 1px);
}
:root:not(.phone) .mpt:not(.mpt-pane) > .mpt-body > .mpt-side::before{box-shadow:inset 0 -1px 0 var(--border-default)!important;}

/* ── §3 Fixed docks: same gap, same gutter (the body paints it) ────────── */
/* App shell: sidebar | page. */
/* Loading (owner 2026-10-17: "the loading screen of the chatbot page is
   gray"). Until a view has panels the page must not show the gutter. The
   body only paints it once .main is parsed (while the sidebar streams in
   first, the page keeps its --bg-primary). Every view then boots as
   body.no-charts (app.html) with an empty .main, so .main
   keeps the surface it showed before the panel system (--bg-primary) on
   every non chart view. Panel sets inside it paint their own gutter, and
   the sidebar seam and the docked Chat Bot seam are .main's margins, so
   they still show the body's gutter. The chart view's seams sit inside
   .main, so there it stays see-through. */
/* Owner 2026-10-17 ("put that back"): the body keeps its ORIGINAL
   background at all times, so no loading screen ever shows the gutter.
   The sidebar seam (and the docked Chat Bot seam) is painted by .main
   itself as a gap wide shadow into its own margin; only the chart view,
   whose seams sit inside .main, paints the gutter behind its panels. */
:root:not(.phone) body:has(> aside.sidebar) > .main{box-shadow:calc(-1 * var(--panel-gap)) 0 0 0 var(--panel-gap-bg);}
:root:not(.phone) body:not(.no-charts):not(.chart-zen):has(> aside.sidebar) > .main{background:var(--panel-gap-bg);}
:root:not(.phone) body.chart-zen > .main{box-shadow:none;}
/* A seam is the gap and nothing else: a panel's own edge line next to the
   gap would add a pixel to it (owner 2026-10-17, measured: the chart's
   seams were 4 to 5px, the table pages' 3px). The sidebar's outer edge
   line goes wherever it meets the gap; it stays where the open sidebar
   floats over the page (900px down). */
:root:not(.phone) .sidebar::after{background:transparent;}
@media(max-width:900px){
  :root.sb-open:not(.phone) .sidebar::after{background:var(--border-sidebar);}
}
/* The sidebar's edge is a clip-path edge, which is antialiased, not snapped
   like a box edge: on a fractional --sidebar-w (rem and vw based) its last
   column blends into the gutter and that seam read about half a pixel
   wider than the rest (measured 3.5px at 1440). Its widths are rounded to
   whole device pixels so the edge lands on a pixel. Same values as 01, 08
   and 39, rounded; behind @supports so an older browser keeps them as is. */
@supports (width:round(1px, 1px)){
  :root:not(.phone){--px-snap:1px;--rail-w:round(4rem, var(--px-snap));--sidebar-w:round(clamp(11.25rem, 14.5vw, 13.75rem), var(--px-snap));}
  @media (min-resolution:1.2dppx) and (max-resolution:1.3dppx){ :root:not(.phone){--px-snap:0.8px;} }
  @media (min-resolution:1.45dppx) and (max-resolution:1.55dppx){ :root:not(.phone){--px-snap:calc(2px / 3);} }
  @media (min-resolution:1.95dppx) and (max-resolution:2.05dppx){ :root:not(.phone){--px-snap:0.5px;} }
  @media (max-width:900px){ :root:not(.phone){--sidebar-w:round(15rem, var(--px-snap));} }
  @media (max-width:640px){ :root:not(.phone){--sidebar-w:180px;} }
}
:root:not(.phone) body:has(> aside.sidebar) > .main{margin-left:calc(var(--rail-w) + var(--panel-gap));}
:root.sb-open:not(.phone) body:has(> aside.sidebar) > .main{margin-left:calc(var(--sidebar-w) + var(--panel-gap));}
@media(max-width:900px){
  :root.sb-open:not(.phone) body:has(> aside.sidebar) > .main{margin-left:calc(var(--rail-w) + var(--panel-gap));}
}
/* Zen hides the sidebar: the chart takes the window edge (08's !important). */
:root:not(.phone) body.chart-zen > .main{margin-left:0!important;}

/* The docked Chat Bot panel's seams (page | chat, ticket | chat) and the
   Ask page's panels (history | chat | right panel) live in
   44-research-chat.css, which owns the chat namespace; its rules are one class more
   specific than the dock rules below, so they win while it is docked. */

/* Chart view: header / drawing tools / chart / Key Stats / order column.
   The chart and its indicator panes are one panel: no gap inside .charts. */
:root:not(.phone) body:not(.no-charts):not(.chart-zen) .charts{margin-top:var(--panel-gap);}
/* The docks' own edge lines (header rule, the tools column's hairlines, the
   Key Stats and order column left borders) would widen the seams they sit
   on; the gap alone separates them, as on the table pages. */
:root:not(.phone) body:not(.no-charts):not(.chart-zen) .hdr{border-bottom:0;}
:root:not(.phone) body:not(.no-charts):not(.chart-zen) #chart-rail{box-shadow:none;}
@media (min-width:721px){
  :root:not(.phone) .ksd-panel,
  :root:not(.phone) .trade-rail,
  :root:not(.phone) .trade-drawer{border-left:0;}
}
:root:not(.phone) body:not(.no-charts):not(.chart-zen) #chart-rail,
:root:not(.phone) body:not(.no-charts):not(.chart-zen) .trade-rail,
:root:not(.phone) body:not(.no-charts):not(.chart-zen) .trade-overlay,
:root:not(.phone) body:not(.no-charts):not(.chart-zen) .ksd-panel{top:calc(var(--header-h) + var(--panel-gap));}
/* Drawing tools column | chart. While the sidebar push runs (app.js
   pushMain, body.sb-pushing) the chart is pinned wide and runs under the
   column (04-header.css), so the column paints the gap itself. */
:root:not(.phone) body.sb-pushing #chart-rail{box-shadow:var(--panel-gap) 0 0 0 var(--panel-gap-bg);}
:root:not(.phone) body:not(.chart-zen) .charts{margin-left:calc(var(--chart-rail-w) + var(--panel-gap));}
:root:not(.phone) body.mc-grid-active .charts{margin-left:var(--chart-rail-w);}
/* The Graphs drawer (09) docks between the sidebar and the tools column:
   one gap on each side, no edge lines or cast shadow of its own. */
:root:not(.phone) #gtb-modal.gtb-drawer{left:calc(var(--rail-w) + var(--panel-gap));}
:root.sb-open:not(.phone) #gtb-modal.gtb-drawer{left:calc(var(--sidebar-w) + var(--panel-gap));}
@media(max-width:900px){ :root.sb-open:not(.phone) #gtb-modal.gtb-drawer{left:calc(var(--rail-w) + var(--panel-gap));} }
:root:not(.phone) #gtb-modal.gtb-drawer .gtb-modal-card{border-left:0;border-right:0;box-shadow:none;}
:root:not(.phone) #gtb-modal.gtb-drawer.open .gtb-modal-card{box-shadow:none;}
:root:not(.phone) body.gtb-open #chart-rail{left:calc(var(--ss-w) + var(--panel-gap));}
/* The drawer floats over the chart, so the tools column paints that gap. */
:root:not(.phone) body.gtb-open:not(.chart-zen) #chart-rail{box-shadow:calc(-1 * var(--panel-gap)) 0 0 0 var(--panel-gap-bg);}
/* Chart | right column. --dock-r is the chart's right reservation (12, 13):
   each docked column adds its width plus one gap. */
:root:not(.phone) body{--dock-r:calc(var(--trade-rail-w) + var(--panel-gap));}
:root:not(.phone) body.trade-open{--dock-r:calc(var(--trade-w) + var(--panel-gap));}
:root:not(.phone) body.ksd-open{--dock-r:calc(var(--trade-rail-w) + var(--ksd-w) + 2 * var(--panel-gap));}
:root:not(.phone) body.ksd-open.trade-open{--dock-r:calc(var(--trade-w) + var(--ksd-w) + 2 * var(--panel-gap));}
:root:not(.phone) body.chart-zen{--dock-r:0;}
/* Key Stats dock | order column: the dock stops one gap short of it. */
:root:not(.phone) .ksd-panel{right:calc(var(--trade-rail-w) + var(--panel-gap));}
:root:not(.phone) body.trade-open .ksd-panel{right:calc(var(--trade-w) + var(--panel-gap));}
:root:not(.phone) .ksd-panel{transform:translateX(calc(100% + var(--trade-rail-w) + var(--panel-gap) + 4px));}
:root:not(.phone) .ksd-panel.open{transform:none;}
:root:not(.phone) body.trade-open .ksd-panel:not(.open){transform:translateX(calc(100% + var(--trade-w) + var(--panel-gap) + 4px));}
/* Narrow (721px down): the ticket and the dock become sheets over the chart
   (12, 13), so they reserve no gap; only the rail strip keeps its seam. */
@media (max-width:720px){
  :root:not(.phone) body.trade-open{--dock-r:0;}
  :root:not(.phone) body.ksd-open{--dock-r:calc(var(--trade-rail-w) + var(--panel-gap));}
  :root:not(.phone) body.ksd-open.trade-open{--dock-r:0;}
  :root:not(.phone) .ksd-panel,
  :root:not(.phone) body.trade-open .ksd-panel{right:0;}
  :root:not(.phone) body.trade-open .ksd-panel:not(.open){transform:translateX(calc(100% + 4px));}
}

/* Workspaces: top bar over the pane grid (the grid itself is a §1 set;
   workspace.js reads its gap and padding back from CSS). */
:root:not(.phone) .wks-surface:has(.wks-pane){background:var(--panel-gap-bg);}
/* While the workspace loads (no pane yet) the stage keeps its own surface
   (49: --bg-sink), not an empty gutter
   (#wks-root, app.html: the §1 list's specificity is an id's.) */
:root:not(.phone) #wks-root:not(:has(.wks-pane)) .wks-grid{background:transparent!important;}
:root:not(.phone) .wks-stage{margin-top:var(--panel-gap);}
/* Panes meet at the grid's gap alone: their 1px ring (52-wks-start.css)
   made every pane seam 5px. The focused pane still shows by its lighter
   header strip (49-workspace.css). */
:root:not(.phone) .wks-pane::after{box-shadow:none;}

/* Stock Sources view: narrative column | feed. The view paints a texture
   under see-through panels, so the gutter is a hard band on the column's
   edge instead of a set background (same gap, same colour). */
:root:not(.phone) .sources-view > .sx-left{
  margin-right:var(--panel-gap);border-right:0;
  box-shadow:var(--panel-gap) 0 0 0 var(--panel-gap-bg);
}
