/* ==========================================================================
   CoRTIF — Live STOCK Screener (screener page)
   Table on the left · live candlestick chart panel on the right.
   Uses the site's design tokens from style.css (dark + lime).
   ========================================================================== */

/* ---------- offline / demo banner ---------- */
.scr-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 12px 16px;
  background: var(--amber-soft);
  border: 1px solid rgba(245, 197, 24, .35);
  border-radius: var(--r-md);
  color: var(--amber); font-size: .84rem; font-weight: 600; line-height: 1.5;
}
.scr-banner[hidden] { display: none; }

/* ---------- market pulse strip ---------- */
.scr-pulse { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 18px; }
.scr-pulse .stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px 12px; min-width: 0;
  position: relative; overflow: hidden;
}
.scr-pulse .stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent); opacity: .5;
}
.scr-pulse .stat .lbl {
  font-size: .64rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scr-pulse .stat .val {
  font-family: var(--font-head); font-size: 1.18rem; font-weight: 800;
  color: var(--ink); letter-spacing: -.01em; white-space: nowrap;
}
.scr-pulse .stat .sub { font-size: .72rem; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.scr-pulse .stat .sub.up   { color: var(--green); font-weight: 700; }
.scr-pulse .stat .sub.down { color: var(--red);   font-weight: 700; }

.market-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-size: .92rem; font-weight: 800; color: var(--ink);
}
.market-chip::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 0 0 rgba(255, 107, 107, .5);
}
.market-chip.is-open::before {
  background: var(--green); animation: scrPulse 1.8s infinite;
}
@keyframes scrPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(93, 214, 44, .55); }
  50%      { box-shadow: 0 0 0 6px rgba(93, 214, 44, 0); }
}

/* ---------- live status chip ---------- */
.scr-live {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--green-soft); border: 1px solid rgba(93, 214, 44, .35);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  color: var(--green); text-transform: uppercase; white-space: nowrap;
}
.scr-live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: scrPulse 1.6s infinite; }
.scr-live.demo { background: var(--amber-soft); border-color: rgba(245,197,24,.35); color: var(--amber); }
.scr-live.demo .dot { background: var(--amber); animation: none; }

/* ---------- layout: table + chart rail ---------- */
.scr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }

/* ---------- controls ---------- */
.scr-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.scr-controls .tabs { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.scr-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--navy-2); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 7px 14px; min-width: 190px;
}
.scr-search:focus-within { border-color: var(--primary); }
.scr-search svg { flex: none; opacity: .55; }
.scr-search input { background: none; border: 0; outline: 0; color: var(--ink); font: inherit; font-size: .86rem; width: 100%; }
.scr-per {
  background: var(--navy-2); color: var(--muted); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 7px 8px; font-size: .8rem; font-weight: 600; outline: none;
}

/* ---------- table ---------- */
.scr-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.scr-table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  font-size: .64rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint); text-align: right; padding: 10px 12px;
  border-bottom: 1px solid var(--line-2); white-space: nowrap; user-select: none;
}
.scr-table th.sortable { cursor: pointer; }
.scr-table th.sortable:hover { color: var(--ink-2); }
.scr-table th .arrow { font-size: .6rem; margin-left: 3px; color: var(--primary); }
.scr-table th.tl, .scr-table td.tl { text-align: left; }
.scr-table td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.scr-table tbody tr { cursor: pointer; transition: background .15s; }
.scr-table tbody tr:hover { background: rgba(255, 255, 255, .035); }
.scr-table tbody tr.sel { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }

