/* SigmaWay palette: navy #001C47, teal #1CC0BD / #55D7DA, deep teal #0E8F8D, pale blue #EEF3FA / #DBE4F2,
   grey text #666, accent orange #E07A1F. Headings Raleway, body Roboto. */
:root {
  --navy: #001C47; --navy-2: #0A2A5C; --teal: #1CC0BD; --teal-2: #55D7DA; --teal-3: #0E8F8D; --orange: #E07A1F;
  --bg: #EEF3FA; --card: #FFFFFF; --line: #DBE4F2; --text: #1F2A3D; --muted: #5B6475; --soft: #F5F8FC;
  --up: #0E8F8D; --down: #C8414B; --warn: #E07A1F; --side: #001C47; --side-text: #C9D6EA;
  --shadow: 0 1px 2px rgba(0, 28, 71, .06), 0 4px 16px rgba(0, 28, 71, .05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #071226; --card: #0D1C36; --line: #1B2E52; --text: #E6EDF7; --muted: #93A1BA; --soft: #0A1830;
  --up: #3AD6C3; --down: #FF6B76; --side: #020B1C; --side-text: #A9B8D0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Roboto, system-ui, sans-serif; }
h1, h2, h3, .brand { font-family: Raleway, Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 6px; font-weight: 600; }
a { color: var(--teal-3); text-decoration: none; }
:root[data-theme="dark"] a { color: var(--teal-2); }
.mono, code, pre, td.num, .num { font-family: "Roboto Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .tiny { font-size: 11px; } .small { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 16px 12px;
        position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 17px; padding: 4px 8px 18px; }
.brand b { color: var(--teal); }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--teal); color: var(--navy); display: grid;
        place-items: center; font-weight: 700; }
nav a { display: flex; align-items: center; justify-content: space-between; color: var(--side-text); padding: 8px 10px;
        border-radius: 8px; margin: 2px 0; font-weight: 500; }
nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
nav a.on { background: rgba(28, 192, 189, .16); color: #fff; box-shadow: inset 3px 0 0 var(--teal); }
nav .badge { background: var(--orange); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; }
nav .sep { border-top: 1px solid rgba(255, 255, 255, .08); margin: 10px 4px; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 8px; }
.side-foot .ghost { color: var(--side-text); border-color: rgba(255, 255, 255, .15); }

main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px;
       border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; }
.crumbs { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
#view { padding: 18px 22px 40px; display: grid; gap: 16px; }
#banner:empty { display: none; }
#banner { margin: 12px 22px 0; }

body.popout .shell { grid-template-columns: 1fr; }
body.popout .side, body.popout #popBtn { display: none; }
body.popout .top { padding: 8px 14px; }
body.popout #view { padding: 12px 14px; }
body.popout h1 { font-size: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 14px 16px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: grid; gap: 2px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font: 600 22px/1.2 "Roboto Mono", monospace; }
.kpi .sub { font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--soft); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--soft); }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }
td.wrap { white-space: normal; min-width: 220px; }

button, .btn { font: 500 13px Roboto, sans-serif; border-radius: 8px; padding: 7px 14px; cursor: pointer;
               border: 1px solid var(--teal-3); background: var(--teal-3); color: #fff; display: inline-flex;
               align-items: center; gap: 6px; }
button:hover, .btn:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--down); border-color: var(--down); }
button.warnb { background: var(--orange); border-color: var(--orange); }
button.small, .btn.small { padding: 4px 10px; font-size: 12px; }
input, select, textarea { font: 14px Roboto, sans-serif; padding: 7px 10px; border: 1px solid var(--line);
                           border-radius: 8px; background: var(--card); color: var(--text); min-width: 0; }
textarea { width: 100%; resize: vertical; }
textarea.code { font: 13px/1.5 "Roboto Mono", monospace; min-height: 320px; tab-size: 4; background: var(--soft); }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1 1 120px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px;
        border: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--up); } .pill.bad .dot { background: var(--down); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 500;
       text-transform: uppercase; letter-spacing: .03em; background: var(--soft); border: 1px solid var(--line); }
.tag.BUY, .tag.placed, .tag.live { background: rgba(14, 143, 141, .12); color: var(--up); border-color: transparent; }
.tag.SELL, .tag.failed, .tag.rejected, .tag.error { background: rgba(200, 65, 75, .12); color: var(--down); border-color: transparent; }
.tag.pending, .tag.paper, .tag.running, .tag.queued { background: rgba(224, 122, 31, .14); color: var(--warn); border-color: transparent; }

