/*
  Level Watch dashboard.
  Color is reserved for meaning: green = long, red = short, amber = needs attention.
  Everything else is neutral. Radius scale: panels 12px, controls 8px, tags 6px.
*/

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --line: #e2e5ea;
  --line-strong: #cdd2da;
  --text: #13161b;
  --text-2: #464e5b;
  --text-3: #687080;
  --invert: #13161b;
  --invert-text: #f5f6f8;

  --long: #0b7f57;
  --long-soft: rgba(11, 127, 87, 0.1);
  --short: #cc3439;
  --short-soft: rgba(204, 52, 57, 0.09);
  --warn: #9a5b00;
  --warn-soft: rgba(196, 122, 0, 0.12);
  --warn-ink: #ffffff;

  --shadow: 0 1px 2px rgba(19, 22, 27, 0.05), 0 4px 16px rgba(19, 22, 27, 0.05);
  --font: "Geist Variable", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r-panel: 12px;
  --r-ctl: 8px;
  --r-tag: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10;
    --surface: #121519;
    --surface-2: #171b20;
    --surface-3: #1f242b;
    --line: #242a32;
    --line-strong: #323944;
    --text: #e9ebee;
    --text-2: #aab0ba;
    --text-3: #838a96;
    --invert: #e9ebee;
    --invert-text: #0b0d10;
    --long: #3fcf8e;
    --long-soft: rgba(63, 207, 142, 0.12);
    --short: #f2777a;
    --short-soft: rgba(242, 119, 122, 0.12);
    --warn: #f3b544;
    --warn-soft: rgba(243, 181, 68, 0.13);
    --warn-ink: #1b1305;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #121519;
  --surface-2: #171b20;
  --surface-3: #1f242b;
  --line: #242a32;
  --line-strong: #323944;
  --text: #e9ebee;
  --text-2: #aab0ba;
  --text-3: #838a96;
  --invert: #e9ebee;
  --invert-text: #0b0d10;
  --long: #3fcf8e;
  --long-soft: rgba(63, 207, 142, 0.12);
  --short: #f2777a;
  --short-soft: rgba(242, 119, 122, 0.12);
  --warn: #f3b544;
  --warn-soft: rgba(243, 181, 68, 0.13);
  --warn-ink: #1b1305;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 13px; background: var(--surface-3); padding: 2px 6px; border-radius: var(--r-tag); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ph { font-size: 16px; line-height: 1; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: var(--r-ctl); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-3); }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn-primary { background: var(--invert); color: var(--invert-text); border-color: var(--invert); }
.btn-primary:hover { background: var(--invert); opacity: 0.9; }
.btn-sm { height: 30px; padding: 0 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); cursor: pointer; color: var(--text-2);
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.on-good { color: var(--long); border-color: var(--long); }
.icon-btn.on-bad { color: var(--short); border-color: var(--short); }
.link-btn { border: 0; background: none; padding: 0; color: var(--text-2); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px; height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.wordmark { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; }
.file { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.market { display: flex; align-items: center; gap: 22px; margin-left: 8px; }
.mk { display: flex; flex-direction: column; line-height: 1.2; }
.mk-label { font-size: 12px; color: var(--text-3); }
.mk-value { font-family: var(--mono); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.health-wrap { position: relative; }
.health {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctl); cursor: pointer; font-size: 13px; color: var(--text-2);
}
.health .dot, .feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--long); flex: none; }
.health.bad .dot, .feed .dot.bad { background: var(--short); }
.feed .dot.idle { background: var(--line-strong); }
.health.bad { color: var(--short); border-color: var(--short); }
.popover {
  position: absolute; right: 0; top: 42px; width: 300px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); z-index: 30;
}
.feed { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; padding: 8px; border-radius: var(--r-ctl); }
.feed b { font-weight: 500; }
.feed .when { color: var(--text-3); font-size: 12px; }
.feed .err { grid-column: 2 / -1; color: var(--short); font-size: 12px; word-break: break-word; }
.feed .what { grid-column: 2 / -1; color: var(--text-3); font-size: 12px; }