.scr-rank { color: var(--faint); font-weight: 700; font-size: .78rem; }
.scr-coin { display: flex; align-items: center; gap: 10px; }
.scr-coin .nm { font-weight: 700; color: var(--ink); font-size: .88rem; }
.scr-coin .sy { color: var(--faint); font-size: .72rem; margin-top: -2px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
.scr-exch-tag {
  font-size: .56rem; font-weight: 800; letter-spacing: .08em; color: var(--primary);
  background: var(--primary-soft); border-radius: 4px; padding: 1px 5px; vertical-align: 2px;
}
.scr-price { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.scr-chip {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: .76rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.scr-chip.up   { background: var(--green-soft); color: var(--green); }
.scr-chip.down { background: var(--red-soft);   color: var(--red); }
.scr-spark { display: inline-block; vertical-align: middle; }
.scr-vol { font-variant-numeric: tabular-nums; color: var(--muted); }
.scr-star { background: none; border: 0; color: var(--faint); font-size: 1rem; padding: 4px 6px; border-radius: 6px; line-height: 1; }
.scr-star:hover { color: var(--amber); background: rgba(255,255,255,.05); }
.scr-star.on { color: var(--amber); }

.scr-skel td { padding: 13px 12px; }
.scr-skel i {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, #1c1c1c 25%, #262626 50%, #1c1c1c 75%);
  background-size: 200% 100%; animation: scrShimmer 1.3s infinite;
}
@keyframes scrShimmer { to { background-position: -200% 0; } }
.scr-empty td { text-align: center; color: var(--muted); padding: 34px 0; cursor: default; }
.scr-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; font-size: .76rem; color: var(--faint); flex-wrap: wrap;
}

/* ---------- right rail: chart panel + movers ---------- */
.scr-rail { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; }
.scr-rail .panel { margin: 0; }

.qp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qp-head .ico {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #2c2c2c, #1a1a1a); border: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2); font-weight: 800; font-size: .72rem; letter-spacing: .02em;
}
.qp-title { min-width: 0; }
.qp-sym { font-family: var(--font-head); font-weight: 800; font-size: 1.18rem; color: var(--ink); line-height: 1.1; }
.qp-name { color: var(--faint); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.qp-price-wrap { margin-left: auto; text-align: right; }
.qp-price { font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }

.qp-ranges { display: flex; gap: 6px; margin: 12px 0 4px; flex-wrap: wrap; align-items: center; }
.qp-ranges .tab { padding: 5px 11px; font-size: .78rem; }
.qp-ranges .scr-chip { margin-left: auto; }

.qp-legend {
  font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums;
  padding: 4px 0 6px; white-space: nowrap; overflow-x: auto;
}
.qp-legend b { color: var(--ink-2); font-weight: 700; }

.qp-chart-wrap { position: relative; width: 100%; }
.qp-chart-wrap svg { display: block; width: 100%; height: 330px; }
.qp-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #0a0a0a; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; font-size: .72rem; color: var(--ink-2); line-height: 1.5;
  transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap; display: none;
  box-shadow: var(--shadow-1); font-variant-numeric: tabular-nums;
}
.qp-tip b { color: var(--ink); }

.qp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.qp-stats .cell { background: var(--navy-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; min-width: 0; }
.qp-stats .cell .l { font-size: .58rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.qp-stats .cell .v { font-weight: 700; color: var(--ink-2); font-size: .8rem; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.scr-mv-row { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: .82rem; cursor: pointer; border-radius: 6px; }
.scr-mv-row:hover { background: rgba(255,255,255,.04); }
.scr-mv-row .nm { color: var(--ink-2); font-weight: 700; }
.scr-mv-row .pct { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.scr-mv-row .pct.up { color: var(--green); }
.scr-mv-row .pct.down { color: var(--red); }
.scr-mv-h { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 8px 0 2px; }
.scr-mv-h:first-child { margin-top: 0; }

.scr-note-body { font-size: .78rem; color: var(--muted); line-height: 1.6; }
.scr-note-body b { color: var(--ink-2); }

/* ---------- responsive ---------- */
@media (max-width: 1240px) { .scr-pulse { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1120px) {
  .scr-layout { grid-template-columns: 1fr; }
  .scr-rail { position: static; }
}
@media (max-width: 720px) {
  .scr-pulse { grid-template-columns: repeat(2, 1fr); }
  .scr-search { margin-left: 0; order: -1; width: 100%; }
  .qp-stats { grid-template-columns: repeat(2, 1fr); }
  .qp-chart-wrap svg { height: 250px; }
  .scr-coin .sy { max-width: 130px; }
}
