/* ATLAS dashboard — JARVIS/SCADA HMI theme, salvaged from archive/atlas-v3.0
   dashboard/theme.py. Custom-property palette kept verbatim so the box keeps
   the old ATLAS feel. */
:root {
  --navy:  #0a0e1a;
  --deep:  #0d1224;
  --panel: #111827;
  --blue:  #2563eb;
  --cyan:  #06b6d4;
  --gold:  #f59e0b;
  --green: #10b981;
  --red:   #ef4444;
  --purple:#8b5cf6;
  --text:  #e2e8f0;
  --muted: #64748b;
  --border:#1e293b;
  --font-head: 'Orbitron', monospace;
  --font-mono: 'Share Tech Mono', monospace;
  --font-body: 'Exo 2', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.05) 0%, transparent 40%);
}

/* Header */
.atlas-header {
  background: linear-gradient(180deg, #0d1224 0%, #0a0e1a 100%);
  border-bottom: 1px solid var(--cyan);
  box-shadow: 0 2px 20px rgba(6,182,212,0.15);
  position: sticky; top: 0; z-index: 100;
}
.header-top { display: flex; align-items: center; gap: 16px; padding: 10px 24px; min-height: 52px; flex-wrap: wrap; }
.header-logo {
  font-family: var(--font-head); font-size: 22px; font-weight: 900;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: 3px; white-space: nowrap;
}
.header-version { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.header-clock { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); letter-spacing: 1px; }
.header-logout {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  text-decoration: none; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 3px; transition: all .15s; white-space: nowrap;
}
.header-logout:hover { border-color: var(--cyan); color: var(--cyan); }

.equity-line {
  display: flex; gap: 24px; flex-wrap: wrap; padding: 10px 24px;
  border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px;
}
.equity-line .kpi { display: flex; flex-direction: column; gap: 2px; }
.equity-line .kpi .lbl { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.equity-line .kpi .val { color: var(--text); font-size: 15px; }

main { padding: 24px; max-width: 1600px; margin: 0 auto; }
.section { margin-bottom: 28px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; position: relative; overflow: hidden;
}
.card-glow { border-color: var(--cyan); box-shadow: 0 0 15px rgba(6,182,212,0.1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 16px; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } }

h1 {
  font-family: var(--font-head); font-size: 16px; font-weight: 700;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 20px; letter-spacing: 1px;
}
h2 {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
}
h3 { font-family: var(--font-body); font-size: 15px; color: var(--text); margin-bottom: 8px; font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 12px; font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; letter-spacing: .5px;
}
.badge-green { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.3); }
.badge-red   { background: rgba(239,68,68,.15);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.badge-yellow{ background: rgba(245,158,11,.15); color: var(--gold);  border: 1px solid rgba(245,158,11,.3); }
.badge-cyan  { background: rgba(6,182,212,.15);  color: var(--cyan);  border: 1px solid rgba(6,182,212,.3); }
.badge-muted { background: rgba(51,65,85,.2);    color: var(--muted); border: 1px solid rgba(51,65,85,.4); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-yellow{ background: var(--gold);  box-shadow: 0 0 6px var(--gold); }
.dot-red   { background: var(--red);   box-shadow: 0 0 6px var(--red); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); text-align: left;
}
td {
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  padding: 7px 12px; border-bottom: 1px solid rgba(30,41,59,.5);
}
tr:hover td { background: rgba(6,182,212,.04); }

input[type=text], input[type=password], input[type=number] {
  background: var(--deep); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 4px; font-family: var(--font-mono);
  font-size: 13px; width: 100%; transition: border-color .15s;
}
input:focus { outline: none; border-color: var(--cyan); }

.btn {
  background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff;
  border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  letter-spacing: .5px; transition: all .15s;
}
.btn:hover { opacity: .88; box-shadow: 0 0 12px rgba(6,182,212,.3); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: linear-gradient(135deg, #7f1d1d, var(--red)); }
.btn-gold   { background: linear-gradient(135deg, #78350f, var(--gold)); }
.btn-ghost  { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); }

.stat { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--cyan); }
.pos { color: var(--green); } .neg { color: var(--red); }
.buy { color: var(--green); } .sell { color: var(--red); }
.muted { color: var(--muted); } .cyan { color: var(--cyan); } .gold { color: var(--gold); }
.empty { color: var(--muted); font-style: italic; font-family: var(--font-mono); }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-family: var(--font-mono); font-size: 13px; }
.alert-red    { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: var(--red); }
.alert-yellow { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: var(--gold); }
.halt-banner {
  padding: 14px 20px; border-radius: 6px; margin: 0 24px 16px; text-align: center;
  background: rgba(239,68,68,.15); border: 1px solid var(--red); color: var(--red);
  font-family: var(--font-head); letter-spacing: 2px; font-weight: 700;
}

.strat-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; font-family: var(--font-mono); font-size: 12px; }
.kv .k { color: var(--muted); } .kv .v { color: var(--text); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3,6,15,.8); display: none;
  align-items: center; justify-content: center; z-index: 1000;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--cyan); border-radius: 10px;
  padding: 24px; max-width: 440px; width: 92%;
  box-shadow: 0 0 40px rgba(6,182,212,.25);
}
.modal h3 { color: var(--cyan); font-family: var(--font-head); letter-spacing: 1px; }
.modal .effect { margin: 14px 0; padding: 12px; border-radius: 6px; background: var(--deep); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 13px; }
.modal label { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 6px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.modal .err { color: var(--red); font-family: var(--font-mono); font-size: 12px; min-height: 16px; margin-top: 8px; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px; padding: 3px 10px; border-radius: 12px; }
.chip-verified { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.35); }
.chip-local    { background: rgba(245,158,11,.12); color: var(--gold);  border: 1px solid rgba(245,158,11,.35); }