.offline {
  display: flex; align-items: center; gap: 8px; padding: 10px 24px;
  background: var(--short-soft); color: var(--short); font-weight: 500; border-bottom: 1px solid var(--line);
}

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px;
  max-width: 1680px; margin: 0 auto; padding: 20px 24px 40px;
}
.rail {
  position: sticky; top: 80px; align-self: start;
  max-height: calc(100dvh - 100px); overflow: auto; display: grid; gap: 16px;
  scrollbar-width: thin;
}

/* ---------- overview tiles ---------- */
.overview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow);
  cursor: pointer; text-align: left; transition: border-color 0.15s, background 0.15s;
}
.tile:hover { border-color: var(--line-strong); }
.tile[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.tile-num { font-family: var(--mono); font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -0.03em; }
.tile-label { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.tile.armed .tile-num, .tile.approaching .tile-num { color: var(--warn); }
.tile.long .tile-num { color: var(--long); }
.tile.short .tile-num { color: var(--short); }
.tile.armed.has { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.tile .zero { color: var(--text-3); }

/* ---------- list bar ---------- */
.listbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.list-title { font-size: 18px; }
.list-sub { color: var(--text-3); font-size: 13px; }
.list-sub .clear { margin-left: 6px; }
.search {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; width: 200px;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--text-3);
}
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); }
.search:focus-within { border-color: var(--text); }
.select select {
  height: 34px; padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none; cursor: pointer; font-size: 13px;
}

/* ---------- coin rows ---------- */
.list-head, .row {
  display: grid; grid-template-columns: 136px minmax(320px, 1fr) 228px 104px; gap: 20px; align-items: center;
}
.list-head { padding: 0 18px 8px; font-size: 12px; color: var(--text-3); }
.coin-list { display: grid; gap: 8px; }
.row {
  position: relative; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-panel); box-shadow: var(--shadow); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.row:hover { border-color: var(--line-strong); }
.row.approaching { border-left: 3px solid var(--warn); padding-left: 16px; }
.row.armed { border-left: 3px solid var(--warn); padding-left: 16px; background: linear-gradient(90deg, var(--warn-soft), transparent 45%), var(--surface); }
.row.error { cursor: default; }

