/* ===========================================================================
   OA_BLOCKS_v2 (2026-11-29) — block edges, elevation and the brand ramp,
   shared by FOUR separate documents:

     1. the dashboard        /opt/gamma_algo/dashboard/templates/index.html
     2. Strategy Lab         …/templates/strategy_lab.html        (iframe)
     3. Breakouts            …/templates/breakouts.html           (iframe)
     4. Backtest             /home/devbt/backtest/historical/templates/
                             backtest.html   (separate service, port 8092)

   Backtest, Strategy Lab and Breakouts are loaded by the dashboard as IFRAMES.
   A stylesheet in the parent never crosses into an iframe — which is the whole
   reason those three pages stayed fully amber after the v1 pass. They each get
   this same file linked in directly.

   Everything below is scoped by `html:root[data-theme="light"]` and by class/id
   names that are unique to one app, so one file can serve all four without
   the sections interfering.

   WHY THE EDGE IS NOT #F5F5F7
   ---------------------------
   v1 used #F5F5F7 literally, as asked. Against a #FFFFFF card on a #FFFFFF
   page that is a 1.5% lightness step — mathematically a border, visually
   nothing, which is why the report came back "no grey edge". The outline is
   #E6E6EC here: still a quiet hairline, but one you can actually see. The
   #F5F5F7 the user picked is kept for the places where it works — internal
   dividers and the Option Chain gridlines, which sit against tinted rows.
   ========================================================================= */

html:root[data-theme="light"]{
  --oa-edge:       #E6E6EC;   /* block outline — visible grey */
  --oa-edge-soft:  #F5F5F7;   /* internal dividers, gridlines */
  --oa-rule:       rgba(17,24,39,.07);

  --shadow-soft:
      0 1px 2px rgba(17,24,39,.05),
      0 4px 10px -2px rgba(17,24,39,.07),
      0 16px 32px -14px rgba(17,24,39,.09);
  --oa-block-sh: var(--shadow-soft);
  --oa-block-sh-hover:
      0 1px 2px rgba(17,24,39,.06),
      0 6px 14px -3px rgba(17,24,39,.10),
      0 22px 44px -16px rgba(17,24,39,.13);
}

