@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── tokens ── */
:root {
  --bg:       #09090b;
  --bg2:      #111113;
  --surface:  #18181b;
  --surface2: #1c1c1f;
  --border:   #27272a;
  --border2:  #1f1f22;
  --text:     #f4f4f5;
  --muted:    #71717a;
  --dim:      #3f3f46;
  --accent:   #d4a853;
  --a-bg:     rgba(212,168,83,.09);
  --a-border: rgba(212,168,83,.22);
  --green:    #4ade80;
  --red:      #f87171;
  --yellow:   #fbbf24;
  --mono:     'JetBrains Mono', ui-monospace, monospace;
  --sans:     'Outfit', system-ui, sans-serif;
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* no body-level horizontal scroll */
  max-width: 100vw;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── header ── */
header {
  position: sticky; top: 0; z-index: 50;
  height: 52px;
  background: rgba(9,9,11,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  overflow: hidden; /* never let header cause body scroll */
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; min-width: 0; }
.logo  { width: 26px; height: 26px; flex-shrink: 0; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; }
.brand-name .accent { color: var(--accent); }
.brand-tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; white-space: nowrap; }

.header-mid {
  display: flex; align-items: center; gap: 16px;
  font-size: 11px; color: var(--muted);
  flex: 1; justify-content: center; min-width: 0; overflow: hidden;
}
.header-mid .kv { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.header-mid .kv strong { font-family: var(--mono); color: var(--text); font-weight: 500; font-size: 11px; }
.header-mid .sep { color: var(--border); }
@media (max-width: 700px) { .header-mid { display: none; } }

.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; min-width: 0; }

/* status dot */
.status-row { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(74,222,128,.15); transition: background .15s; }
.dot.err { background: var(--red); box-shadow: 0 0 0 2px rgba(248,113,113,.15); }
.dot.pulse { animation: dotPulse .9s ease-out; }
@keyframes dotPulse {
  0%  { box-shadow: 0 0 0 0   rgba(74,222,128,.5); }
  70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); }
  100%{ box-shadow: 0 0 0 2px rgba(74,222,128,.15); }
}

/* chip / pill */
.chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 500; font-family: var(--mono);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  white-space: nowrap;
}
.chip-muted { color: var(--muted); }

/* live pill */
.live-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  font-family: var(--mono); letter-spacing: .4px; text-transform: uppercase;
  background: rgba(74,222,128,.08); color: var(--green); border: 1px solid rgba(74,222,128,.25);
}
.live-pill.offline { background: rgba(248,113,113,.08); color: var(--red); border-color: rgba(248,113,113,.25); }
.lp-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.live-pill.offline .lp-dot { animation: none; }
@keyframes blink { 0%,40%,100%{opacity:1} 50%{opacity:.2} }
.heartbeat-bar { display: inline-flex; gap: 2px; align-items: center; height: 10px; margin-left: 2px; }
.hb-tick { width: 2px; height: 100%; background: var(--border); border-radius: 1px; transition: background .5s; }
.hb-tick.on { background: var(--green); }

/* ── tape ── */
.tape {
  position: relative; overflow: hidden;
  background: var(--bg2); border-bottom: 1px solid var(--border2);
  padding: 7px 0;
}
.tape .scroll {
  display: inline-flex; gap: 24px; padding-left: 24px;
  white-space: nowrap; animation: tapeScroll 160s linear infinite; will-change: transform;
}
.tape:hover .scroll { animation-play-state: paused; }
@keyframes tapeScroll { from{transform:translateX(0)} to{transform:translateX(-50%)} }
.tape .item { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-family: var(--mono); }
.tape .item .sym { font-weight: 600; color: var(--text); letter-spacing: .3px; }
.tape .item .px  { color: var(--muted); }
.tape .item .chg { font-weight: 600; }
.tape .item.flag .sym { color: var(--accent); text-shadow: 0 0 10px rgba(212,168,83,.3); }
.tape .item::after { content:""; width:3px; height:3px; border-radius:50%; background:var(--dim); margin-left:17px; }
.tape-fade {
  position: absolute; top: 0; bottom: 0; width: 48px; pointer-events: none; z-index: 1;
}
.tape-fade.left  { left:  0; background: linear-gradient(90deg, var(--bg), transparent); }
.tape-fade.right { right: 0; background: linear-gradient(-90deg, var(--bg), transparent); }
.tape-empty { color: var(--muted); font-size: 11px; padding: 0 20px; }

