/* ============================================================================
   MARKET FORECAST  ·  stylesheet
   ----------------------------------------------------------------------------
   A dark trading-screen look: near-black blue panels, hairline rules, green
   and red with the same lightness (both pass 4.5:1 on the panels), one cool
   azure for the forecast. Inter with tabular figures for every number.
   Desktop: a watchlist column and the content column. Phone (max-width
   768px): the watchlist is a bottom sheet over a dock, the content scrolls.
   grep: ":root"  "#tickerHead"  ".cards"  "@media (max-width:768px)"  "sn-saver"
   ========================================================================== */
:root {
  --bg: #06080c; --bg1: #0a0d13; --bg2: #0f131b; --bg3: #151a24;
  --line: rgba(255,255,255,.07); --line2: rgba(255,255,255,.12);
  --ink: #e8edf4; --ink2: #b9c3d2; --dim: #7f8b9d;
  --up: #2bd685; --down: #ff6170; --az: #79acff; --amber: #ffc35c;
  --r: 12px; --side: 310px; --top: 58px; --dock-h: 0px;
  --f: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(1200px 600px at 70% -10%, rgba(80,120,220,.10), transparent 60%), var(--bg); color: var(--ink); font: 400 14px/1.45 var(--f); font-feature-settings: 'tnum' 1, 'cv11' 1; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* top bar */
#top { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 18px; padding: 0 18px; background: rgba(8,10,15,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { width: 26px; height: 26px; color: var(--az); flex: none; }
.brand b { display: block; font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.brand .sub { display: block; font-size: 11.5px; color: var(--dim); }
.modes { display: flex; gap: 2px; padding: 3px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; margin-left: 8px; }
.modes button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; color: var(--ink2); font-weight: 500; }
.modes button.on { background: var(--bg3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line2); background: var(--bg2); padding: 6px 12px; border-radius: 9px; font-weight: 500; font-size: 13px; }
.chip:hover { border-color: rgba(121,172,255,.5); }
.chip.ghost { background: transparent; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.chip.live .dot { background: var(--up); box-shadow: 0 0 8px var(--up); }
.sel select { appearance: none; -webkit-appearance: none; border: 1px solid var(--line2); background: var(--bg2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237f8b9d'/%3E%3C/svg%3E") no-repeat right 10px center; padding: 6px 28px 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; max-width: 240px; }

/* layout */
#app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
#side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; border-right: 1px solid var(--line); background: linear-gradient(180deg, var(--bg1), var(--bg)); padding: 14px 12px 20px; }
#sheetGrip { display: none; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 2px 6px 10px; }
.side-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.pf-mini { text-align: right; font-size: 12px; color: var(--dim); }
.pf-mini span { color: var(--ink); font-weight: 600; margin-right: 6px; }
.pf-mini em { font-style: normal; }
.cols { display: grid; grid-template-columns: 1fr 76px 66px; padding: 0 10px 6px; font-size: 10.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.cols span:not(:first-child) { text-align: right; }
.row { position: relative; display: grid; grid-template-columns: 1fr 76px 66px; grid-template-rows: auto auto; align-items: center; column-gap: 0; padding: 9px 10px 8px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; }
.row:hover { background: rgba(255,255,255,.025); }
.row.on { background: linear-gradient(90deg, rgba(121,172,255,.10), rgba(121,172,255,.02)); border-color: rgba(121,172,255,.22); }
.row .s { font-weight: 600; font-size: 13.5px; letter-spacing: .01em; }
.row .n { grid-column: 1; font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.row .p { text-align: right; font-weight: 500; }
.row .c { text-align: right; font-weight: 600; font-size: 12.5px; }
.row canvas.spark { grid-column: 2 / 4; grid-row: 2; width: 100%; height: 20px; }
.row .pos { grid-column: 1 / 4; display: none; gap: 6px; margin-top: 8px; }
.row.on .pos { display: flex; }
.pos label { flex: 1; display: flex; flex-direction: column; font-size: 10.5px; color: var(--dim); gap: 2px; }
.pos input { width: 100%; border: 1px solid var(--line2); background: var(--bg); border-radius: 7px; padding: 5px 7px; font-size: 13px; }
.pos .rm { flex: none; align-self: flex-end; border: 1px solid var(--line2); background: none; border-radius: 7px; padding: 5px 8px; color: var(--dim); }
.up { color: var(--up); } .dn { color: var(--down); }
#addForm { display: flex; gap: 6px; margin: 12px 4px 6px; }
#addForm input { flex: 1; min-width: 0; border: 1px solid var(--line2); background: var(--bg2); border-radius: 9px; padding: 8px 10px; text-transform: uppercase; }
#addForm input::placeholder { text-transform: none; color: var(--dim); }
#addForm button { border: 1px solid var(--line2); background: var(--bg3); border-radius: 9px; padding: 0 14px; font-weight: 500; }
.hint { font-size: 11.5px; color: var(--dim); margin: 6px 6px 0; }

#content { min-width: 0; padding: 16px 20px 28px; }
#tickerHead { display: grid; grid-template-columns: auto auto 1fr auto; align-items: end; gap: 6px 26px; padding: 2px 2px 14px; }
.th-id .sym { font-size: 26px; font-weight: 600; letter-spacing: .01em; line-height: 1.1; }
.th-id .nm { font-size: 12.5px; color: var(--dim); margin-top: 2px; }
.th-px .px { font-size: 32px; font-weight: 600; letter-spacing: -.01em; line-height: 1.05; }
.th-px .chg { font-size: 14px; font-weight: 600; margin-top: 3px; }
.th-meta { font-size: 11.5px; color: var(--dim); align-self: end; padding-bottom: 3px; }
.th-meta b { color: var(--ink2); font-weight: 500; }
.th-ctl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: inline-flex; padding: 2px; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; }
.seg[hidden] { display: none; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; font-size: 12.5px; color: var(--ink2); font-weight: 500; }
.seg button.on { background: var(--bg3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }

.gfx { position: relative; width: 100%; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: #090b10; touch-action: pan-y; }
.gfx canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gfx canvas.mf-ov { cursor: crosshair; }
#chartBox { height: clamp(360px, 58vh, 700px); box-shadow: 0 30px 80px -40px rgba(60,110,220,.35); }
#scrub { display: flex; align-items: center; gap: 12px; margin: 12px 2px 4px; }
.round { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line2); background: var(--bg2); display: grid; place-items: center; }
.round svg { width: 16px; height: 16px; }
.round.on { border-color: var(--az); color: var(--az); }
#scrubR { flex: 1; accent-color: var(--az); }
#scrubL { flex: none; min-width: 210px; font-size: 12.5px; color: var(--ink2); text-align: right; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 10px; margin-top: 12px; }
.card { background: linear-gradient(180deg, var(--bg2), var(--bg1)); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px 12px; min-width: 0; }
.card .k { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.card .v { font-size: 21px; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.card .s { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.cards.small .card .v { font-size: 17px; }
.card .v.sm { font-size: 16.5px; white-space: normal; line-height: 1.25; }
.bar80 { position: relative; height: 6px; border-radius: 3px; background: rgba(255,255,255,.07); margin-top: 8px; }
.bar80 i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, rgba(121,172,255,.35), rgba(121,172,255,.8), rgba(121,172,255,.35)); }
.bar80 b { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--amber); }
.runline { font-size: 11.5px; color: var(--dim); margin: 10px 2px 0; min-height: 1.4em; }
.runline b { color: var(--ink2); font-weight: 500; }
.prog { display: inline-block; width: 120px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.08); vertical-align: middle; margin: 0 6px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--az); }

/* analysis */
.an-title h2 { margin: 2px 0 2px; font-size: 22px; font-weight: 600; }
.an-title p { margin: 0; color: var(--dim); font-size: 12.5px; max-width: 900px; }
.an-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.card-box { background: linear-gradient(180deg, var(--bg1), var(--bg)); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.card-box.wide:last-child { grid-column: 1 / -1; }
.card-box h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--ink2); }
.card-box h3 small { font-weight: 400; color: var(--dim); margin-left: 6px; letter-spacing: 0; }
.gfx.tall { height: 300px; }
#calibBox { height: 260px; flex: 1; }
.legend { font-size: 11.5px; color: var(--dim); margin: 8px 2px 0; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw.up { background: var(--up); } .sw.dn { background: var(--down); } .sw.now { background: var(--amber); width: 3px; } .sw.ln { background: none; border-top: 2px solid #d9e4ff; height: 0; width: 14px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: right; font-weight: 500; color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 4px 6px 7px; border-bottom: 1px solid var(--line); }
td { text-align: right; padding: 7px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td small { display: block; color: var(--dim); font-size: 10.5px; margin-top: 2px; }
td .mini { display: inline-block; position: relative; width: 54px; height: 6px; background: rgba(255,255,255,.06); border-radius: 3px; vertical-align: middle; }
td .mini i { position: absolute; top: 0; bottom: 0; background: rgba(121,172,255,.6); border-radius: 3px; }
td .mini b { position: absolute; top: -2px; width: 2px; height: 10px; background: var(--amber); }
.bt-row { display: flex; gap: 14px; align-items: stretch; margin-top: 12px; }
figure.rel { margin: 0; flex: none; width: 210px; }
figure.rel svg { width: 100%; height: auto; background: #090b10; border: 1px solid var(--line); border-radius: var(--r); }
figure.rel figcaption { font-size: 11px; color: var(--dim); margin-top: 6px; }

#foot { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,195,92,.04); color: var(--ink2); font-size: 12.5px; }
#foot b { color: var(--ink); font-weight: 600; }

dialog { border: 1px solid var(--line2); border-radius: 16px; background: #0c1017; color: var(--ink); padding: 20px 22px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 30px 90px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(2,4,8,.6); backdrop-filter: blur(6px); }
dialog h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
dialog p, dialog li { color: var(--ink2); font-size: 13.5px; }
dialog a { color: var(--az); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
.fine { font-size: 12px !important; color: var(--dim) !important; }
.prov { display: grid; gap: 8px; }
.prov label { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.prov label:has(input:checked) { border-color: rgba(121,172,255,.55); background: rgba(121,172,255,.06); }
.prov input { grid-row: 1 / 3; margin-top: 3px; accent-color: var(--az); }
.prov b { font-weight: 600; } .prov small { color: var(--dim); font-size: 11.5px; }
.mdl { display: grid; gap: 6px; margin-top: 6px; font-size: 13px; }
.mdl select { border: 1px solid var(--line2); background: var(--bg); border-radius: 9px; padding: 8px 10px; }
#keyRow { margin-top: 14px; }
#keyRow label { font-size: 12.5px; color: var(--ink2); }
.key { display: flex; gap: 6px; margin-top: 6px; }
.key input { flex: 1; border: 1px solid var(--line2); background: var(--bg); border-radius: 9px; padding: 8px 10px; }
#toast { position: fixed; left: 50%; bottom: calc(22px + var(--dock-h)); transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; background: #121824; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 14px; font-size: 13px; z-index: 60; pointer-events: none; max-width: calc(100vw - 24px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
#dock { display: none; }

@media (max-width: 1100px) {
  .an-grid { grid-template-columns: 1fr; }
  #tickerHead { grid-template-columns: auto 1fr; }
  .th-meta { grid-column: 1 / -1; }
  .th-ctl { grid-column: 1 / -1; justify-content: flex-start; }
}

/* PHONE: the watchlist is a bottom sheet over the dock; content scrolls. */
@media (max-width: 768px) {
  :root { --top: 52px; --dock-h: calc(62px + env(safe-area-inset-bottom)); }
  #top { padding: 0 12px; gap: 8px; }
  .brand .sub, .modes, #aboutBtn, .sel { display: none; }
  #srcBtn span { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #app { display: block; }
  #content { padding: 12px 12px calc(var(--dock-h) + 18px); }
  #side { position: fixed; left: 0; right: 0; bottom: var(--dock-h); top: auto; height: 46vh; height: 46dvh; z-index: 40; border: 1px solid var(--line2); border-bottom: 0; border-radius: 18px 18px 0 0; background: rgba(10,13,19,.97); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transform: translateY(calc(100% + var(--dock-h))); transition: transform .3s cubic-bezier(.4,0,.2,1), height .3s cubic-bezier(.4,0,.2,1); padding-top: 4px; box-shadow: 0 -20px 60px rgba(0,0,0,.5); }
  #side.open { transform: none; }
  #side.full { height: calc(100dvh - var(--dock-h) - 40px); }
  #sheetGrip { display: flex; justify-content: center; padding: 8px 0 10px; cursor: grab; touch-action: none; }
  #sheetGrip span { width: 46px; height: 5px; border-radius: 3px; background: var(--dim); opacity: .6; }
  #tickerHead { grid-template-columns: 1fr auto; gap: 4px 12px; padding-bottom: 10px; }
  .th-id .sym { font-size: 21px; } .th-px { text-align: right; } .th-px .px { font-size: 24px; } .th-px .chg { font-size: 12.5px; }
  .th-ctl { grid-column: 1 / -1; justify-content: space-between; }
  #chartBox { height: 50vh; height: 50dvh; min-height: 300px; }
  #scrub { flex-wrap: wrap; }
  #scrubL { flex: 1 1 100%; min-width: 0; font-size: 11.5px; text-align: left; order: 3; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card .v { font-size: 18px; }
  .bt-row { flex-direction: column; }
  #calibBox { flex: none; height: 240px; }
  figure.rel { width: 100%; max-width: 260px; }
  #dock { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--dock-h); z-index: 45; padding: 6px 8px env(safe-area-inset-bottom); gap: 6px; background: rgba(8,10,15,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  #dock button { flex: 1; border: 1px solid transparent; background: none; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; color: var(--ink2); min-height: 48px; }
  #dock button svg { width: 20px; height: 20px; }
  #dock button.on { color: var(--az); border-color: rgba(121,172,255,.25); background: rgba(121,172,255,.06); }
}
@media (pointer: coarse) {
  .seg button { padding: 9px 13px; min-height: 40px; }
  .chip { min-height: 40px; }
  .row { padding: 12px 10px; }
  .round { width: 44px; height: 44px; }
}

/* screensaver: the shell pins our canvas; hide the page chrome */
html.mf-saver body { overflow: hidden; }
html.mf-saver #top, html.mf-saver #side, html.mf-saver #dock, html.mf-saver #foot, html.mf-saver #toast { display: none !important; }
