:root {
  --bg: #0b1220;
  --card: #111a2c;
  --line: #1f2a40;
  --text: #e6ebf5;
  --muted: #8a96ad;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --accent: #22d3ee;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.controls { display: flex; gap: 10px; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.num { text-align: right; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 14px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 3px; height: 100%; }
.bar .seg-ok { background: var(--accent); opacity: .75; border-radius: 2px 2px 0 0; }
.bar .seg-bad { background: var(--bad); }
.bar .seg-rej { background: var(--warn); opacity: .8; }
.bars { max-width: 100%; }
.bar { max-width: 28px; }
input, select, button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
button { cursor: pointer; background: var(--accent); color: #04202a; border: 0; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 400; }
#login { max-width: 360px; margin: 12vh auto 0; }
#login-form { display: grid; gap: 12px; margin-top: 18px; }
#login-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
#login-form input { width: 100%; }
@media (max-width: 560px) { .card .value { font-size: 18px; } th, td { padding: 6px 4px; } }

/* live zoom lab (chart colours are set in lab.js) */
.lab-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lab-controls input { flex: 1 1 200px; min-width: 0; }
.lab-board { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 6px; }
.lab-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.lab-live { margin-left: 8px; font-size: 13px; font-weight: 600; }
.lab-live.on { color: #facc15; }
.lab-live.dim { color: #facc15; opacity: .55; }
.lab-live.off { color: var(--muted); }
.lab-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lab-seg button { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 5px 14px; font-weight: 500; }
.lab-seg button.active { background: var(--accent); color: #04202a; font-weight: 600; }
.lab-chart { display: block; width: 100%; height: auto; touch-action: pan-y; }
.lab-progress { height: 5px; background: var(--line); border-radius: 3px; margin-top: 6px; }
#lab-progress-fill { height: 100%; width: 0; background: #facc15; border-radius: 3px; }
/* Horizon signal panel: gauge | centred read-out | reads timeline */
.sig-panel {
  --tone: #22d3ee;
  position: relative; display: grid; grid-template-columns: 96px 1fr 240px; gap: 18px; align-items: center;
  overflow: hidden; margin: 4px 0 12px; padding: 16px 20px; min-height: 190px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  background:
    radial-gradient(90% 120% at 50% 0%, color-mix(in srgb, var(--tone) 13%, transparent), transparent 65%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px),
    #0c1424;
  box-shadow: 0 0 26px -8px var(--tone), inset 0 0 22px -12px var(--tone);
  transition: border-color .5s, box-shadow .5s;
}
.sig-panel.bull { --tone: #34d399; }
.sig-panel.bear { --tone: #f87171; }
.sig-panel.neutral { --tone: #fbbf24; }
.sig-panel.scan { --tone: #22d3ee; }
.sig-panel::after {
  content: ""; position: absolute; left: 0; right: 0; top: -45%; height: 45%; pointer-events: none; opacity: 0;
  background: linear-gradient(transparent, color-mix(in srgb, var(--tone) 16%, transparent), transparent);
}
.sig-panel.scan::after, .sig-panel.busy::after { opacity: 1; animation: sig-scanline 2.4s linear infinite; }
.sig-panel.flash { animation: sig-flash 1.5s ease-out; }

/* gauge: a tall track, a glowing ball with a pointer and its % */
.sig-gauge { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sig-lbl { font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.sig-top { color: #34d399; } .sig-bot { color: #f87171; }
.sig-scale { position: relative; width: 70px; height: 140px; }
.sig-track {
  position: absolute; left: 28px; top: 0; bottom: 0; width: 12px; border-radius: 6px;
  background: linear-gradient(#34d399, #1f2a40 42%, #1f2a40 58%, #f87171);
  box-shadow: 0 0 12px -3px var(--tone), inset 0 0 4px rgba(0,0,0,.6);
}
.sig-zone { position: absolute; left: -4px; right: -4px; top: 35%; height: 30%; border-radius: 3px; border: 1px dashed rgba(251,191,36,.4); }
.sig-tick { position: absolute; left: 0; width: 22px; text-align: right; transform: translateY(-50%);
  font: 500 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.sig-tick.t100 { top: 0; } .sig-tick.t50 { top: 50%; } .sig-tick.t0 { top: 100%; }
.sig-marker {
  position: absolute; left: 0; right: 0; top: 50%; height: 0;
  transition: top 1.2s cubic-bezier(.2,.9,.2,1);
}
.sig-ball {
  position: absolute; left: 25px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, var(--tone) 55%);
  box-shadow: 0 0 14px 2px var(--tone), 0 0 2px #fff;
}
.sig-arrow {
  position: absolute; left: 45px; top: -6px; width: 0; height: 0;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 8px solid var(--tone);
}
.sig-val { position: absolute; left: 54px; top: -7px; font: 700 12px/14px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tone); }
.sig-panel.scan .sig-marker { animation: sig-sweep 1.5s ease-in-out infinite alternate; }
.sig-panel.scan .sig-arrow, .sig-panel.scan .sig-val { display: none; }
.sig-panel.busy .sig-ball { animation: sig-pulse .6s ease-in-out infinite alternate; }

/* centre: kicker, big call, sub-line */
.sig-body { min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sig-kicker { font: 600 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .2em; text-transform: uppercase; color: var(--tone); }
.sig-panel.busy .sig-kicker::after, .sig-panel.scan .sig-kicker::after { content: ""; animation: sig-dots 1.2s steps(4) infinite; }
.sig-read { display: flex; align-items: baseline; justify-content: center; gap: 14px; flex-wrap: wrap; }
.sig-main { font: 800 30px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tone); text-shadow: 0 0 16px color-mix(in srgb, var(--tone) 45%, transparent); }
.sig-pct { font: 800 52px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tone);
  text-shadow: 0 0 22px color-mix(in srgb, var(--tone) 55%, transparent); }
.sig-panel.scan .sig-main::after { content: "▍"; margin-left: 4px; animation: sig-blink 1s steps(1) infinite; }
.sig-sub { color: var(--muted); font-size: 12px; max-width: 520px; }

/* right: reads timeline and last candle */
.sig-side { border-left: 1px solid color-mix(in srgb, var(--tone) 25%, transparent); padding-left: 16px; display: flex; flex-direction: column; gap: 8px; align-self: stretch; justify-content: center; }
.sig-side-title { font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.sig-trail { display: flex; flex-direction: column; gap: 6px; }
.sig-trail:empty::before { content: "none yet"; color: var(--muted); font-size: 12px; }
.sig-chip { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); }
.sig-chip.bull { color: #34d399; border-color: rgba(52,211,153,.4); }
.sig-chip.bear { color: #f87171; border-color: rgba(248,113,113,.4); }
.sig-chip.neutral { color: #fbbf24; border-color: rgba(251,191,36,.4); }
.sig-chip.now { box-shadow: 0 0 10px -2px currentColor; background: color-mix(in srgb, currentColor 8%, transparent); }
.sig-last { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.sig-last:empty { display: none; }
.sig-last .ok { color: #34d399; } .sig-last .bad { color: #f87171; }
@keyframes sig-pulse { from { transform: scale(.85); } to { transform: scale(1.15); } }
@keyframes sig-scanline { from { top: -45%; } to { top: 100%; } }
@keyframes sig-sweep { from { top: 3%; } to { top: 97%; } }
@keyframes sig-jitter { from { transform: translateY(-3px); } to { transform: translateY(3px); } }
@keyframes sig-blink { 50% { opacity: 0; } }
@keyframes sig-dots { 0% { content: ""; } 25% { content: " ."; } 50% { content: " .."; } 75% { content: " ..."; } }
@keyframes sig-flash {
  0% { box-shadow: 0 0 0 2px var(--tone), 0 0 40px 4px var(--tone); }
  100% { box-shadow: 0 0 22px -8px var(--tone), inset 0 0 18px -10px var(--tone); }
}
@media (prefers-reduced-motion: reduce) {
  .sig-panel *, .sig-panel::after, .sig-panel { animation: none !important; transition: none !important; }
}
@media (max-width: 760px) {
  .sig-panel { grid-template-columns: 84px 1fr; }
  .sig-side { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid color-mix(in srgb, var(--tone) 25%, transparent); padding-top: 10px; }
  .sig-trail { flex-direction: row; flex-wrap: wrap; }
  .sig-main { font-size: 22px; } .sig-pct { font-size: 38px; }
}
/* predicted high / low / close next to the live candle */
.lab-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; }
.lab-box { background: #0c1424; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.lab-box-label { font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lab-box-value { font: 700 16px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.lab-box-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.lab-box.up { border-color: rgba(52,211,153,.35); } .lab-box.up .lab-box-value { color: #34d399; }
.lab-box.down { border-color: rgba(248,113,113,.35); } .lab-box.down .lab-box-value { color: #f87171; }
.lab-box.ai { border-color: rgba(167,139,250,.35); } .lab-box.ai .lab-box-value { color: #a78bfa; }
.lab-box.live { border-color: rgba(250,204,21,.35); } .lab-box.live .lab-box-value { color: #facc15; }
@media (max-width: 760px) { .lab-boxes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .lab-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Predicted range: the lab's headline (high / low beat the baselines; direction does not). */
.lab-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px; margin: 0 0 8px; }
.lab-top .lab-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.lab-range { background: linear-gradient(180deg, #0f1a2e, #0b1322); border: 1px solid #2a3a58; border-radius: 12px; padding: 12px 16px 14px; min-width: 0; }
.rng-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.rng-title { font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; text-transform: uppercase; color: #cbd5e1; }
.rng-when { font-size: 11px; color: var(--muted); }
.rng-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; }
.rng-side { min-width: 0; }
.rng-side.up { text-align: right; }
.rng-label { font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.rng-value { font: 800 26px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: 2px; }
.rng-side.up .rng-label, .rng-side.up .rng-value { color: #34d399; }
.rng-side.down .rng-label, .rng-side.down .rng-value { color: #f87171; }
.rng-far { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rng-note { font-size: 11px; color: var(--muted); margin-top: 2px; }
.rng-note.hit { color: #facc15; }
.rng-mid { min-width: 0; }
.rng-bar { position: relative; height: 26px; }
.rng-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 2px; background: var(--line); border-radius: 1px; }
.rng-far-span { position: absolute; top: 7px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(248,113,113,.22), rgba(52,211,153,.22)); }
.rng-typ-span { position: absolute; top: 5px; height: 16px; border-radius: 8px; background: linear-gradient(90deg, rgba(248,113,113,.7), rgba(52,211,153,.7)); box-shadow: 0 0 12px -3px rgba(167,139,250,.6); }
.rng-real-span { position: absolute; top: 12px; height: 2px; background: #facc15; }
.rng-open { position: absolute; top: 3px; width: 2px; height: 20px; margin-left: -1px; background: #e2e8f0; opacity: .7; border-radius: 1px; }
.rng-now { position: absolute; top: 7px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #facc15; box-shadow: 0 0 0 3px rgba(250,204,21,.25), 0 0 10px rgba(250,204,21,.8); }
.rng-legend { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }
.sig-warn { font-size: 11px; color: #d4a94a; max-width: 520px; opacity: .85; }
@media (max-width: 900px) { .lab-top { grid-template-columns: minmax(0, 1fr); } .lab-top .lab-boxes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .rng-row { grid-template-columns: 1fr 1fr; }
  .rng-mid { grid-column: 1 / -1; grid-row: 2; }
  .rng-value { font-size: 22px; }
  .lab-top .lab-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
