:root {
  --bg: #070b14;
  --panel: #0e1524;
  --card: #111a2b;
  --ink: #eef2f7;
  --muted: #9aa3b8;
  --line: #1c2740;
  --gold: #c9a84c;
  --gold-2: #e4c56a;
  --buy: #3dd68c;
  --watch: #e4c56a;
  --wait: #9aa3b8;
  --short: #f07167;
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  --font: "Segoe UI", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "Cascadia Mono", "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
  max-width: 100%;
}
.grain {
  pointer-events: none;
  position: fixed; inset: 0;
  background:
    radial-gradient(1200px 600px at 8% -12%, #1a2438 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 0%, #2a2412 0%, transparent 50%);
  opacity: 0.55;
}

.mast {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 8px; gap: 12px; flex-wrap: wrap;
  position: relative;
}
.brand { display: flex; gap: 10px; align-items: center; }
.mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, #f0d88a, #b8902c);
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 11px;
  letter-spacing: 0.04em; color: #1a1406;
}
h1 { margin: 0; font-size: 16px; letter-spacing: -0.02em; font-weight: 650; }
.tag { margin: 1px 0 0; color: var(--gold-2); font-size: 11px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: var(--panel);
  padding: 4px 8px; font-size: 11px; color: var(--muted);
  border-radius: 999px;
}

main { padding: 4px 18px 24px; position: relative; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.panel-head h2 {
  margin: 0; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gold-2); font-weight: 600;
}
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.hint strong { color: var(--watch); font-weight: 650; }

.legend-wrap { margin: 0 0 10px; }
.legend-summary { display: none; }
.legend-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0; padding: 6px 12px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; font-size: 11px; color: var(--muted);
}
.legend-bar .verdict { font-size: 11px; }
.legend-bar .last-buy { margin-left: auto; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; }
@media (min-width: 721px) {
  .legend-wrap > .legend-bar { display: flex !important; }
}