.coin-cell { display: grid; gap: 3px; min-width: 0; }
.coin-name { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.coin-price { font-family: var(--mono); font-size: 14px; }
.coin-chg { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.up { color: var(--long); }
.down { color: var(--short); }
.tick-up { animation: tickUp 1.2s ease-out; }
.tick-down { animation: tickDown 1.2s ease-out; }
@keyframes tickUp { from { color: var(--long); } }
@keyframes tickDown { from { color: var(--short); } }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--r-tag); font-size: 11px; font-weight: 650; letter-spacing: 0.02em; white-space: nowrap; }
.tag.armed { background: var(--warn); color: var(--warn-ink); }
.tag.approaching { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.muted { background: var(--surface-3); color: var(--text-2); }

/* level ladder */
.ladder { display: grid; gap: 7px; min-width: 0; }
.ladder-ends { display: flex; justify-content: space-between; gap: 12px; }
.end { display: grid; gap: 1px; min-width: 0; }
.end.right { text-align: right; justify-items: end; }
.end-price { font-family: var(--mono); font-size: 14px; font-weight: 500; display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.end-side { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--text-3); }
.end-meta { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.end-dist { font-family: var(--mono); }
.end-dist.near { color: var(--warn); font-weight: 600; }
.end-none { font-size: 12px; color: var(--text-3); padding-top: 2px; }
.tier { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 4px; }
.tier.high { background: var(--text); color: var(--surface); }
.tier.medium { box-shadow: inset 0 0 0 1px var(--text-2); color: var(--text-2); }
.tier.low { color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line-strong); }

.track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: visible; }
.zone { position: absolute; top: 0; bottom: 0; }
.zone.ap { background: var(--warn-soft); }
.zone.arm { background: color-mix(in srgb, var(--warn) 32%, transparent); }
.zone.l { left: 0; border-radius: 5px 0 0 5px; }
.zone.r { right: 0; border-radius: 0 5px 5px 0; }
.track .cap { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); border-radius: 1px; }
.track .cap.l { left: 0; }
.track .cap.r { right: 0; }
.track.open-l .cap.l, .track.open-r .cap.r { display: none; }
.track.open-l { background: linear-gradient(90deg, transparent, var(--surface-3) 18%); }
.track.open-r { background: linear-gradient(270deg, transparent, var(--surface-3) 18%); }
.track.open-l.open-r { background: linear-gradient(90deg, transparent, var(--surface-3) 18%, var(--surface-3) 82%, transparent); }
.marker {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 3px var(--surface); transition: left 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.row.armed .marker, .row.approaching .marker { background: var(--warn); }

/* signals */
.signals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.signals .chip { height: 24px; }
.signals .chip { overflow: hidden; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 7px;
  border-radius: var(--r-tag); background: var(--surface-3); color: var(--text-2); font-size: 12px; white-space: nowrap;
}
.chip .v { font-family: var(--mono); font-weight: 500; color: var(--text); }
.chip .ph { font-size: 14px; }
.chip.long { background: var(--long-soft); color: var(--long); }
.chip.short { background: var(--short-soft); color: var(--short); }
.chip.long .v, .chip.short .v { color: inherit; }

/* bias meter */
.bias { display: grid; gap: 6px; justify-items: start; }
.bias-label { font-size: 13px; font-weight: 650; display: inline-flex; gap: 6px; align-items: baseline; }
.bias-label .mono { font-weight: 500; color: var(--text-3); font-size: 12px; }
.bias.long .bias-label { color: var(--long); }
.bias.short .bias-label { color: var(--short); }
.bias.neutral .bias-label { color: var(--text-2); }
.meter { display: flex; gap: 3px; }
.meter i { width: 18px; height: 6px; border-radius: 2px; background: var(--surface-3); }
.bias.long .meter i.on { background: var(--long); }
.bias.short .meter i.on { background: var(--short); }
.bias.neutral .meter i.on { background: var(--text-3); }
.bias-strength { font-size: 12px; color: var(--text-3); }

/* skeleton */
.skel { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; border-radius: var(--r-tag); height: 12px; }
@media (prefers-reduced-motion: no-preference) { .skel { animation: shimmer 1.4s linear infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }
.row.loading { cursor: default; }
.row-error { color: var(--short); font-size: 13px; grid-column: 2 / -1; }

.empty {
  display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-panel); color: var(--text-2);
}
.empty .ph { font-size: 28px; color: var(--text-3); }
.empty b { color: var(--text); font-size: 15px; }
.footnote { color: var(--text-3); font-size: 12px; margin-top: 18px; }

/* ---------- rail panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow); padding: 14px 16px; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { font-size: 15px; }
.count { font-family: var(--mono); font-size: 12px; min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 11px; background: var(--surface-3); color: var(--text-2); }
.inbox.has .count { background: var(--warn); color: var(--warn-ink); }
.inbox.has { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.hint { color: var(--text-3); font-size: 12px; margin: 0 0 10px; }
.hint .ph { font-size: 13px; vertical-align: -2px; }

.ii { padding: 12px 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.ii:first-child { border-top: 0; padding-top: 2px; }
.ii-top { display: flex; align-items: center; gap: 8px; }
.ii-coin { font-weight: 650; font-size: 15px; }
.ii-level { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.ii-time { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.ii-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-3); }
.ii-meta .long { color: var(--long); font-weight: 600; }
.ii-meta .short { color: var(--short); font-weight: 600; }
.ii-meta .err { color: var(--short); }
.ii-actions { display: flex; gap: 6px; }
.ii-actions .btn-primary { margin-left: auto; }
.inbox-empty { display: flex; gap: 10px; align-items: flex-start; color: var(--text-3); font-size: 13px; }
.inbox-empty .ph { font-size: 20px; color: var(--long); }

.recent { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; scrollbar-width: thin; }
.recent li { display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.recent li:first-child { border-top: 0; }
.recent .t { color: var(--text-3); font-size: 12px; font-family: var(--mono); }
.recent .w { display: flex; align-items: center; gap: 6px; min-width: 0; }
.recent .w b { font-weight: 600; }
.recent .w .mono { color: var(--text-2); font-size: 12px; }
.recent .s { grid-column: 2; color: var(--text-3); font-size: 12px; }
.recent .rate { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 4px; }
.recent .rated { color: var(--text-3); font-size: 16px; }
.recent .rated.good { color: var(--long); }
.recent .rated.bad { color: var(--short); }
.dot-type { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }
.dot-type.approaching { background: transparent; box-shadow: inset 0 0 0 1.5px var(--warn); }

.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats th { font-weight: 500; color: var(--text-3); font-size: 12px; text-align: right; padding: 0 0 6px; }
.stats td { padding: 6px 0; text-align: right; font-family: var(--mono); border-top: 1px solid var(--line); }
.stats th:first-child, .stats td:first-child { text-align: left; font-family: var(--font); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 7, 10, 0.45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(820px, 100vw); z-index: 50;
  background: var(--surface); border-left: 1px solid var(--line); overflow: auto; padding: 20px 24px 28px;
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.25);
}
@media (prefers-reduced-motion: no-preference) {
  .drawer:not([hidden]) { animation: slideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
}
@keyframes slideIn { from { transform: translateX(32px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 18px; }
.drawer-head h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.d-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; font-family: var(--mono); display: flex; flex-wrap: wrap; gap: 4px 16px; }
.d-sub span:first-child { color: var(--text); }
.d-levels-wrap { max-height: 340px; overflow: auto; position: relative; scrollbar-width: thin; }
.d-levels thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.d-ladder { padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-panel); margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--r-ctl); margin-bottom: 10px; }
.seg-btn { border: 0; background: transparent; padding: 4px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.chart { height: 400px; border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.chart-fallback { display: grid; place-items: center; height: 100%; color: var(--text-3); }
.d-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; margin-top: 20px; }
.d-grid h3 { font-size: 14px; margin-bottom: 10px; }
.d-signals { list-style: none; margin: 0; padding: 0; }
.d-signals li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.d-signals li:first-child { border-top: 0; }
.d-signals .ic { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-ctl); background: var(--surface-3); color: var(--text-2); flex: none; }
.d-signals .ic.long { background: var(--long-soft); color: var(--long); }
.d-signals .ic.short { background: var(--short-soft); color: var(--short); }
.d-signals .pts { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--text-3); white-space: nowrap; }
.d-levels { width: 100%; border-collapse: collapse; font-size: 13px; }
.d-levels th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 0 6px 8px; }
.d-levels td { padding: 8px 6px; border-top: 1px solid var(--line); }
.d-levels td.mono { font-family: var(--mono); }
.d-levels tr.price-row td { border-top: 1px dashed var(--line-strong); color: var(--text-3); font-size: 12px; padding: 6px; }
.d-levels tr.nearest td:first-child { box-shadow: inset 2px 0 0 var(--text); }
.d-levels .res { color: var(--short); }
.d-levels .sup { color: var(--long); }

/* ---------- dialog & toast ---------- */
dialog {
  border: 1px solid var(--line-strong); border-radius: var(--r-panel); background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 32px)); padding: 22px 24px;
}
dialog::backdrop { background: rgba(5, 7, 10, 0.5); }
dialog h2 { font-size: 18px; margin-bottom: 12px; }
.steps { padding-left: 20px; margin: 0 0 18px; display: grid; gap: 10px; color: var(--text-2); }
.steps b { color: var(--text); }
.topic { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; }
.topic code { font-size: 14px; padding: 6px 10px; color: var(--text); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--invert); color: var(--invert-text); padding: 10px 16px; border-radius: var(--r-ctl); font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ---------- v2: events, mute, levels, outcomes ---------- */
.tag.breakout { background: var(--invert); color: var(--invert-text); }
.tag.rejected { color: var(--text); box-shadow: inset 0 0 0 1px var(--text-2); }
.tag .ph { font-size: 12px; }
.tier.manual { background: var(--invert); color: var(--invert-text); }
.caution { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--warn); font-weight: 600; }
.caution .ph { font-size: 13px; }
.caution-ic { color: var(--warn); font-size: 13px; }
.warn-text { color: var(--warn); }
.ii-meta .long, .oc.right { color: var(--long); }
.ii-meta .short, .oc.wrong { color: var(--short); }
.oc { margin-right: 10px; }
.oc.right, .oc.wrong { font-weight: 600; }
.recent .type-word { color: var(--text-3); font-size: 12px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 36px; z-index: 35; min-width: 210px; padding: 6px;
  display: grid; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}
