:root {
  --bg: #0b0e14;
  --surface: #131822;
  --surface-2: #1a2030;
  --border: #232a38;
  --text: #e8ecf3;
  --muted: #8b95a7;
  --up: #16c784;
  --up-bg: rgba(22, 199, 132, .14);
  --down: #ea3943;
  --down-bg: rgba(234, 57, 67, .14);
  --accent: #8b6cff;
  --accent-bg: rgba(139, 108, 255, .16);
  --amber: #f5a524;
  --amber-bg: rgba(245, 165, 36, .14);
  --stop: #ef4444;
  --stop-bg: rgba(239, 68, 68, .16);
  --radius: 14px;
  --gap: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f0f2f7; --border: #e2e6ee; --text: #121826;
    --muted: #64708a; --up: #0e9f6e; --up-bg: rgba(14, 159, 110, .12); --down: #d92d39;
    --down-bg: rgba(217, 45, 57, .1); --accent: #6d4aff; --accent-bg: rgba(109, 74, 255, .1);
    --amber: #b7791f; --amber-bg: rgba(245, 165, 36, .16); --stop: #dc2626; --stop-bg: rgba(220, 38, 38, .1);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  overflow-x: hidden;
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom);
}
h2 { font-size: 15px; margin: 0; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.live-dot.on { background: var(--up); box-shadow: 0 0 0 4px var(--up-bg); }
.live-dot.off { background: var(--stop); box-shadow: 0 0 0 4px var(--stop-bg); }
.coins { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.coins::-webkit-scrollbar { display: none; }
.coin {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; padding: 6px 12px; text-align: left; cursor: pointer; min-width: 104px; font: inherit;
}
.coin b { display: block; font-size: 13px; }
.coin span { font-size: 12px; }
.coin.active { border-color: var(--accent); background: var(--accent-bg); }

/* alerts */
.alert-banner { margin: 12px 16px 0; border-radius: var(--radius); padding: 12px 14px; border: 1px solid; }
.alert-banner.stop { background: var(--stop-bg); border-color: color-mix(in srgb, var(--stop) 55%, transparent); --tone: var(--stop); }
.alert-banner.caution { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 55%, transparent); --tone: var(--amber); }
.alert-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.alert-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px;
  background: color-mix(in srgb, var(--tone) 18%, transparent); color: var(--tone);
}
.alert-title { font-weight: 800; color: var(--tone); line-height: 1.2; }
.alert-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.alert-effect {
  font-size: 11px; font-weight: 750; white-space: nowrap; padding: 4px 8px; border-radius: 999px;
  color: var(--tone); border: 1px solid color-mix(in srgb, var(--tone) 50%, transparent);
}
.alert-items { margin-top: 10px; border-top: 1px solid color-mix(in srgb, var(--tone) 25%, transparent); }
.alert-item { display: grid; gap: 4px; padding-top: 10px; }
.alert-item + .alert-item { margin-top: 2px; }
.alert-kind {
  font-size: 10px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap;
  padding: 3px 7px; border-radius: 6px; justify-self: start;
  background: color-mix(in srgb, var(--tone) 16%, transparent); color: var(--tone);
}
.alert-kind.stop { --tone: var(--stop); }
.alert-kind.caution { --tone: var(--amber); }
.alert-text { font-size: 14px; line-height: 1.35; }
.alert-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
@media (max-width: 420px) {
  .alert-head { grid-template-columns: auto 1fr; }
  .alert-effect { grid-column: 2; justify-self: start; }
}

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 24px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
main > * { min-width: 0; }
.price-head { padding-top: 14px; }
.price-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font-size: 30px; font-weight: 750; letter-spacing: -.5px; }
.chg { font-weight: 650; }

.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 1 0 auto; min-width: 52px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip-accent { background: var(--accent-bg); color: var(--accent); }

