/* ==========================================================================
   GoldMind Ticker page — uses tokens from app.css (--bg-0/-1/-2, --gold, etc)
   to stay visually identical to chart.php / admin / member center.
   ========================================================================== */

.tk-shell {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 60px);
  background: var(--bg-0);
}

/* ===== TOPBAR ============================================================ */
.tk-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tk-symBtn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 12px;
  color: var(--text); cursor: pointer; font-weight: 600;
  transition: border-color .15s;
}
.tk-symBtn:hover { border-color: var(--gold-line); }
.tk-symBtn .tk-sym { color: var(--gold); font-family: var(--font-mono); font-size: 15px; letter-spacing: 0.5px; }
.tk-symBtn .tk-symName { font-size: 12px; font-weight: 400; }
.tk-symBtn .tk-caret { transform: rotate(90deg); opacity: .7; }

.tk-symPanel {
  position: absolute; z-index: 80;
  margin-top: 4px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 480px; max-height: 70vh; overflow: auto;
  box-shadow: var(--shadow);
  padding: 12px;
}
.tk-symPanel input {
  width: 100%; padding: 8px 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
  margin-bottom: 8px;
}
.tk-symPanel .tk-grp { font-size: 11px; color: var(--text-faint); letter-spacing: 1px;
                       margin: 8px 0 4px; text-transform: uppercase; }
.tk-symPanel button {
  display: block; width: 100%; text-align: left;
  background: transparent; color: var(--text);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 10px; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.tk-symPanel button:hover  { background: var(--bg-2); border-color: var(--line); }
.tk-symPanel button.active { background: rgba(212,175,55,.10); border-color: var(--gold-line); color: var(--gold); }
.tk-symPanel button .meta  { color: var(--text-faint); font-size: 11px; margin-left: 4px; }

/* OHLC strip in topbar */
.tk-ohlc {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; flex: 1; min-width: 0; overflow: hidden;
}
.tk-ohlc-date { color: var(--text-muted); font-family: var(--font-mono); }
.tk-ohlc-pair { white-space: nowrap; }
.tk-ohlc-chg {
  padding: 3px 10px; border-radius: 6px; font-weight: 700; font-size: 13px;
  background: rgba(255,255,255,.05);
}
.tk-ohlc-chg.up   { color: var(--green); background: rgba(16,185,129,.12); }
.tk-ohlc-chg.down { color: var(--red);   background: rgba(239,68,68,.12); }

.tk-toolbar-actions { display: flex; gap: 8px; }

/* ===== CATEGORY ROW ====================================================== */
.tk-cats {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tk-cats-list { display: flex; gap: 8px; flex-wrap: wrap; }
.tk-cats-list button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px;
  color: var(--text); font-size: 12px; cursor: pointer;
  transition: all .15s;
}
.tk-cats-list button:hover  { border-color: currentColor; }
.tk-cats-list button.active { background: rgba(255,255,255,.04); border-color: currentColor; color: var(--cat-color); }
.tk-cats-list button .count { color: var(--text-faint); font-family: var(--font-mono); font-size: 11px; }

.tk-cats-sub { display: flex; gap: 4px; margin-left: auto; }
.tk-cats-sub button {
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 4px 10px;
  color: var(--text-muted); font-size: 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.tk-cats-sub button.active { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-line); }

/* ===== MAIN GRID ========================================================= */
.tk-main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1px; background: var(--line);
  flex: 1; min-height: 0;
}

/* Tablet: keep 2 cols but news narrower */
@media (max-width: 1100px) {
  .tk-main { grid-template-columns: 1fr 320px; }
}