/* The brand ramp, one definition for every document. */
html{
  --oa-ramp:  linear-gradient(135deg,#ffc130 0%,#ff7a3c 52%,#ff3ead 100%);
  --oa-ramp-h:linear-gradient(90deg,#ffc130 0%,#ff7a3c 55%,#ff3ead 100%);
}
html:root[data-theme="light"]{
  --oa-ramp:  linear-gradient(135deg,#f0a21a 0%,#f05a26 52%,#e02b8e 100%);
  --oa-ramp-h:linear-gradient(90deg,#f0a21a 0%,#f05a26 55%,#e02b8e 100%);
}

/* ===========================================================================
   1 · THE DASHBOARD  (templates/index.html)
   ========================================================================= */

html:root[data-theme="light"]{
  --card-border: var(--oa-edge);
  --divider:     var(--oa-edge-soft);
  --vi-border:   var(--oa-edge);
  --gl-border-0: rgba(17,24,39,.05);
  --gl-border-1: rgba(17,24,39,.08);
}

/* Blocks. v1 scoped this to .view-india / .view-mkt; the report says the
   other views merge too, so the scoping is gone — every light-theme block on
   the dashboard gets the same edge and the same lift. */
html:root[data-theme="light"] body :is(
  .card, .card-sm, .ana-tool, .g-card, .gex-chart-card, .gex-exp-tbl,
  .gr-block, .stri-wrap, .stri-chartcard, .ev-block, .ms-gridwrap,
  .ms-heatgroup, .pb-card, .vs-stat, .mc-card, .ath-card
){
  border: 1px solid var(--oa-edge) !important;
  box-shadow: var(--oa-block-sh) !important;
}
html:root[data-theme="light"] body :is(
  #expected-move-banner, #gex-regime-card, #gom-table-card,
  #max-pain-visual-card, #oc-hdrbar, #oi-change-card, #oib-card-strike,
  #oib-card-trend, #oicc-card, #pcr-trend-card, #synopsis-card,
  #oi-analysis-section, #gex-oi-monitor-section, #news-nse-block,
  #vol-surface-section, #pcr-spot-section, #volume-section, #iv-section
){
  border: 1px solid var(--oa-edge) !important;
  box-shadow: var(--oa-block-sh) !important;
}
html:root[data-theme="light"] body :is(.card,.card-sm,.ana-tool,.gex-chart-card)[onclick]:hover,
html:root[data-theme="light"] body :is(.card,.card-sm,.ana-tool,.gex-chart-card).gx-clickable:hover{
  box-shadow: var(--oa-block-sh-hover) !important;
}

/* Tiles and rows INSIDE a block: edge only. Stacking an elevation inside an
   elevated card reads as mud, not depth. */
html:root[data-theme="light"] body :is(
  .ev-row, .mpc-tile, .mpc-event, .g-controls, .gex-0dte-stat, .stri-tile,
  .wmkt-cell, .wrisk-chip, .ana-tool-hdr, .gex-adv-hdr, .aiv1, .aiv2, .aiv3,
  .al, #pcr-spot-interp, .badge
){
  border-color: var(--oa-edge-soft) !important;
}
html:root[data-theme="light"] .algo-nd-menu{ border-color: var(--oa-edge-soft) !important; }

/* Option Chain gridlines — flattened to #F5F5F7 as asked. */
html:root[data-theme="light"] table.oc-rich tbody td{ border-bottom-color: #F5F5F7 !important; }
html:root[data-theme="light"] table.oc-rich thead th{ border-color: #F5F5F7 !important; }
html:root[data-theme="light"] table.oc-rich tr.oc-ltp-row td{
  border-top-color: rgba(17,24,39,.14) !important;
  border-bottom-color: rgba(17,24,39,.14) !important;
}
/* The other data tables keep a neutral slate at matched weight: these are row
   separators in dense grids and #F5F5F7 would not separate anything. */
html:root[data-theme="light"] body :is(
  .ana-tbl tbody td, #gom-table tbody tr, #os-table tbody tr, #ss-table tbody tr
){ border-color: var(--oa-rule) !important; }

/* The inline-style translation layer: dash-a rewrites every dark-theme inline
   rgba(255,255,255,…) border into amber for light theme. Same alphas, neutral. */
html:root[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.06)"]  { border-color: rgba(17,24,39,.07) !important; }
html:root[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.08)"]  { border-color: rgba(17,24,39,.08) !important; }
html:root[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.1)"]   { border-color: rgba(17,24,39,.09) !important; }
html:root[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.12)"]  { border-color: rgba(17,24,39,.10) !important; }
html:root[data-theme="light"] [style*="border-bottom:1px solid rgba(255,255,255"] { border-bottom-color: rgba(17,24,39,.07) !important; }
html:root[data-theme="light"] [style*="border-top:1px solid rgba(255,255,255"]    { border-top-color: rgba(17,24,39,.07) !important; }
html:root[data-theme="light"] [style*="border-left:1px solid rgba(255,255,255"]   { border-left-color: rgba(17,24,39,.07) !important; }

/* Id-anchored amber the rules above cannot out-rank by shape alone. */
html:root[data-theme="light"] body.view-india #greeks-section :is(.g-card, .g-controls),
html:root[data-theme="light"] body :is(#glab-vol-wrap, #glab-oid-wrap, #glab-heat-table-wrap),
html:root[data-theme="light"] body :is(#gex-advanced-section, #gex-oi-monitor-section, #gammagex-panel),
html:root[data-theme="light"] body #gammagex-panel > div,
html:root[data-theme="light"] body #gex-advanced-section :is(.gex-chart-card, .gex-adv-stat, .gex-0dte-stat, .gex-exp-tbl),
html:root[data-theme="light"] body #gex-oi-monitor-section div[style*="rgba(255,255,255,0.08)"],
html:root[data-theme="light"] body #gex-oi-monitor-section div[style*="rgba(255,255,255,0.07)"],
html:root[data-theme="light"] body #gex-oi-monitor-section #gammagex-signals > div{
  border-color: var(--oa-edge) !important;
}
html:root[data-theme="light"] body.view-india #greeks-section .g-card{ box-shadow: var(--oa-block-sh) !important; }

/* Active controls → the brand ramp instead of flat amber. The report called
   these out by name on the Screeners tab; they are the same classes the
   Analysis sub-tabs and the Greeks Lab use, so they all move together. */
html:root[data-theme="light"] body :is(
  .glab-btn.on, .g-btn.on, .stri-pill.on, .gex-adv-btn.on, .oia-btn.active,
  .oicc-btn.active, .itab.on, .tab.on, .r2-ctab.on, .scr-tab.active,
  .mscr-tab.active, .mscr-seg.active, .mscr-f.active, .oc-rng.on
){
  background: var(--oa-ramp) !important;
  border-color: transparent !important;
  color: #fff !important;
}
html:root[data-theme="light"] body :is(.glab-btn.on, .g-btn.on, .stri-pill.on) *{ color:#fff !important; }

/* Global tab: give the gutter back (the Global layout rule sets margin:0
   !important, wiping the body-level 14px gutter on both sides). Desktop and
   tablet only — dash-b deliberately tightens this to 6px under 640px. */
body.view-mkt[data-mko-sec="global"] #world-section{
  margin-left: 14px !important;
  margin-right: 14px !important;
  max-width: calc(100% - 28px) !important;
}

/* ===========================================================================
   2 · STRATEGY LAB  (templates/strategy_lab.html — iframe)
   Its own palette: --border / --line / --line2 were all rgba(255,176,32,…),
   and .metric — the Max profit / Max loss / Risk:reward row — was #EDE9FF,
   a leftover lavender from before the de-purpling. None of the blocks had a
   shadow.
   ========================================================================= */
html:root[data-theme="light"]{
  --border:  #E6E6EC;
  --line:    #E6E6EC;
  --line2:   #DCDCE4;
}
html:root[data-theme="light"] :is(.scard, .llm-kpi, .metric, .mkt-cell, .leg, .sbadge, .chip, .bs, .card){
  border-color: var(--oa-edge) !important;
}
html:root[data-theme="light"] :is(.scard, .llm-kpi, .metric, .card){
  box-shadow: var(--oa-block-sh) !important;
}
/* the purple block */
html:root[data-theme="light"] .metric{ background: #FFFFFF !important; }
html:root[data-theme="light"] .scard:hover{ box-shadow: var(--oa-block-sh-hover) !important; }

/* ===========================================================================
   3 · BACKTEST  (/home/devbt/backtest/historical/templates/backtest.html —
   separate service on :8092)
   The four numbered config cards and the parameter panel had no shadow at
   all, and the 32-item strategy rail plus every button carried an amber edge.
   ========================================================================= */
html:root[data-theme="light"] :is(
  #cfg-card-instrument, #cfg-card-period, #cfg-card-fees, #cfg-card-strategy,
  #params-group, #empty-state, #results-card, #bt-chart-card
){
  border: 1px solid var(--oa-edge) !important;
  box-shadow: var(--oa-block-sh) !important;
}
html:root[data-theme="light"] :is(.nav-item, .icon-btn, #user-btn, .seg-opt, .cfg-card){
  border-color: var(--oa-edge) !important;
}
html:root[data-theme="light"] .nav-item:hover{ border-color:#D7D7E0 !important; }
/* the selected strategy in the rail, and the selected segment pills (1Y, 5min) */
html:root[data-theme="light"] :is(.nav-item.active, .nav-item.on, .seg-opt.active, .seg-opt.on){
  background: var(--oa-ramp) !important;
  border-color: transparent !important;
  color: #fff !important;
}
html:root[data-theme="light"] :is(.nav-item.active, .nav-item.on) *,
html:root[data-theme="light"] :is(.seg-opt.active, .seg-opt.on) *{ color:#fff !important; }

/* ===========================================================================
   4 · BREAKOUTS  (templates/breakouts.html — iframe)
   Its --line is already neutral, so the blocks were fine; the complaint was
   the charts. The flat amber card sparklines are handled in the template
   itself (OA_BRAND_RAMP_v1) because an SVG stroke gradient needs a paint
   server, which CSS alone cannot supply. What is left here is the chrome.
   ========================================================================= */
html:root[data-theme="light"] :is(.bk-card, .rcard, .brk-card){
  box-shadow: var(--oa-block-sh) !important;
}
html:root[data-theme="light"] :is(.pill.on, .tab.on, .fbtn.on, .seg.on){
  background: var(--oa-ramp) !important;
  border-color: transparent !important;
  color:#fff !important;
}

/* ===========================================================================
   5 · THE SURFACE LAYERS  (all four documents)
   --bg3 / --bg4 are the "elevated" and "row tint" layers every app paints its
   chips, inputs, tab strips and table stripes with. They were tinted, not
   neutral — lavender #EDE9FF / #F8F6FF in Strategy Lab (the strip behind the
   P&L / Greeks / IV tabs, the symbol and spot fields, the leg rows), warm
   cream #F6F3EE / #FAF8F4 on the dashboard. One pair of neutral greys at the
   same lightness takes the cast out of all of them at once.
   ========================================================================= */
html:root[data-theme="light"]{
  --bg3: #F1F1F5;
  --bg4: #F8F8FB;
}

/* ===========================================================================
   6 · MARKET SCREENER CONTROLS  (Market Overview → Screeners)
   "Equity & Futures", "Stocks (0)", "All" were flat #e8940a. They take the
   ramp like every other active control.
   ========================================================================= */
html:root[data-theme="light"] body :is(.ms-tab.on, .ms-chip.on, .ms-sub .on, .ms-sub button.on),
html:root[data-theme="dark"]  body :is(.ms-tab.on, .ms-chip.on, .ms-sub .on, .ms-sub button.on){
  background: var(--oa-ramp) !important;
  border-color: transparent !important;
  color: #fff !important;
}
html:root body :is(.ms-tab.on, .ms-chip.on) *{ color:#fff !important; }
html:root[data-theme="light"] body :is(.ms-tab, .ms-chip, .ms-search, .ms-refresh){
  border-color: var(--oa-edge) !important;
}

/* ===========================================================================
   7 · THE MARKET OVERVIEW KPI TILES
   #market-extras-row's tiles took the new border but kept box-shadow:none:
   dash-a carries a long `box-shadow:none !important` selector list that
   includes id-anchored members, and an id outranks the class list above.
   Matched here with the ids, and with a literal shadow rather than the token
   so there is one less thing in the chain that can fail.
   ========================================================================= */
html:root[data-theme="light"] body #market-extras-row > :is(.card, .card-sm),
html:root[data-theme="light"] body :is(
  #card-vix, #card-giftnifty, #card-niftyfut, #card-risk, #card-advdecline,
  #card-sectorheatmap, #card-feargreed, #card-btcfunding, #card-ofalerts,
  #card-optscreener, #card-stockscreener, #card-windices, #card-wcommod, #card-wfx
){
  border: 1px solid #E6E6EC !important;
  box-shadow:
      0 1px 2px rgba(17,24,39,.05),
      0 4px 10px -2px rgba(17,24,39,.07),
      0 16px 32px -14px rgba(17,24,39,.09) !important;
}

/* "Load" on the ticker strip was the last flat-amber control. */
html:root body #mko-ticker-go{
  background: var(--oa-ramp) !important;
  border-color: transparent !important;
  color: #fff !important;
}