.notice { border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line); background: var(--card); }
.notice.ok { border-color: var(--teal); } .notice.bad { border-color: var(--down); color: var(--down); }
.notice.warn { border-color: var(--orange); }

/* Strategy pipeline */
.board { display: grid; grid-template-columns: repeat(7, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.lane { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 120px; }
.lane h3 { display: flex; justify-content: space-between; text-transform: uppercase; font-size: 12px; letter-spacing: .05em; color: var(--muted); }
.scard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px;
         display: grid; gap: 6px; cursor: pointer; }
.scard:hover { border-color: var(--teal); }
.scard .name { font-weight: 600; font-family: Raleway, sans-serif; line-height: 1.3; }
.scard .m { display: flex; gap: 10px; font-size: 12px; }
.stages { display: flex; gap: 4px; flex-wrap: wrap; }
.stages button { border-radius: 99px; }
.stages button.cur { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .stages button.cur { background: var(--teal); color: var(--navy); }
.timeline { display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.ev { border-left: 3px solid var(--line); padding: 2px 10px; }
.ev.stage { border-color: var(--teal); } .ev.backtest { border-color: var(--navy-2); }
.ev.error { border-color: var(--down); } .ev.signal, .ev.paper { border-color: var(--orange); }
pre.err { white-space: pre-wrap; color: var(--down); background: var(--soft); padding: 10px; border-radius: 8px; font-size: 12px; }

.chart { width: 100%; height: 260px; display: block; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--muted); font: 11px Roboto, sans-serif; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.spark { width: 100%; height: 44px; display: block; }

.monitors { display: grid; gap: 10px; }
.mon { display: grid; grid-template-columns: 1fr 200px auto; gap: 10px; align-items: center; padding: 10px;
       border: 1px solid var(--line); border-radius: 10px; }
.screens { display: flex; gap: 8px; flex-wrap: wrap; }
.screen { border: 2px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--soft); font-size: 12px; }

#toast { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 50; }
#toast div { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 420px; }
#toast div.bad { background: var(--down); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); } main, #view { min-width: 0; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  nav { display: flex; flex-wrap: wrap; } .side-foot { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .mon { grid-template-columns: 1fr; }
}

/* AI analyst */
.card.ai { border-left: 3px solid var(--teal); }
.ainote { border-top: 1px solid var(--line); padding: 10px 0; }
.ainote summary { cursor: pointer; font-size: 13px; }
.md { line-height: 1.6; padding: 8px 2px; }
.md h2, .md h3 { margin: 14px 0 6px; }
.md ul { margin: 6px 0; padding-left: 20px; }
pre.code-out { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto;
               font: 12px/1.5 "Roboto Mono", monospace; white-space: pre; }
input[type=file] { padding: 5px; }

/* strategy families, day trading, MF & SIP */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chips button.cur { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .chips button.cur { background: var(--teal); color: var(--navy); }
.tag.fam-position { background: rgba(0, 28, 71, .08); color: var(--navy); }
.tag.fam-swing { background: rgba(28, 192, 189, .14); color: var(--teal-3, #0E8F8D); }
.tag.fam-intraday { background: rgba(224, 122, 31, .14); color: var(--orange, #E07A1F); }
.tag.fam-mf { background: rgba(85, 215, 218, .18); color: #0b6b6a; }
:root[data-theme="dark"] .tag.fam-position { background: rgba(238, 243, 250, .1); color: var(--text); }
:root[data-theme="dark"] .tag.fam-mf { color: #55D7DA; }
label.inline { display: flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }

/* info bubbles */
.ib { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border-radius: 50%; border: 1px solid var(--teal-3); color: var(--teal-3); font: italic 700 10px/1 Georgia, serif;
  cursor: help; vertical-align: middle; margin-left: 3px; flex: none; }
:root[data-theme="dark"] .ib { border-color: var(--teal-2); color: var(--teal-2); }
.ib .ibt { visibility: hidden; opacity: 0; position: absolute; z-index: 50; left: -8px; top: calc(100% + 8px);
  width: max-content; max-width: min(320px, 78vw); white-space: normal; text-align: left;
  background: var(--navy); color: #EAF2FF; font: 400 12.5px/1.5 Roboto, sans-serif; font-style: normal;
  padding: 10px 12px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 28, 71, .25); transition: opacity .12s; pointer-events: none; }
.ib .ibt.left { left: auto; right: -8px; }
.ib:hover .ibt, .ib:focus .ibt, .ib:focus-within .ibt { visibility: visible; opacity: 1; }
:root[data-theme="dark"] .ib .ibt { background: #1B2E52; }
.plainbox { margin-top: 10px; padding: 10px 12px; background: var(--soft); border-left: 3px solid var(--teal); border-radius: 0 6px 6px 0; }
.tag.aip { background: rgba(28, 192, 189, .14); color: var(--teal-3); border-color: transparent; }

/* dashboards */
.dbar .row { align-items: end; }
.tiles { display: grid; gap: 14px; }
.tiles.c1 { grid-template-columns: 1fr; }
.tiles.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .tiles.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .tiles.c2, .tiles.c3 { grid-template-columns: 1fr; } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; min-width: 0; display: grid; gap: 6px; }
.tile.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--teal); } }
@media (prefers-reduced-motion: reduce) { .tile.flash { animation: none; box-shadow: 0 0 0 2px var(--teal); } }
.th { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.th .ts { width: 130px; font-weight: 700; text-transform: uppercase; }
.th .ti { width: auto; }
.th-px { font-family: "Roboto Mono", monospace; font-size: 13px; }
.grow { flex: 1; }
.pts { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.pt { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 3px 8px; font: 700 12px "Roboto Mono", monospace; min-height: 0; }
.pt.on { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .pt.on { background: var(--teal); color: var(--navy); }
.why { font-size: 12px; color: var(--muted); background: var(--soft); padding: 4px 8px; border-radius: 6px; }
.sigban { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; padding: 6px 8px; border-radius: 6px; margin-top: 2px; }
.sigban.b { background: rgba(14, 143, 141, .12); } .sigban.s { background: rgba(200, 65, 75, .12); } .sigban.i { background: var(--soft); }
.sigban button { margin-left: auto; }
.readout { min-height: 16px; font-family: "Roboto Mono", monospace; }
.tk { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--soft); display: grid; gap: 8px; }
.tk-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.tk-row label { flex: 1 1 90px; }
.seg { display: inline-flex; gap: 0; }
.seg button { border-radius: 0; } .seg button:first-child { border-radius: 6px 0 0 6px; } .seg button:last-child { border-radius: 0 6px 6px 0; }
.seg .on.b { background: var(--up); border-color: var(--up); color: #fff; } .seg .on.s { background: var(--down); border-color: var(--down); color: #fff; }

/* indicator charts */
svg.ta { width: 100%; height: auto; display: block; }
.ta .pbg { fill: var(--soft); }
.ta .gl { stroke: var(--line); stroke-width: 1; } .ta .gl.rz { stroke-dasharray: 3 3; }
.ta .ax { fill: var(--muted); font: 10.5px "Roboto Mono", monospace; }
.ta .pl { fill: var(--muted); font: 600 11px Roboto, sans-serif; }
.ta .cu { fill: var(--up); stroke: var(--up); } .ta .cd { fill: var(--down); stroke: var(--down); }
.ta .wk { stroke-width: 1; }
.ta .bb { fill: var(--teal); opacity: .08; }
.ta .l1, .ta .l2, .ta .l3, .ta .l4 { fill: none; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.ta .l1 { stroke: var(--teal); } .ta .l2 { stroke: var(--orange); } .ta .l3 { stroke: var(--navy-2); } .ta .l4 { stroke: #7B61FF; }
:root[data-theme="dark"] .ta .l3 { stroke: #A9C1E6; }
.ta .k1 { fill: var(--teal); } .ta .k2 { fill: var(--orange); } .ta .k3 { fill: var(--navy-2); } .ta .k4 { fill: #7B61FF; }
:root[data-theme="dark"] .ta .k3 { fill: #A9C1E6; }
.ta .vu { fill: var(--up); opacity: .45; } .ta .vd { fill: var(--down); opacity: .45; }
.ta .hp { fill: var(--up); opacity: .5; } .ta .hn { fill: var(--down); opacity: .5; }
.ta .mk { stroke: var(--card); stroke-width: 1; cursor: help; } .ta .mb { fill: var(--up); } .ta .ms { fill: var(--down); }
.ta .mk.exit { opacity: .55; }
.ta [class^="id-"] { stroke-width: 1.2; stroke-dasharray: 5 4; }
.ta .id-entry { stroke: var(--navy-2); } .ta .id-stop { stroke: var(--down); } .ta .id-target { stroke: var(--up); }
.ta .id-entryt { fill: var(--navy-2); stroke: none; } .ta .id-stopt { fill: var(--down); stroke: none; } .ta .id-targett { fill: var(--up); stroke: none; }
.ta .xh { stroke: var(--muted); stroke-dasharray: 2 3; }
.ta .hov { fill: transparent; pointer-events: none; }
body.popout .tiles.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* platform guide */
.gcheck { display: flex; flex-wrap: wrap; gap: 8px; }
.gc { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.gc.ok span { color: var(--up); font-weight: 700; } .gc.todo { border-color: var(--warn); } .gc.todo span { color: var(--warn); }
.gg { margin: 18px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.gcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.gcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.gh { display: flex; gap: 10px; align-items: flex-start; } .gh > div { flex: 1; min-width: 0; }
.gh h3 { margin: 0 0 2px; } .gi { width: 28px; height: 28px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; font-weight: 700; color: var(--teal-3); flex: none; }
.gsteps { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 13px; }
.gtips { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }

/* bonds */
.lbar { display: grid; grid-template-columns: 70px 1fr 110px; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.lbar > div { background: var(--soft); border-radius: 4px; height: 14px; overflow: hidden; } .lbar i { display: block; height: 100%; background: var(--teal-3, #14b8a6); border-radius: 4px; }
.lbar b { text-align: right; font-variant-numeric: tabular-nums; }
.bf { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--soft); display: grid; gap: 8px; }
.bsub td { background: var(--soft); } .warnc { color: var(--warn); } .tag.ai { background: var(--soft); }
table.compact td { padding: 5px 8px; }
.tw { overflow-x: auto; max-width: 100%; } .tw table { min-width: 1100px; }
#bt, #bt + * { min-width: 0; }
main { min-width: 0; }
#view { grid-template-columns: minmax(0, 1fr); }
html, body { overflow-x: clip; } table.compact { width: 100%; } #bcal { overflow-x: auto; }

/* ---------- grouped, animated menu ---------- */
:root { --ease: cubic-bezier(.2, .8, .2, 1); }
.shell { transition: grid-template-columns .3s var(--ease); }
.side { overflow: hidden; }
.side-top { display: flex; align-items: center; justify-content: space-between; }
#menuBtn { display: none; color: var(--side-text); border-color: rgba(255, 255, 255, .15); }
#nav { overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.navq { position: relative; margin: 0 0 10px; }
.navq input { width: 100%; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1); color: #fff; padding: 7px 28px 7px 10px; border-radius: 8px; font-size: 13px; transition: background .2s, border-color .2s; }
.navq input::placeholder { color: rgba(255, 255, 255, .45); }
.navq input:focus { outline: none; background: rgba(255, 255, 255, .12); border-color: var(--teal); }
.navq kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: rgba(255, 255, 255, .45); border: 1px solid rgba(255, 255, 255, .2); border-radius: 4px; padding: 0 5px; }
.ng { margin: 2px 0; }
.ngh { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: rgba(255, 255, 255, .55); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; transition: color .2s, background .2s; }
.ngh:hover { color: #fff; background: rgba(255, 255, 255, .05); } .ngh:focus-visible { outline: 2px solid var(--teal); }
.ngl { flex: 1; } .ngi { width: 18px; text-align: center; font-size: 13px; letter-spacing: 0; }
.chev { transition: transform .3s var(--ease); font-size: 15px; line-height: 1; }
.ng.open .chev { transform: rotate(90deg); }
.ngb { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s var(--ease); }
.ng.open .ngb { grid-template-rows: 1fr; }
.ngin { overflow: hidden; min-height: 0; }
.ngin > a { opacity: 0; transform: translateX(-6px); transition: opacity .25s, transform .3s var(--ease), background .15s, box-shadow .2s, color .15s; }
.ng.open .ngin > a { opacity: 1; transform: none; }
.ng.open .ngin > a:nth-child(2) { transition-delay: .03s, .03s, 0s, 0s, 0s; } .ng.open .ngin > a:nth-child(3) { transition-delay: .06s, .06s, 0s, 0s, 0s; }
.ng.open .ngin > a:nth-child(4) { transition-delay: .09s, .09s, 0s, 0s, 0s; } .ng.open .ngin > a:nth-child(n+5) { transition-delay: .12s, .12s, 0s, 0s, 0s; }
nav a { justify-content: flex-start; gap: 8px; padding: 7px 10px; }
nav a .nl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
nav a .ni { width: 18px; text-align: center; flex: none; }
nav a:hover { transform: translateX(2px); }
nav a.sub { padding-left: 22px; font-size: 13px; } nav a.sub .ni { opacity: .6; font-size: 11px; }
nav a.add { color: var(--teal); opacity: .85; } nav a.add:hover { opacity: 1; }
nav a.hide, .ng.hide { display: none; }
.ng-none { padding: 8px 10px; color: rgba(255, 255, 255, .5); }
#railBtn .ri { display: inline-block; transition: transform .3s var(--ease); }
/* collapsed rail */
body.rail .shell { grid-template-columns: 64px minmax(0, 1fr); }
body.rail .side { padding: 16px 8px; }
body.rail .bt, body.rail .nl, body.rail .ngl, body.rail .chev, body.rail .navq, body.rail .ngh .nb { display: none; }
body.rail .ngh { justify-content: center; padding: 6px 0; } body.rail .ngh .ngi { opacity: .5; }
body.rail .ng .ngb { grid-template-rows: 1fr; } body.rail .ngin > a { opacity: 1; transform: none; }
body.rail nav a { justify-content: center; padding: 8px 0; position: relative; } body.rail nav a.sub { padding-left: 0; }
body.rail nav a .badge { position: absolute; top: 0; right: 2px; font-size: 9px; padding: 0 4px; }
body.rail #railBtn .ri { transform: rotate(180deg); }
body.rail .brand { justify-content: center; padding: 4px 0 18px; }
body.rail .side-foot { padding: 8px 0; } body.rail .side-foot .ghost { padding: 6px 0; text-align: center; } body.rail #who { display: none; }
/* page change: gentle fade */
#view > * { animation: viewIn .28s var(--ease) both; }
#view > *:nth-child(2) { animation-delay: .03s; } #view > *:nth-child(3) { animation-delay: .06s; } #view > *:nth-child(n+4) { animation-delay: .09s; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* phone: menu folds into the top bar */
@media (max-width: 900px) {
  body.rail .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 30; height: auto; display: block; padding: 10px 14px; }
  #menuBtn { display: inline-block; }
  .side .brand { padding: 4px 0; }
  #nav { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); max-height: 70vh; overflow: hidden; margin: 0; }
  #nav > * { min-height: 0; }
  body.menu-open #nav { grid-template-rows: 1fr; overflow-y: auto; padding-top: 10px; }
  #nav { display: block; max-height: 0; transition: max-height .35s var(--ease), padding .35s; }
  body.menu-open #nav { max-height: 75vh; }
  body.rail .nl, body.rail .ngl, body.rail .chev, body.rail .navq, body.rail .bt { display: revert; }
  #railBtn { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .shell, .ngb, .ngin > a, .chev, #nav, #view > *, .scrpop { transition: none !important; animation: none !important; }
}
/* send-to-screen popover */
.scrpop { position: fixed; z-index: 60; width: 320px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow), 0 16px 40px rgba(0, 0, 0, .18); padding: 12px; opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; transition: opacity .18s, transform .22s var(--ease); }
.scrpop.in { opacity: 1; transform: none; }
.sp-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.sp-list { display: grid; gap: 8px; }
.sp-s { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; transition: border-color .2s, background .2s; }
.sp-s:hover { border-color: var(--teal); } .sp-s.rem { background: var(--soft); }
.sp-t { display: grid; min-width: 0; } .sp-t b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-mini { width: 44px; max-height: 34px; border: 2px solid var(--muted); border-radius: 3px; background: var(--soft); }
.sp-s.cur .sp-mini { border-color: var(--teal); }
.sp-f { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
/* dashboards hub */
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 12px; }
.dcard { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; background: var(--card); transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.dcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--teal); }
.dprev { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 10px; background: var(--soft); min-height: 84px; align-content: start; }
.dprev span { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: 500 11px "Roboto Mono", monospace; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmeta { display: grid; gap: 2px; padding: 10px 12px 4px; } .dact { display: flex; gap: 6px; padding: 6px 12px 12px; }
.dact [data-scr] { flex: 1; }
#nav { flex: 1; min-height: 0; }
.dtools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; } .dtools select { width: auto; }
body.rail .ngh { height: 1px; padding: 0; margin: 8px 10px; background: rgba(255, 255, 255, .12); border-radius: 0; pointer-events: none; }
body.rail .ngh * { display: none; } body.rail .ng:first-child .ngh { display: none; }
/* fundamentals */
.fhi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.fhi .kpi { margin: 0; }
a.btnlink { display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
/* fundamental score badges */
.fb { display: inline-block; font: 700 10.5px/1 "Roboto Mono", monospace; padding: 3px 6px; border-radius: 999px; cursor: pointer; vertical-align: middle; white-space: nowrap; border: 1px solid transparent; }
.fb-pass { background: #DDF5EA; color: #0B7A4B; border-color: #9FDDBF; }
.fb-mixed { background: #FDF1DD; color: #9A5B00; border-color: #F2CF91; }
.fb-fail { background: #FBE3E5; color: #B3261E; border-color: #F0A9AE; }
.fb-unknown { background: var(--soft); color: var(--muted); border-color: var(--line); }
:root[data-theme="dark"] .fb-pass { background: #0F3B2A; color: #7FE0B0; } :root[data-theme="dark"] .fb-mixed { background: #3B2A0F; color: #F5C46B; } :root[data-theme="dark"] .fb-fail { background: #3B1418; color: #F29AA0; }
.th .fb { margin-left: 2px; }
.fsc { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.fbig { width: 120px; height: 120px; border-radius: 16px; display: grid; place-items: center; align-content: center; gap: 2px; text-align: center; border: 1px solid; }
.fbig b { font: 700 40px/1 "Roboto Mono", monospace; } .fbig span { font-size: 12px; opacity: .7; } .fbig em { font-style: normal; font-weight: 700; font-size: 13px; }
.fpil { display: grid; grid-template-columns: 140px 1fr 36px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.fpil > div { height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; } .fpil i { display: block; height: 100%; border-radius: 5px; }
.fpil i.g { background: #1AA36A; } .fpil i.a { background: #E0A030; } .fpil i.r { background: #D9534F; } .fpil b { text-align: right; font-family: "Roboto Mono", monospace; }
.fb-na { background: transparent; color: var(--muted); border-color: var(--line); font-weight: 500; }

/* Safety guard */
.sgh { table-layout: fixed; width: 100%; } .sgh td { white-space: normal; overflow-wrap: anywhere; } .sgh td:first-child { width: 42%; }
.rbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; } .rbar span { display: block; height: 100%; background: var(--teal); } .rbar span.near { background: var(--orange); } .rbar span.over { background: var(--down); }
/* Approvals, journal, activity */
.apgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.apcard { border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 12px; padding: 14px; display: grid; gap: 8px; background: var(--card); }
.apcard.s { border-left-color: var(--down); }
.apcard .big { font-size: 18px; }
.big-btn { flex: 1; min-height: 48px; font-size: 16px; }
@media (max-width: 600px) { .apgrid { grid-template-columns: 1fr; } }
.jform textarea { width: 100%; }
.jform label { display: block; margin-top: 6px; }
tr.alrow td { background: color-mix(in srgb, var(--orange) 8%, transparent); }
td.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
.big-btn.ghost.danger { background: transparent; color: var(--down); border: 1.5px solid var(--down); }
.fb.fb-stale { opacity: .55; outline: 1px dashed currentColor; }
#demobar { background: var(--orange); color: #fff; text-align: center; padding: 6px 12px; font-size: 13px; font-weight: 600; position: sticky; top: 0; z-index: 50; }

/* monitor layouts */
.lybar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lybar select { min-width: 220px; } .lybar input { min-width: 200px; flex: 1 1 200px; }
.lysep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.lymap { position: relative; width: 100%; max-height: 340px; margin: 8px auto 6px; }
.lyscr { position: absolute; box-sizing: border-box; border: 2px solid var(--navy-2); border-radius: 6px; background: var(--soft); overflow: hidden; }
:root[data-theme="dark"] .lyscr { border-color: var(--line); }
.lyscr-n { position: absolute; left: 6px; bottom: 4px; font-size: 11px; color: var(--muted); z-index: 2; pointer-events: none; }
.lyv { position: absolute; box-sizing: border-box; border: 1px solid var(--teal-3); background: rgba(28, 192, 189, .18); border-radius: 3px;
  display: flex; align-items: center; justify-content: center; padding: 2px; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text); }
.lyv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lyv:hover { background: rgba(28, 192, 189, .32); }
.lyv.over { border-color: var(--warn); background: rgba(224, 122, 31, .2); }
.mon.ly { grid-template-columns: 1fr 170px 170px auto; }
.mon.ly.off { opacity: .6; }
.mon.flash { box-shadow: 0 0 0 2px var(--teal); transition: box-shadow .3s; }
@media (max-width: 760px) { .mon.ly { grid-template-columns: 1fr 1fr; } .mon.ly label { grid-column: 1 / -1; } }