/* Phone/small tablet: stack vertically — chart on top, news below */
@media (max-width: 820px) {
  .tk-main { grid-template-columns: 1fr; grid-template-rows: 60vh auto; }
  .tk-news-col { max-height: 50vh; }
  .tk-chart { min-height: 360px; }
  .tk-topbar { padding: 8px 10px; gap: 8px; font-size: 12px; }
  .tk-topbar .tk-symBtn { padding: 4px 8px; }
  .tk-topbar .tk-symName { display: none; }
  .tk-ohlc { font-size: 11px; gap: 6px; }
  .tk-ohlc-pair { white-space: nowrap; }
  .tk-toolbar-actions .btn { padding: 4px 8px; font-size: 11px; }
  .tk-cats { padding: 8px 10px; font-size: 11px; }
  .tk-cats-list button { padding: 4px 10px; font-size: 11px; }
  .tk-symPanel { width: 92vw; max-height: 60vh; }

  /* Floating panels → bottom sheet on phone */
  .tk-floating-panel {
    right: 0; left: 0; top: auto; bottom: 0;
    width: 100%; max-height: 70vh;
    border-radius: 14px 14px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  .tk-range-popup { width: 88vw; left: 6vw !important; }

  /* Prediction body taller on phone */
  .tk-pred-body { max-height: 50vh; }
  .tk-pred-cards { grid-template-columns: 1fr; }
}

/* Very small phones */
@media (max-width: 420px) {
  .tk-toolbar-actions { display: none; }   /* hide secondary buttons */
  .tk-cats-sub { width: 100%; margin-left: 0; justify-content: flex-start; }
}

.tk-chart-col {
  display: flex; flex-direction: column;
  background: var(--bg-0);
  min-width: 0;
}

.tk-chart {
  flex: 1;
  min-height: 480px;
  background: var(--bg-0);
  position: relative;
}
.tk-chart svg  { width: 100%; height: 100%; display: block; }
.tk-chart canvas { position: absolute; left: 0; top: 0; pointer-events: none; }

/* range-popup floating */
.tk-range-popup {
  position: fixed; z-index: 90;
  width: 320px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.tk-range-popup h4 { margin: 0 0 6px; font-size: 14px; }
.tk-range-popup .preset {
  display: block; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 7px 10px; margin: 4px 0;
  color: var(--text); font-size: 12px; cursor: pointer;
}
.tk-range-popup .preset:hover { border-color: var(--gold-line); color: var(--gold); }
.tk-range-popup input[type=text] {
  width: 100%; padding: 7px 9px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
  margin-top: 6px; font-size: 12px;
}
.tk-range-popup .meta { color: var(--text-faint); font-size: 11px; margin-bottom: 8px; }
.tk-range-popup .pcg-up   { color: var(--green); font-weight: 700; }
.tk-range-popup .pcg-down { color: var(--red);   font-weight: 700; }

/* ===== PREDICTION (collapsible) ========================================== */
.tk-prediction {
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  flex-shrink: 0;
}
.tk-pred-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: transparent; border: none; color: var(--text);
  font-weight: 600; cursor: pointer; font-size: 14px;
}
.tk-pred-toggle:hover { background: var(--bg-2); }
.tk-pred-toggle #tk-pred-chev { transition: transform .2s; transform: rotate(90deg); }
.tk-prediction.open #tk-pred-chev { transform: rotate(-90deg); }
.tk-pred-body { padding: 16px; max-height: 60vh; overflow: auto; border-top: 1px solid var(--line); }

/* prediction sub-cards */
.tk-pred-section { margin-bottom: 24px; }
.tk-pred-section h4 {
  font-size: 13px; color: var(--gold); letter-spacing: 1px;
  text-transform: uppercase; margin: 0 0 8px; font-weight: 700;
}
.tk-hero-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px;
}
.tk-hero-dir { font-size: 28px; font-weight: 800; }
.tk-hero-dir.up   { color: var(--green); }
.tk-hero-dir.down { color: var(--red); }
.tk-hero-conf { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }
.tk-conf-bar { height: 4px; background: var(--bg-3); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.tk-conf-bar > i { display: block; height: 100%; background: var(--gold); }

.tk-pred-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px;
}
.tk-pred-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
}
.tk-pred-card .h { font-size: 11px; color: var(--text-faint); letter-spacing: 1px; }
.tk-pred-card .d { font-size: 18px; font-weight: 700; margin: 4px 0; }
.tk-pred-card .d.up { color: var(--green); } .tk-pred-card .d.down { color: var(--red); }
.tk-pred-card .drv { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.6; }
.tk-pred-card .drv b { color: var(--text); font-weight: 500; }
.tk-pred-card .zbar  { display: inline-block; width: 28px; height: 4px; background: var(--bg-3); border-radius: 2px; vertical-align: middle; margin: 0 4px; overflow: hidden; }
.tk-pred-card .zbar i { display: block; height: 100%; background: var(--gold); }