/* signal badges */
.sig { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .3px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.sig.very_strong { background: var(--accent); color: #fff; }
.sig.strong { background: var(--accent-bg); color: var(--accent); }
.sig.weak { background: var(--surface-2); color: var(--muted); font-weight: 600; }

/* best card */
.best-card { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background:
  linear-gradient(160deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface) 55%); }
.best-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.best-label b { color: var(--text); }
.best-main { display: flex; align-items: center; gap: 14px; margin: 12px 0 8px; }
.arrow-big {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; flex: 0 0 auto;
}
.arrow-big.up { background: var(--up-bg); color: var(--up); }
.arrow-big.down { background: var(--down-bg); color: var(--down); }
.best-dir { font-size: 28px; font-weight: 800; line-height: 1.1; }
.best-sub { font-size: 13px; color: var(--muted); }
.best-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.fact { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.fact .k { font-size: 11px; color: var(--muted); }
.fact .v { font-weight: 700; }
.risk-note { margin-top: 10px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); }
.risk-note.stop { background: var(--stop-bg); color: var(--stop); }
.agree-bar { display: flex; gap: 3px; margin-top: 4px; }
.agree-bar i { flex: 1; height: 6px; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); }
.agree-bar i.on { background: var(--accent); border-color: var(--accent); }