.menu-title { font-size: 11px; color: var(--text-3); padding: 6px 8px 2px; font-weight: 600; }
.menu button { border: 0; background: transparent; text-align: left; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.menu button:hover { background: var(--surface-3); }
.icon-btn.on { color: var(--warn); border-color: var(--warn); }

.d-mute { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 14px; }
.add-level { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 10px; }
.add-level input, dialog textarea {
  height: 30px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); font-size: 13px; min-width: 0;
}
.add-level input:focus, dialog textarea:focus { outline: none; border-color: var(--text); }
.d-levels td.acts { white-space: nowrap; text-align: right; }
.d-levels td.acts .icon-btn { margin-left: 4px; }
.d-hidden { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.d-hidden .hint { margin: 0; }
.sub-h { font-size: 13px; margin: 16px 0 4px; }

.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
dialog textarea { width: 100%; height: auto; padding: 10px; font-family: var(--mono); line-height: 1.5; resize: vertical; }
.err-text { color: var(--short); font-size: 13px; margin: 8px 0 0; }

/* ---------- responsive ---------- */
@media (max-width: 1360px) {
  .list-head, .row { grid-template-columns: 130px minmax(260px, 1fr) 230px 112px; gap: 16px; }
  .market .mk.optional { display: none; }
}
@media (max-width: 1120px) {
  .layout { display: flex; flex-direction: column; gap: 16px; }
  .rail { display: contents; }
  .inbox { order: 0; }
  .main { order: 1; }
  .history { order: 2; }
  .quality { order: 3; }
  .market { display: none; }
}
@media (max-width: 860px) {
  .overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .list-head { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "coin bias" "ladder ladder" "signals signals"; gap: 12px; }
  .row .coin-cell { grid-area: coin; }
  .row .ladder { grid-area: ladder; }
  .row .signals { grid-area: signals; }
  .row .bias { grid-area: bias; justify-items: end; }
  .file { display: none; }
  .d-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .top-actions .btn span, .top-actions .btn { font-size: 0; gap: 0; padding: 0 9px; }
  .top-actions .btn .ph { font-size: 16px; }
  .health { font-size: 0; gap: 0; padding: 0 12px; }
  .layout { padding: 16px 16px 32px; }
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .overview .tile:first-child { grid-column: 1 / -1; }
  .tile { padding: 12px 14px; }
  .tile-num { font-size: 24px; }
  .search { width: 100%; order: 5; }
  .select { order: 6; flex: 1; }
  .select select { width: 100%; }
  .row { padding: 12px 14px; }
  .row.armed, .row.approaching { padding-left: 12px; }
  .drawer { padding: 16px; }
  .chart { height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  .marker { transition: none; }
  .tick-up, .tick-down { animation: none; }
}

/* Inside Telegram (Mini App): Telegram sets the theme and owns the phone setup */
.in-tg #theme-btn,
.in-tg #phone-btn { display: none; }
.in-tg body { overscroll-behavior: none; }