.login-wrap { max-width: 420px; margin: 80px auto; padding: 0 16px; }
.login-title { text-align: center; margin-bottom: 32px; }
.login-title .word { font-family: var(--font-head); font-size: 40px; font-weight: 900; background: linear-gradient(90deg, var(--cyan), var(--blue)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: 5px; }
.login-title .sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 6px; letter-spacing: 2px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 6px; }
.uplot { width: 100%; }

/* ── dashboard v2 additions ─────────────────────────────────────────────── */
.equity-hint {
  padding: 6px 24px 10px; border-top: 1px dashed var(--border);
  font-family: var(--font-body); font-size: 11.5px; color: var(--muted); line-height: 1.5;
}
.equity-hint strong { color: var(--cyan); font-weight: 600; }
.atlas-footer { margin-top: 32px; padding: 18px 8px; text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 11px; border-top: 1px solid var(--border); }

button.header-logout { background: transparent; cursor: pointer; }
.header-back { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); text-decoration: none; padding: 3px 8px; border: 1px solid var(--border); border-radius: 3px; }
.header-back:hover { border-color: var(--cyan); }

.edit-pencil { background: transparent; border: 1px solid var(--border); color: var(--gold); cursor: pointer; border-radius: 3px; font-size: 12px; padding: 1px 6px; line-height: 1.2; }
.edit-pencil:hover { border-color: var(--gold); box-shadow: 0 0 8px rgba(245,158,11,.25); }

/* state-by-colour on the global halt/resume buttons */
.btn-lit { box-shadow: 0 0 14px rgba(239,68,68,.5); outline: 1px solid var(--red); }
.btn-gold.btn-lit { outline-color: var(--gold); box-shadow: 0 0 14px rgba(245,158,11,.4); }