/* ── scan bar ── */
.scan-bar {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  padding: 7px 20px;
  background: var(--bg2); border-bottom: 1px solid var(--border2);
  font-size: 11px; color: var(--muted);
}
.scan-bar .kv { display: flex; align-items: center; gap: 5px; }
.scan-bar .v  { font-family: var(--mono); color: var(--text); font-size: 11px; }
.scan-bar .countdown { color: var(--accent); font-weight: 600; }
.scan-bar .flash-now { color: var(--green); }
.scan-bar .ml { margin-left: auto; }

/* ── layout ── */
main { padding: 18px 20px; max-width: 1440px; margin: 0 auto; overflow: hidden; }
.layout { display: grid; grid-template-columns: 1fr 272px; gap: 16px; align-items: start; min-width: 0; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}

/* ── table section ── */
.table-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; min-width: 0;
}
.table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.table-head h2 {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
}
.table-head-right { display: flex; align-items: center; gap: 8px; }
.table-wrap { max-height: calc(100vh - 220px); overflow-x: auto; overflow-y: auto; }
/* On mobile contain the scroll to the wrapper, never the body */
@media (max-width: 768px) { .table-wrap { max-height: none; } }

/* table */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border2); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th.l, td.l { text-align: left; }
th {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); background: var(--surface); position: sticky; top: 0; z-index: 1;
}
tbody tr { transition: background .12s; cursor: pointer; }
tbody tr:hover { background: var(--surface2); }
tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
tbody tr.flash { background: rgba(212,168,83,.1) !important; }

.coin { display: flex; align-items: center; gap: 9px; }
.coin img { width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); }
.coin .sym  { font-weight: 600; font-size: 13px; }
.coin .name { color: var(--muted); font-size: 11px; }
.pos  { color: var(--green); }
.neg  { color: var(--red); }
.warn { color: var(--yellow); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.score { font-family: var(--mono); font-weight: 600; }
.score-bar {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  height: 4px; border-radius: 2px; min-width: 6px;
  background: linear-gradient(90deg, var(--yellow), var(--accent));
}
.spark { width: 110px; height: 26px; }
.ext-link { color: var(--muted); font-size: 13px; transition: color .15s; }
.ext-link:hover { color: var(--accent); text-decoration: none; }

.empty {
  padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px;
}

/* AMD badges */
.amd-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  letter-spacing: .5px; white-space: nowrap;
}
.amd-none      { color: var(--dim); font-size: 11px; }
.amd-accum     { background: rgba(113,113,122,.15); color: var(--muted); border: 1px solid rgba(113,113,122,.3); }
.amd-manip     { background: rgba(251,191,36,.12);  color: var(--yellow); border: 1px solid rgba(251,191,36,.3); }
.amd-dist-bull { background: rgba(74,222,128,.1);   color: var(--green);  border: 1px solid rgba(74,222,128,.3); }
.amd-dist-bear { background: rgba(248,113,113,.1);  color: var(--red);    border: 1px solid rgba(248,113,113,.3); }

/* FVG entry zones (desktop table column) */
.fvg-cell    { display: flex; flex-direction: column; gap: 3px; line-height: 1.2; }
.fvg-label   { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--dim); }
.fvg-zone    { font-family: var(--mono); font-size: 11px; font-weight: 500; }
.fvg-bullish { color: var(--green); }
.fvg-bearish { color: var(--red); }
.fvg-none    { color: var(--dim); font-size: 11px; }

/* Mobile inline AMD/FVG — shown only on small screens */
.coin-analysis { display: none; }
.fvg-mini { font-family: var(--mono); font-size: 10px; font-weight: 600; }

/* hide on mobile — keep table readable without horizontal scroll */
@media (max-width: 768px) {
  .hide-mobile { display: none; }
  /* tighten remaining visible cells */
  th, td { padding: 8px 6px; }
  .coin img { width: 18px; height: 18px; }
  .coin .name { display: none; }
  .coin { gap: 6px; }
  .score-bar { display: none; }
  /* hide status-row text on very small screens */
  #statusText { display: none; }
  .brand-tag { display: none; }
  .chip { padding: 3px 7px; font-size: 10px; }
  /* show AMD/FVG inline under coin symbol */
  .coin-analysis {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
    margin-top: 4px;
  }
}