.ticker {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 8px 0 10px;
}
.ticker-card {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  min-height: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ticker-card.active { border-color: #3b3118; box-shadow: inset 0 0 0 1px #3b3118; }
.ticker-card .sym {
  display: flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 11px; margin: 0;
}
.ticker-card .sym .verdict { font-size: 10px; }
.ticker-card strong { font-size: 13px; margin: 0; color: var(--ink); font-weight: 650; }
.ticker-card .hl { color: var(--muted); font-size: 10px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
}
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.mono { font-family: var(--mono); font-size: 12px; }
tr.sel td { background: #151e30; }
tr.main-row:hover td { background: #141c2c; cursor: pointer; }
.empty { color: var(--muted); font-family: var(--font) !important; }
.sym-cell { font-weight: 600; }
.sym-cell .name { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 1px; }
.expand {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--gold-2); cursor: pointer; font-size: 11px; line-height: 1;
}
.expand[aria-expanded="true"] { background: #1a2438; }
tr.strategy-block td { background: #0b1220; padding: 6px 8px 10px 38px; }
.nested { font-size: 12px; }
.nested th { font-size: 10px; padding: 5px 6px; }
.nested td { padding: 6px; }

.verdict { font-weight: 700; letter-spacing: 0.03em; font-size: 12px; }
.verdict.BUY, .verdict.buy { color: var(--buy); }
.verdict.SHORT, .verdict.short { color: var(--short); }
.verdict.WATCH, .verdict.watch { color: var(--watch); }
.verdict.WAIT, .verdict.wait { color: var(--wait); }
.verdict.BUYSETUP, .verdict.buysetup { color: #7dffc2; }
.verdict.SHORTSETUP, .verdict.shortsetup { color: #ff9a90; }

.sub { margin: 12px 0 4px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-2); }
.strategies, .sensors { list-style: none; padding: 0; margin: 0 0 8px; }
.strategies li, .sensors li { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sensor { font-family: var(--mono); font-size: 11px; margin-right: 8px; }
.sensor.observed { color: var(--buy); }
.sensor.available { color: var(--watch); }
.sensor.stale { color: var(--gold); }
.sensor.unavailable { color: var(--wait); }
.ghost, .take {
  background: transparent; border: 1px solid var(--line); color: var(--ink);
  padding: 6px 10px; font-family: var(--font); font-size: 12px;
  cursor: pointer; margin: 8px 8px 8px 0; border-radius: 6px;
}
.take { border-color: var(--buy); color: var(--buy); }
.hidden { display: none; }
.wait-cell { max-width: 240px; color: var(--ink); font-size: 12px; }
.alert-list .icon { font-family: var(--mono); margin-right: 6px; color: var(--gold-2); }
.muted { color: var(--muted); }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }

.chart-wrap {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 8px;
  margin: 8px 0 10px;
}
.chart { height: 240px; background: transparent; border: 0; border-radius: 0; margin: 0; }
.chart-cap, .chart-sentence {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.chart-sentence { margin-top: 2px; }
.swatch {
  width: 8px; height: 8px; border-radius: 2px; display: inline-block;
}
.swatch.up { background: var(--buy); }
.swatch.down { background: var(--short); }
.swatch.sma { background: var(--gold); }
.evidence { list-style: none; padding: 0; margin: 0 0 8px; }
.evidence li { font-size: 13px; padding: 5px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.evidence .dir, .strategies .dir { font-family: var(--mono); color: var(--muted); margin-right: 8px; font-size: 12px; }
.why-body, .frontier { font-size: 12px; color: var(--muted); line-height: 1.45; }
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.alert-list .sym { font-family: var(--mono); margin-right: 8px; font-size: 12px; }
.alert-list .thesis { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

footer { padding: 4px 18px 18px; color: var(--muted); font-size: 11px; }
.foot-note { margin: 0; }
.foot-status { display: none; margin: 4px 0 0; }
.mobile-only { display: none; }
.why-line { margin: 0 0 8px; font-size: 13px; color: var(--ink); line-height: 1.4; }
.levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0 0 10px;
}
.levels > div { min-width: 0; }
.levels dt {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.levels dd {
  margin: 1px 0 0;
  font-family: var(--mono);
  font-size: 13px;
}

@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .chart { height: 220px; }
}

@media (max-width: 720px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
  }
  .mast, main, footer {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .mast {
    flex-direction: column;
    align-items: flex-start;
    padding-top: max(14px, env(safe-area-inset-top, 0px));
  }
  .desk-block, .desk-inline { display: none !important; }
  .mobile-only { display: block; }
  .mobile-only.hidden { display: none !important; }
  .tag-rest { display: none; }
  footer {
    padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  }
  .foot-note, .foot-status {
    display: block;
    font-size: 11px;
    color: var(--muted);
  }

  .panel, .split, .chart-wrap {
    max-width: 100%;
    min-width: 0;
  }
  .split { display: flex; flex-direction: column; gap: 12px; }
  .panel { overflow: hidden; }
  main { display: flex; flex-direction: column; }
  .live-strip { order: 1; }
  .summary-strip { order: 2; }
  .found-card { order: 3; }
  .watching-panel { order: 4; }
  .split { order: 5; }
  .legend-wrap { order: 6; }

  .mobile-only.live-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 10px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 12px;
    color: var(--ink);
  }
  .live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--buy);
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55);
    animation: live-pulse 1.6s ease-in-out infinite;
    flex: 0 0 auto;
  }
  @keyframes live-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.45); }
    70% { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(61, 214, 140, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); }
  }
  .live-tape {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .live-tape.fresh { color: var(--buy); }
  #live-scan.tick {
    animation: price-tick 0.9s ease-out;
  }
  @keyframes price-tick {
    0% { color: var(--gold-2); }
    100% { color: var(--ink); }
  }
  @keyframes price-up {
    0% { color: var(--buy); }
    100% { color: var(--ink); }
  }
  @keyframes price-down {
    0% { color: var(--short); }
    100% { color: var(--ink); }
  }

  .legend-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 10px;
    font-size: 12px;
    color: var(--muted);
  }
  .legend-summary::-webkit-details-marker { display: none; }
  .legend-wrap[open] .legend-summary { border-radius: 10px 10px 0 0; border-bottom: 0; }
  .legend-wrap[open] .legend-bar { border-radius: 0 0 10px 10px; }
  .legend-bar .last-buy {
    margin-left: 0;
    max-width: 100%;
    flex: 1 1 100%;
    white-space: normal;
  }

  .summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 12px;
    padding: 10px 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    text-align: center;
  }
  .summary-strip strong {
    display: block;
    font-size: 20px;
    font-weight: 650;
    color: var(--ink);
  }
  .summary-strip span {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .summary-strip .hot { color: var(--buy); }

  .found-card {
    margin: 0 0 8px;
  }
  .found-card .found-actions[hidden] { display: none; }
  #found-why[hidden] { display: none; }
  .found-actions { display: flex; gap: 8px; flex-wrap: wrap; }
  .ghost, .take {
    min-height: 44px;
    margin: 4px 0 0;
  }

  .watching-panel { margin: 0 0 12px; }
  .watching-panel h2 {
    margin: 0 0 8px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-2);
  }
  .watch-card {
    width: 100%;
    text-align: left;
    color: inherit;
    font: inherit;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 0 0 8px;
    cursor: pointer;
  }
  .watch-card.open, .watch-card.sel { border-color: #3b3118; }
  .watch-card.sel { box-shadow: inset 0 0 0 1px #3b3118; }
  .watch-card.setup {
    border-color: #5a4a22;
  }
  .watch-card.trigger {
    border-width: 2px;
  }
  .watch-card.trigger.BUY {
    border-color: var(--buy);
    box-shadow: inset 0 0 0 1px var(--buy);
  }
  .watch-card.trigger.SHORT {
    border-color: var(--short);
    box-shadow: inset 0 0 0 1px var(--short);
  }
  .watch-card-top {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: baseline;
  }
  .watch-card .sym { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .watch-card .price { font-family: var(--mono); font-size: 13px; }
  .watch-card .price.tick.up { animation: price-up 0.9s ease-out; }
  .watch-card .price.tick.down { animation: price-down 0.9s ease-out; }
  .verdict.tick { animation: verdict-tick 0.7s ease-out; }
  @keyframes verdict-tick {
    0% { opacity: 0.35; }
    100% { opacity: 1; }
  }
  .watch-card .wait-line,
  .watch-card .next-line {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
  }
  .watch-card .meta-line .next-line { margin: 0; flex: 1; min-width: 0; }
  .watch-card .meta-line {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    margin-top: 4px;
  }
  .tape-tag {
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }
  .tape-tag.fresh { color: var(--buy); }
  .watch-card-more { display: none; margin-top: 8px; }
  .watch-card.open .watch-card-more { display: block; }
  .watch-card .why-line { color: var(--ink); font-size: 12px; margin: 0 0 8px; }

  .mobile-only.levels { display: grid; }
  .why .desk-intel, .why .why-body, .why .frontier { display: none; }
  .why.investigate-open .desk-intel,
  .why.investigate-open .why-body,
  .why.investigate-open .frontier { display: block; }
  #why-meta { display: none; }

  .chart-wrap {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 8px;
  }
  .chart {
    height: 260px;
    width: 100%;
    max-width: 100%;
  }
  .chart-cap, .chart-sentence { font-size: 12px; }

  .alert-list li {
    padding: 6px 0;
    font-size: 12px;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 2px 8px;
    align-items: baseline;
  }
  .alert-list .icon { margin-right: 0; }
  .alert-list .muted, .alert-list .thesis {
    grid-column: 1 / -1;
    margin-top: 0;
  }
  .alert-list .thesis { font-size: 11px; }
}

@media (max-width: 480px) {
  .mast, main, footer {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  h1 { font-size: 15px; }
  .summary-strip strong { font-size: 18px; }
  .chart { height: 220px; }
  .panel { padding: 10px 12px 12px; }
  .levels { grid-template-columns: 1fr 1fr; }
}