.tk-similar-period {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px; margin: 4px 0;
  font-size: 12px;
}
.tk-similar-period .ret { font-family: var(--font-mono); }
.tk-similar-period .up   { color: var(--green); }
.tk-similar-period .down { color: var(--red); }

/* ===== NEWS PANEL ======================================================== */
.tk-news-col {
  background: var(--bg-1);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
}
.tk-news-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.tk-news-head h3 { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; }
.btn-link {
  background: transparent; border: none; color: var(--gold);
  font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0;
}

.tk-news-list { flex: 1; overflow-y: auto; padding: 8px; }
.tk-news-list::-webkit-scrollbar { width: 6px; }
.tk-news-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.tk-news-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px;
  font-size: 12.5px; line-height: 1.5;
  cursor: pointer;
  transition: border-left-color .15s, background .15s;
}
.tk-news-card.pos { border-left-color: var(--green); }
.tk-news-card.neg { border-left-color: var(--red); }
.tk-news-card.neu { border-left-color: var(--blue); }
.tk-news-card.dim { opacity: .35; }
.tk-news-card.locked { background: rgba(56,189,248,.08); border-color: var(--blue); }
.tk-news-card .title { font-weight: 600; margin-bottom: 4px; }
.tk-news-card .meta  { color: var(--text-faint); font-size: 11px;
                       display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.tk-news-card .meta .ret { font-family: var(--font-mono); }
.tk-news-card .meta .ret.up   { color: var(--green); }
.tk-news-card .meta .ret.down { color: var(--red); }
.tk-news-card .summary { color: var(--text-muted); margin: 4px 0; }
.tk-news-card .reasons { margin-top: 6px; font-size: 11.5px; }
.tk-news-card .reasons b { color: var(--text); }
.tk-news-card .reasons .up-reason   { color: var(--green); display: block; margin: 2px 0; }
.tk-news-card .reasons .down-reason { color: var(--red);   display: block; margin: 2px 0; }
.tk-news-card .actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tk-news-card .actions button {
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 3px 8px;
  color: var(--text-muted); font-size: 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.tk-news-card .actions button:hover { color: var(--gold); border-color: var(--gold-line); }

.tk-empty { text-align: center; color: var(--text-faint); padding: 40px 16px; font-size: 12px; }

/* ===== FLOATING SIDE PANELS ============================================== */
.tk-floating-panel {
  position: fixed; right: 16px; top: 80px;
  width: 420px; max-height: calc(100vh - 100px);
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 70; overflow: auto;
  padding: 14px;
}
.tk-floating-panel .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.tk-floating-panel .head h3 { margin: 0; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tk-floating-panel .close {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 4px;
}
.tk-floating-panel .close:hover { color: var(--red); background: var(--bg-2); }

.tk-floating-panel .stat-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0;
}
.tk-floating-panel .stat-cell {
  background: var(--bg-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px;
}
.tk-floating-panel .stat-cell b { display: block; font-family: var(--font-mono); color: var(--text); font-size: 14px; margin-top: 2px; }

.tk-loading { color: var(--text-faint); padding: 24px; text-align: center; font-size: 12px; }
.tk-error   { color: var(--red);        padding: 12px; font-size: 12px; }

/* ===== CHART INTERNAL D3 STYLES ========================================== */
.tk-chart .axis line, .tk-chart .axis path { stroke: var(--line); }
.tk-chart .axis text                       { fill: var(--text-faint); font-size: 10px; }
.tk-chart .grid line                       { stroke: var(--line); stroke-dasharray: 2,2; opacity: .5; }
.tk-chart .candle.up   { fill: var(--green); stroke: var(--green); }
.tk-chart .candle.down { fill: var(--red);   stroke: var(--red);   }
.tk-chart .crosshair   { stroke: var(--gold); stroke-dasharray: 3,3; opacity: .6; }
.tk-chart .brush .selection { fill: rgba(212,175,55,.18); stroke: var(--gold); }