/* strategy cards: enabled glow vs disabled dim + drill-in affordance */
.strat-card { cursor: pointer; transition: border-color .15s, opacity .15s; }
.strat-card:hover { border-color: var(--cyan); }
.card-disabled { opacity: .55; filter: grayscale(.4); border-style: dashed; }
.card-disabled:hover { opacity: .8; }
.drill-hint { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* tape filters */
.tape-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.tape-filters label { display: flex; flex-direction: column; gap: 3px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tape-filters select, .tape-filters input { width: auto; min-width: 90px; }

/* legend */
.modal-wide { max-width: 640px; }
.legend-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.legend-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; font-size: 13px; line-height: 1.4; }
.legend-row > span:first-child { justify-self: start; pointer-events: none; }
.legend-row b { color: var(--text); }
@media (max-width: 560px) { .legend-row { grid-template-columns: 1fr; } }

/* strategy detail */
.s-summary { font-size: 15px; line-height: 1.5; margin: 12px 0; color: var(--text); }
.s-how { margin-top: 8px; }
.s-how summary { font-family: var(--font-mono); font-size: 11px; color: var(--cyan); text-transform: uppercase; letter-spacing: 1px; cursor: pointer; }
.s-how p { margin-top: 8px; line-height: 1.6; color: var(--text); }

.stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.stat-tile { padding: 12px 14px; }
.stat-lbl { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat-val { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: var(--cyan); margin: 4px 0 2px; }
.stat-val.pos { color: var(--green); } .stat-val.neg { color: var(--red); }
.stat-sub { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.chart-legend .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 4px; vertical-align: middle; border-radius: 2px; }
.swatch.tri-up { width: 0; height: 0; border-radius: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 10px solid var(--green); }
.swatch.tri-down { width: 0; height: 0; border-radius: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 10px solid var(--red); }
.swatch.line-green { height: 0; border-top: 2px dashed var(--green); }
.swatch.line-red { height: 0; border-top: 2px dashed var(--red); }

/* grid ladder viz */
.grid-asset { margin-bottom: 16px; }
.grid-ladder { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.grid-level { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; font-family: var(--font-mono); font-size: 11px; align-items: center; padding: 3px 6px; border-left: 2px solid var(--border); }
.gl-sell { color: var(--red); opacity: .5; }
.gl-buy { color: var(--green); opacity: .5; }
.gl-armed { opacity: 1; font-weight: 600; }
.gl-state { color: var(--muted); text-align: right; }

/* opening-range concept */
.orb-viz { padding: 20px 0; }
.orb-band { position: relative; height: 90px; margin: 24px 0; background: linear-gradient(180deg, rgba(16,185,129,.12), rgba(239,68,68,.12)); border-top: 2px solid var(--green); border-bottom: 2px solid var(--red); border-radius: 4px; }
.orb-lbl { position: absolute; font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; }
.orb-hi { top: -20px; left: 6px; color: var(--green); }
.orb-lo { bottom: -20px; left: 6px; color: var(--red); }

/* tuning form */
.param-row { display: grid; grid-template-columns: 180px 200px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(30,41,59,.5); }
.param-lbl { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); }
.param-help { font-size: 12px; color: var(--muted); line-height: 1.4; }
.param-input select, .param-input input { width: 100%; }
@media (max-width: 640px) { .param-row { grid-template-columns: 1fr; gap: 4px; } }

/* gold badge + sentiment-linked button state */
.badge-gold { background: rgba(245,158,11,.15); color: var(--gold); border: 1px solid rgba(245,158,11,.35); }
.btn-sentiment { background: linear-gradient(135deg, #78350f, var(--gold)); }
.btn-sentiment.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-sentiment.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-sentiment.btn-lit { outline: 1px solid var(--gold); box-shadow: 0 0 14px rgba(245,158,11,.4); }

/* market-sentiment header readout */
.sentiment-bar { padding: 8px 24px 12px; border-top: 1px solid rgba(30,41,59,.6); background: rgba(13,18,36,.4); }
.sent-main { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sent-title { font-family: var(--font-head); font-size: 12px; letter-spacing: 2px; color: var(--cyan); text-transform: uppercase; }
.sent-score { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }
.sent-score.pos { color: var(--green); } .sent-score.neg { color: var(--red); }
.sent-label { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
.sent-factor { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.sent-factor b { color: var(--gold); }
.sent-note { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
.sent-components { margin-top: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--deep); max-width: 520px; }

/* strategy-detail sentiment dial row */
.sentiment-dial-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(30,41,59,.6); }
.sd-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sd-title { font-family: var(--font-head); font-size: 12px; letter-spacing: 2px; color: var(--cyan); text-transform: uppercase; }

/* reviews tab */
.reviews-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.reviews-list { position: sticky; top: 78px; max-height: calc(100vh - 110px); overflow-y: auto; }
.rev-group-title { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 6px; }
.rev-item { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid var(--border); color: var(--text); font-family: var(--font-mono); font-size: 12px; padding: 6px 10px; margin-bottom: 4px; border-radius: 4px; cursor: pointer; transition: all .15s; }
.rev-item:hover { border-color: var(--cyan); color: var(--cyan); }
.rev-item.rev-active { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(6,182,212,.15); background: rgba(6,182,212,.08); }
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.review-stem { font-family: var(--font-mono); font-size: 14px; color: var(--cyan); }
.review-md { line-height: 1.6; overflow-wrap: anywhere; }
.review-md h1, .review-md h2, .review-md h3, .review-md h4 { font-family: var(--font-head); color: var(--text); margin: 18px 0 10px; line-height: 1.3; }
.review-md h1 { font-size: 22px; color: var(--cyan); }
.review-md h2 { font-size: 18px; } .review-md h3 { font-size: 15px; }
.review-md p { margin: 10px 0; }
.review-md ul, .review-md ol { margin: 10px 0 10px 22px; }
.review-md li { margin: 4px 0; }
.review-md code { font-family: var(--font-mono); font-size: 12px; background: var(--deep); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.review-md pre { background: var(--deep); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 12px 0; }
.review-md pre code { border: none; padding: 0; background: transparent; }
.review-md blockquote { border-left: 3px solid var(--cyan); margin: 12px 0; padding: 4px 14px; color: var(--muted); background: rgba(6,182,212,.05); }
.review-md a { color: var(--cyan); }
.review-md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
@media (max-width: 720px) { .reviews-layout { grid-template-columns: 1fr; } .reviews-list { position: static; max-height: none; } }

/* ══════════════════════════════════════════════════════════════════════════
   Mobile / responsive. The header stacks nav + an 8-KPI equity line + an
   explainer + the sentiment bar. On a phone that whole sticky block dominated
   the screen (and in landscape ate the short viewport). Fix: only a SLIM nav
   bar stays pinned; everything else scrolls with the page. In landscape (short
   height) nothing pins, so the content gets the full height.
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* whole header joins the normal scroll flow ... */
  .atlas-header { position: static; box-shadow: none; }
  /* ... except a slim, always-reachable nav bar that pins to the top */
  .header-top {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(180deg, #0d1224 0%, #0a0e1a 100%);
    border-bottom: 1px solid var(--cyan);
    padding: 8px 12px; min-height: 44px; gap: 8px 10px;
  }
  .header-logo { font-size: 18px; letter-spacing: 2px; }
  .header-version { display: none; }          /* long subtitle: decorative, drop it */
  #status-text { display: none; }              /* the status dot already says it */
  .header-right { gap: 8px; }
  .header-logout, .header-back { font-size: 10px; padding: 4px 7px; }
  .header-clock { display: none; }             /* the phone has its own clock */

  /* KPI line: compact and scrolls away with the page */
  .equity-line { padding: 10px 12px; gap: 8px 16px; font-size: 11px; }
  .equity-line .kpi .val { font-size: 13px; }
  .equity-line .kpi .lbl { font-size: 9px; }
  .equity-hint { display: none; }              /* verbose explainer: hidden on mobile */
  .sentiment-bar { padding: 8px 12px; }
  .sent-score { font-size: 17px; }
  .sent-main { gap: 8px 12px; }

  main { padding: 14px 12px; }
  .section { margin-bottom: 20px; }
  h1 { font-size: 15px; margin-bottom: 14px; }
}

/* Landscape phones / short viewports: don't pin ANY of the header — give the
   scrollable content the full (short) height. This is the "bottom 20% only"
   bug: a pinned tall header left almost no room to scroll. */
@media (orientation: landscape) and (max-height: 600px) {
  .atlas-header, .header-top { position: static; box-shadow: none; }
  .header-version, .equity-hint, .sent-note, #status-text { display: none; }
  .header-top { padding: 6px 14px; min-height: 40px; }
  .equity-line { padding: 6px 14px; gap: 6px 16px; }
  .sentiment-bar { padding: 6px 14px; }
  main { padding: 12px 14px; }
}
