:root {
  --bg: #0b0e11;
  --panel: #151a21;
  --panel-2: #1b222b;
  --line: #2a313c;
  --txt: #eaecef;
  --muted: #848e9c;
  --gold: #f0b90b;
  --up: #0ecb81;
  --down: #f6465d;
  --neutral: #f3ba2f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

/* Wadah halaman sekaligus "container" untuk responsive layout
   (container query aktif baik di layar nyata maupun pratinjau mode HP) */
.app-shell {
  container-type: inline-size;
  container-name: app;
  min-height: 100vh;
}

/* Pratinjau tampilan smartphone di layar desktop */
body.mode-phone { background: #05070a; padding: 18px 0; }
body.mode-phone .app-shell {
  max-width: 430px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 6px #11151b, 0 18px 50px rgba(0, 0, 0, .7);
}

b { font-weight: 600; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { color: var(--gold); font-size: 20px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.price-block { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.pair-select {
  background: var(--panel-2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.price-main { display: flex; align-items: baseline; gap: 10px; }
.live-price { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-change { font-weight: 600; font-variant-numeric: tabular-nums; }
.price-change.up { color: var(--up); }
.price-change.down { color: var(--down); }

.price-meta { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.price-meta b { color: var(--txt); font-weight: 500; }

.conn-block { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--up); box-shadow: 0 0 8px var(--up); }
.dot-off { background: var(--down); box-shadow: 0 0 8px var(--down); }

/* ---------- SAKELAR TAMPILAN (Desktop / HP) ---------- */
.dev-block {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.dev-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.dev-btn:hover { color: var(--txt); }
.dev-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1c1c1c;
  font-weight: 700;
}

/* ---------- TOOLBAR ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.tf-group { display: flex; gap: 4px; }
.tf-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.tf-btn:hover { color: var(--txt); background: var(--panel-2); }
.tf-btn.active { background: var(--gold); color: #1c1c1c; }

.switch { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--gold); cursor: pointer; }
.switch:hover { color: var(--txt); }

.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.updated { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.banner {
  background: #3a2530;
  color: #ffb4c0;
  border-bottom: 1px solid var(--down);
  padding: 8px 18px;
  font-size: 13px;
}

/* ---------- LAYOUT ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 14px;
  padding: 14px 18px;
  align-items: start;
}

.chart-panel, .card, .alerts {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.chart-panel { padding: 12px 14px; overflow: hidden; }

.chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.chart-title { font-weight: 600; font-size: 15px; }
.score-text { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.chart-box { width: 100%; height: 440px; }

.reason-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.reason {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.reason.up { border-color: rgba(14, 203, 129, .45); color: #7fe3c0; }
.reason.down { border-color: rgba(246, 70, 93, .45); color: #ff9aa9; }

/* ---------- SIDE ---------- */
.side { display: flex; flex-direction: column; gap: 14px; }
.card { padding: 14px; }
.card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.verdict { text-align: center; margin-bottom: 12px; }
.verdict-big { font-size: 30px; font-weight: 800; letter-spacing: 1.5px; }
.verdict-big.buy { color: var(--up); }
.verdict-big.sell { color: var(--down); }
.verdict-big.neutral { color: var(--neutral); }
.verdict-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

.meter { margin-bottom: 10px; }
.meter-track {
  position: relative;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--down), #6b5a2a 50%, var(--up));
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  top: -2px;
  width: 3px;
  height: 14px;
  background: #fff;
  border-radius: 2px;
  left: 50%;
  transition: left .5s ease;
  box-shadow: 0 0 6px rgba(255, 255, 255, .8);
}
.meter-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px; }

.disclaimer {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--panel-2);
  border-left: 3px solid var(--gold);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
}

/* ---------- INDICATOR ROWS ---------- */
.ind-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ind-name { width: 74px; font-size: 12px; color: var(--muted); }
.ind-val { width: 44px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }

.gauge {
  position: relative;
  flex: 1;
  height: 8px;
  background: var(--panel-2);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.gauge-fill { height: 100%; width: 0; background: var(--neutral); transition: width .4s ease, background .4s ease; }
.g-over {
  position: absolute;
  right: 30%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, .25);
}

.ind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 12px; }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; }

/* ---------- BADGES ---------- */
.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  padding: 3px 9px;
  border-radius: 5px;
}
.badge-buy { background: rgba(14, 203, 129, .15); color: var(--up); border: 1px solid rgba(14, 203, 129, .5); }
.badge-sell { background: rgba(246, 70, 93, .15); color: var(--down); border: 1px solid rgba(246, 70, 93, .5); }
.badge-neutral { background: rgba(243, 186, 47, .12); color: var(--neutral); border: 1px solid rgba(243, 186, 47, .45); }

/* ---------- MTF TABLE ---------- */
.mtf { width: 100%; border-collapse: collapse; font-size: 13px; }
.mtf th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}
.mtf td { padding: 7px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.mtf tr:last-child td { border-bottom: none; }
.mtf tr.active-row td { background: rgba(240, 185, 11, .07); }
.mtf .sc-up { color: var(--up); }
.mtf .sc-down { color: var(--down); }
.mtf-final { margin-top: 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--muted); }

/* ---------- ALERTS ---------- */
.alerts { margin: 0 18px 14px; padding: 12px 14px; }
.alerts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.alerts-head h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 5px;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--txt); border-color: var(--muted); }