/* flip digits */
.flip { display: inline-flex; gap: 0; line-height: 1; font-variant-numeric: tabular-nums; }
.flip-char { display: inline-block; min-width: .55em; text-align: center; backface-visibility: hidden; }
.flip-char.new { animation: flipIn .35s cubic-bezier(.2,.7,.3,1); }
@keyframes flipIn {
  0%  { transform: rotateX(-80deg); opacity: 0; color: var(--accent); }
  60% { transform: rotateX(6deg);  opacity: 1; }
  100%{ transform: rotateX(0);    opacity: 1; }
}

/* ── sidebar ── */
.sidebar { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.s-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.s-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin-bottom: 14px;
}

/* thresholds */
.thresholds { display: grid; grid-template-columns: 1fr auto auto; gap: 5px 10px; align-items: center; }
.th-key  { font-size: 12px; color: var(--muted); }
.th-op   { font-size: 12px; color: var(--dim); text-align: center; }
.th-val  { font-family: var(--mono); font-size: 12px; color: var(--accent); text-align: right; }

/* alert steps */
.alert-steps {
  display: flex; flex-direction: column; gap: 8px;
  padding-left: 0; list-style: none; counter-reset: steps;
}
.alert-steps li {
  counter-increment: steps;
  display: flex; gap: 9px; align-items: baseline;
  font-size: 12px; color: var(--muted); line-height: 1.5;
}
.alert-steps li::before {
  content: counter(steps);
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--accent);
}
.alert-steps li a { color: var(--accent); font-weight: 600; }

/* form */
.form-gap { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .3px; }

#subTarget {
  width: 100%; background: var(--surface2); color: var(--accent);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 14px; font-family: var(--mono); font-size: 18px;
  letter-spacing: 6px; text-align: center; text-transform: uppercase;
  transition: border-color .2s, box-shadow .2s; outline: none;
}
#subTarget::placeholder { color: var(--dim); letter-spacing: 4px; font-size: 14px; }
#subTarget:focus { border-color: var(--a-border); box-shadow: 0 0 0 3px rgba(212,168,83,.09); }

/* buttons */
.btn-primary {
  width: 100%; margin-top: 8px;
  background: var(--accent); color: #09060a;
  border: 0; border-radius: 8px; padding: 9px 14px;
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 11px; font-family: var(--sans); font-size: 12px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* cfg note */
.cfg-note { font-size: 11px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.cfg-note .mono { font-family: var(--mono); font-size: 10px; color: var(--dim); }

/* ── toast ── */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  background: var(--surface2); border: 1px solid var(--border);
  padding: 10px 14px; border-radius: 8px;
  font-size: 12px; max-width: 300px;
  opacity: 0; transform: translateY(6px); transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── modal ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: min(960px,94vw);
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04);
}
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.mh-left { display: flex; align-items: center; gap: 12px; }
.mh-left img { width: 32px; height: 32px; border-radius: 50%; }
.mh-symbol { font-size: 17px; font-weight: 700; }
.mh-pair { color: var(--muted); font-weight: 400; font-size: 13px; }
.mh-name { color: var(--muted); font-size: 11px; margin-top: 1px; }
.mh-stats { display: flex; gap: 20px; font-size: 12px; font-family: var(--mono); }
.mh-stat { display: flex; flex-direction: column; gap: 2px; }
.mh-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.mh-value { font-size: 14px; color: var(--text); }
.range-toggle {
  display: inline-flex; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; padding: 2px;
}
.range-toggle button {
  background: transparent; color: var(--muted); border: 0;
  padding: 4px 10px; font-size: 11px; font-family: var(--sans);
  border-radius: 6px; cursor: pointer; font-weight: 500; transition: all .15s;
}
.range-toggle button.active { background: var(--border); color: var(--text); }
.modal-close {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; border-radius: 7px; padding: 0;
  font-size: 16px; line-height: 1; cursor: pointer; transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.chart-wrap { flex: 1; min-height: 420px; padding: 12px 16px 20px; position: relative; }
.chart-wrap .chart { width: 100%; height: 420px; }
.chart-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 12px; line-height: 1.6;
  background: var(--surface); text-align: center;
  padding: 24px;
}