/* theories */
.theories { display: grid; gap: 8px; }
.theory { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.theory-name { font-weight: 650; font-size: 14px; }
.theory-dir { font-weight: 750; text-align: right; }
.prob-bar { grid-column: 1 / -1; position: relative; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.prob-bar span { position: absolute; top: 0; bottom: 0; }
.prob-bar span.up { left: 50%; background: var(--up); }
.prob-bar span.down { right: 50%; background: var(--down); }
.prob-bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.theory-meta { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* tf grid */
.tf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tf-tile { background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 10px; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.tf-tile.active { border-color: var(--accent); }
.tf-tile .tf { font-size: 12px; color: var(--muted); font-weight: 650; }
.tf-tile .d { font-size: 17px; font-weight: 800; margin: 2px 0 4px; }

.chart { height: 300px; border-radius: 10px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.ok { background: var(--up); } .dot.bad { background: var(--down); } .dot.pend { background: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.score td:nth-child(2) { min-width: 128px; }
.score td.rank { font-weight: 800; color: var(--muted); width: 24px; }
.score tr.best-row td.rank { color: var(--accent); }
.score-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.score-controls select { width: auto; flex: 1 1 160px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; flex: 1 1 220px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 650;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.score tr.best-row td { background: var(--accent-bg); }
.score tr.base-row td { opacity: .75; }
.verdict { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.verdict.good { color: var(--up); font-weight: 700; }
.verdict.bad { color: var(--down); font-weight: 700; }
.note { margin: 10px 0 0; }

.curve { margin-top: 12px; display: grid; gap: 6px; }
.curve-row { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 8px; font-size: 12px; }
.curve-track { height: 8px; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; }
.curve-track span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.curve-track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }

/* global */
.markets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.market { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.market .n { font-size: 12px; color: var(--muted); }
.market .v { font-weight: 700; }
.news { margin-top: 12px; display: grid; gap: 6px; }
.news-item { display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.news-item a { color: var(--text); text-decoration: none; }
.news-item a:hover { text-decoration: underline; }
.news-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.risk { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 4px; height: fit-content; white-space: nowrap; }
.risk.r2 { background: var(--stop-bg); color: var(--stop); }
.risk.r1 { background: var(--amber-bg); color: var(--amber); }
.risk.r0 { background: var(--surface-2); color: var(--muted); }

/* history */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
select, .btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 10px; font: inherit; font-size: 14px; min-width: 0; width: 100%;
}
.btn { width: auto; min-width: 44px; cursor: pointer; }
.btn:disabled { opacity: .4; cursor: default; }
.history { display: grid; gap: 6px; }
.hist { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.hist .top { font-weight: 650; }
.hist .right { text-align: right; }
.hist .sub { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; font-weight: 750; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.correct { background: var(--up-bg); color: var(--up); }
.badge.wrong { background: var(--down-bg); color: var(--down); }
.badge.pending, .badge.flat, .badge.void { background: var(--surface); color: var(--muted); }
.badge.late { background: var(--amber-bg); color: var(--amber); }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 10px; }

details summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
details summary::-webkit-details-marker { display: none; }
details summary h2::after { content: " ▾"; color: var(--muted); }
details[open] summary h2::after { content: " ▴"; }
.version { margin-top: 14px; }
.version-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.version p { margin: 4px 0 8px; }

footer { max-width: 1100px; margin: 0 auto; padding: 16px 16px 28px; display: grid; gap: 6px; text-align: center; }

/* wider screens: two columns */
@media (min-width: 900px) {
  main { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .price-head, #tf-pills { grid-column: 1 / -1; }
  .pill { flex: 0 0 auto; }
  .chart { height: 380px; }
  .markets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tf-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  main > section.card:nth-of-type(n+4) { grid-column: 1 / -1; }
}

/* scoreboard as cards on phones */
@media (max-width: 600px) {
  .score thead { display: none; }
  .score, .score tbody { display: block; }
  .score tr {
    display: grid; grid-template-columns: 26px 1fr 1fr; gap: 6px 10px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .score tr:last-child { border-bottom: 0; }
  .score tr.best-row { background: var(--accent-bg); border-radius: 12px; padding: 10px 8px; margin: 4px -8px; border-bottom: 0; }
  .score td { display: block; padding: 0; border: 0; min-width: 0 !important; }
  .score td.rank { grid-row: 1 / span 5; font-size: 16px; }
  .score td.name { grid-column: 2 / -1; }
  .score .verdict { white-space: normal; }  /* long notes wrap instead of running into the next cell */
  .score td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 1px;
  }
  .score tr.best-row td { background: transparent; }
}

/* trading plan */
.plan { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.plan-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.plan-grid .k { display: block; font-size: 11px; color: var(--muted); }
.plan-grid b { font-size: 14px; }
.plan-verdict { margin-top: 10px; font-size: 13px; font-weight: 650; padding: 8px 10px; border-radius: 10px; }
.plan-verdict.ok { background: var(--up-bg); color: var(--up); }
.plan-verdict.no { background: var(--surface); color: var(--muted); }
.plan-outcome { margin-top: 8px; font-size: 13px; }
.chip-ok { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--up-bg); color: var(--up); }

/* account type */
.mode-seg { max-width: 260px; }
@media (min-width: 900px) { .mode-seg { grid-column: 1 / -1; } }

/* history: calendar and Uji Sejarah progress */
.date-bar { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; }
.date-row { display: inline-flex; align-items: center; gap: 4px; }
.date-step { width: 36px; height: 36px; padding: 0; font-size: 18px; line-height: 1; min-width: 0; }
.date-pick {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; white-space: nowrap;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
}
.date-pick.on { border-color: var(--accent); background: var(--accent-bg); }
/* calendar: a small panel that drops down right under the date button */
.cal {
  position: absolute; top: 42px; left: 0; z-index: 30; width: 300px; max-width: calc(100vw - 32px);
  padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.cal-head { display: grid; grid-template-columns: 32px minmax(0, 1.3fr) minmax(0, 1fr) 32px; gap: 4px; margin-bottom: 8px; }
.cal-head select { padding: 6px; font-size: 13px; font-weight: 650; }
.cal-nav { width: 32px; height: 32px; padding: 0; font-size: 16px; min-width: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 36px); justify-content: space-between; gap: 3px; text-align: center; }
.cal-week span { font-size: 11px; color: var(--muted); padding-bottom: 2px; }
.cal-days button {
  width: 36px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
}
.cal-days button:not(:disabled):hover { background: var(--surface-2); }
.cal-days button:disabled { color: var(--muted); opacity: .35; cursor: default; }
.cal-days button.today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-days button.sel { background: var(--accent); color: #fff; }
.cal-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.cal-foot .btn { padding: 6px 10px; font-size: 13px; }
.replay-line { display: grid; gap: 4px; margin-bottom: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.replay-line .bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.replay-line .bar span { display: block; height: 100%; background: var(--accent); transition: width .6s ease; }
.replay-line[hidden], .cal[hidden] { display: none; }