/* Tombol refresh screener */
.btn-refresh { color: var(--gold); border-color: rgba(240, 185, 11, .45); font-size: 12px; padding: 5px 12px; }
.btn-refresh:hover { color: var(--gold); border-color: var(--gold); background: rgba(240, 185, 11, .12); }
.btn-refresh:disabled { opacity: .55; cursor: progress; }
.btn-refresh .ico { display: inline-block; }
.btn-refresh.spin .ico { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert-list { max-height: 170px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: var(--panel-2);
  border-left: 3px solid var(--neutral);
  border-radius: 0 6px 6px 0;
  padding: 7px 10px;
  font-size: 12.5px;
}
.alert-item.buy { border-left-color: var(--up); }
.alert-item.sell { border-left-color: var(--down); }
.alert-item .t { color: var(--muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.foot {
  text-align: center;
  color: #5b6570;
  font-size: 11px;
  padding: 0 18px 18px;
}

/* ---------- PROFIT (estimasi keuntungan) ---------- */
.profit-inputs {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.profit-inputs label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
}
.profit-inputs input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.profit-inputs input:focus { outline: none; border-color: var(--gold); }

.profit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.profit-note {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--panel-2);
  border-left: 3px solid var(--gold);
  padding: 8px 10px;
  border-radius: 0 6px 6px 0;
}
.card-profit { border-color: rgba(240, 185, 11, .35); }

/* ---------- WATCHLIST ---------- */
.watchlist {
  margin: 0 18px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.wl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.wl-head h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.wl-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.wl-chip {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.wl-chip-buy { color: var(--up); border-color: rgba(14, 203, 129, .5); background: rgba(14, 203, 129, .1); }
.wl-chip-sell { color: var(--down); border-color: rgba(246, 70, 93, .5); background: rgba(246, 70, 93, .1); }
.wl-chip-pot { color: var(--gold); border-color: rgba(240, 185, 11, .5); background: rgba(240, 185, 11, .08); }

.wl-scroll { overflow-x: auto; }

table.wl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.wl th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.wl td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wl tr:last-child td { border-bottom: none; }
.wl .num { text-align: right; }

.wl-row { cursor: pointer; transition: background .15s; }
.wl-row:hover { background: var(--panel-2); }
.wl-active { background: rgba(240, 185, 11, .06); }
.wl-buy td:first-child { box-shadow: inset 3px 0 0 var(--up); }
.wl-sell td:first-child { box-shadow: inset 3px 0 0 var(--down); }

.wl-pair b { display: block; font-size: 13px; }
.wl-name { font-size: 10.5px; color: var(--muted); }

/* ---------- LOGO IKON KOIN ---------- */
.coin-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--panel-2);
  border: 1px solid var(--line);
  vertical-align: -4px;
  margin-right: 6px;
  flex: none;
}
.coin-ico.sm { width: 15px; height: 15px; margin-right: 5px; vertical-align: -3px; }
.search-item b .coin-ico { margin-right: 6px; }
.c-chg.up { color: var(--up); }
.c-chg.down { color: var(--down); }
.c-spark canvas { display: block; }
.sc-up { color: var(--up); }
.sc-down { color: var(--down); }

.wl-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- TOOLS: tambah koin & sort rekomendasi ---------- */
.wl-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.search-box { position: relative; flex: 1; min-width: 260px; }
.search-box input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
}
.search-box input:focus { outline: none; border-color: var(--gold); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 30;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
}
.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #232b36; }
.search-item .si-name { color: var(--muted); font-size: 11.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item .si-price { font-variant-numeric: tabular-nums; color: var(--gold); }
.search-item .si-add {
  background: rgba(14, 203, 129, .15);
  border: 1px solid rgba(14, 203, 129, .5);
  color: var(--up);
  border-radius: 5px;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
}
.search-item .si-add:hover { background: rgba(14, 203, 129, .3); }
.search-item.si-exists .si-add { opacity: .45; cursor: default; }
.search-empty { padding: 10px; font-size: 12px; color: var(--muted); }

.sort-chips { display: flex; gap: 6px; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 20px;
  font-size: 11.5px;
  padding: 4px 11px;
  cursor: pointer;
}
.chip:hover { color: var(--txt); }
.chip.active { background: var(--gold); border-color: var(--gold); color: #1c1c1c; font-weight: 600; }

/* ---------- REKOMENDASI ---------- */
.recs {
  margin: 14px 18px;
  background: var(--panel);
  border: 1px solid rgba(240, 185, 11, .3);
  border-radius: 10px;
  padding: 12px 14px;
}
.rec-rank {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.rec-rank.top { background: rgba(240, 185, 11, .18); border-color: var(--gold); color: var(--gold); font-weight: 700; }
.rec-why { font-size: 11.5px; color: var(--muted); max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn-mini {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 5px;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { color: var(--txt); border-color: var(--muted); }
.btn-mini.go { border-color: rgba(91, 140, 255, .5); color: #8fb0ff; }
.btn-mini.go:hover { background: rgba(91, 140, 255, .15); }
.btn-mini.added { opacity: .4; cursor: default; }

/* hapus koin dari watchlist */
.wl-del {
  margin-left: 6px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 5px;
  width: 20px;
  height: 20px;
  line-height: 1;
  font-size: 12px;
  cursor: pointer;
  vertical-align: middle;
}
.wl-del:hover { color: var(--down); border-color: var(--down); }

/* ---------- HEADER FX ---------- */
.fx-text { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- RESPONSIVE ----------
   Memakai container query (.app-shell), sehingga aturan yang sama berlaku untuk:
   desktop lebar, tablet, smartphone sungguhan, dan pratinjau mode HP (🖥/📱). */

/* --- Desktop sempit / tablet --- */
@container app (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .chart-box { height: 340px; }
  .price-block { gap: 10px; }
  .conn-block { margin-left: 0; }
  .profit-inputs { grid-template-columns: 1fr 1fr 1fr; }
  /* kartu samping berbaris 2 kolom */
  .side { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}

/* --- Smartphone --- */
@container app (max-width: 640px) {
  body { font-size: 13px; }

  /* header menumpuk */
  .topbar { gap: 8px 10px; padding: 8px 10px; }
  .brand { order: 1; }
  .brand-sub { display: none; }
  .brand-name { font-size: 16px; }
  .dev-block { order: 2; margin-left: auto; padding: 2px; }
  .dev-btn { font-size: 11px; padding: 4px 8px; }
  .price-block { order: 3; width: 100%; gap: 8px; }
  .pair-select { flex: 1; min-width: 130px; font-size: 13px; }
  .live-price { font-size: 21px; }
  .price-main { gap: 8px; }
  .price-meta { gap: 10px; font-size: 11px; flex-wrap: wrap; }
  .conn-block { order: 4; width: 100%; margin-left: 0; flex-wrap: wrap; }

  /* toolbar */
  .toolbar { gap: 8px; padding: 6px 10px; }
  .toolbar-right { margin-left: 0; gap: 10px; flex-wrap: wrap; }
  .switch { font-size: 12px; }
  .tf-btn { padding: 5px 9px; font-size: 12px; }

  /* konten */
  .layout { padding: 10px; gap: 10px; }
  .chart-box { height: 260px; }
  .chart-head { flex-wrap: wrap; gap: 8px; }
  .side { grid-template-columns: 1fr; }        /* kembali 1 kolom */
  .verdict-big { font-size: 26px; }
  .profit-inputs { grid-template-columns: 1fr 1fr; }

  .recs, .watchlist { margin: 10px 8px; padding: 10px; }
  .alerts { margin: 0 8px 12px; padding: 10px; }
  .wl-head { gap: 8px; margin-bottom: 8px; }
  .wl-summary { width: 100%; }
  .wl-tools { flex-direction: column; align-items: stretch; gap: 8px; }
  .search-box { min-width: 0; }
  .sort-chips { flex-wrap: wrap; }
  .wl-note { font-size: 10.5px; }

  /* tabel: ringkas + kolom pertama menempel saat digeser */
  table.wl { min-width: 720px; font-size: 12px; }
  .wl th, .wl td { padding: 6px; }
  .wl th:first-child, .wl td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
  }
  .wl-row:hover td:first-child { background: var(--panel-2); }
  .wl-active td:first-child { background: #1d232c; }
  .rec-table { min-width: 640px; }
  .rec-table th:nth-child(10), .rec-table td:nth-child(10) { display: none; } /* kolom alasan */
  .rec-actions { flex-direction: column; gap: 4px; }

  .foot { padding: 0 10px 16px; }
}

/* --- Layar sangat kecil --- */
@container app (max-width: 380px) {
  .profit-inputs { grid-template-columns: 1fr; }
  .ind-grid, .profit-grid { grid-template-columns: 1fr; }
  .live-price { font-size: 19px; }
}
