:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18202b;
  --line: #243041;
  --text: #e6edf3;
  --muted: #8b98a8;
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f59e0b;
  --accent: #38bdf8;
  --fast: #f59e0b;
  --slow: #a78bfa;
  --stop: #ef4444;
  --radius: 10px;
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 8px 14px; }
.up { color: var(--up); }
.down { color: var(--down); }
.r { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-mark { color: var(--accent); }
.badges { display: flex; gap: 8px; align-items: center; flex: 1; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #1f3b2b; color: #86efac; border: 1px solid #2c5a3e;
}
.badge.live { background: #4a1d1d; color: #fecaca; border-color: #7f1d1d; }
.badge-dim { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--up); box-shadow: 0 0 6px var(--up); }
.dot.bad { background: var(--down); box-shadow: 0 0 6px var(--down); }
.dot.warn { background: var(--warn); }
.actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px;
  padding: 7px 12px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: #0e7490; border-color: #0891b2; }
.btn-danger { background: #7f1d1d; border-color: #b91c1c; color: #fee2e2; }
.btn-resume { background: #14532d; border-color: #15803d; color: #dcfce7; }
.btn-ghost { background: transparent; }

/* ---------- alerts ---------- */
.alerts { display: flex; flex-direction: column; gap: 6px; padding: 0 18px; }
.alerts:not(:empty) { padding-top: 10px; }
.alert { padding: 8px 12px; border-radius: 8px; border: 1px solid; font-size: 13px; }
.alert.danger { background: #3b1414; border-color: #7f1d1d; color: #fecaca; }
.alert.info { background: #0f2533; border-color: #155e75; color: #bae6fd; }
.alert.warn { background: #3a2a0c; border-color: #92400e; color: #fde68a; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; padding: 12px 18px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; min-height: 16px; }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 10px; padding: 10px 18px 18px;
  grid-template-columns: minmax(470px, 1.25fr) minmax(0, 2fr) minmax(300px, 1fr);
  grid-template-areas:
    "watch chart news"
    "watch analysis news"
    "risk equity activity";
}
.watch { grid-area: watch; }
.chart-card { grid-area: chart; }
.news { grid-area: news; }
.analysis { grid-area: analysis; }
.equity { grid-area: equity; }
.activity { grid-area: activity; }
.risk { grid-area: risk; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14px; margin: 0; font-weight: 650; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 4px 10px; cursor: pointer; font-size: 12px;
  font-weight: 600;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--panel-2); color: var(--text); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th {
  position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}
.tbl td { padding: 7px 8px; border-bottom: 1px solid #1a2330; white-space: nowrap; }
.tbl th.r, .tbl td.r { text-align: right; }
#watch tbody tr { cursor: pointer; }
#watch tbody tr:hover { background: var(--panel-2); }
#watch tbody tr.sel { background: #13293a; box-shadow: inset 3px 0 0 var(--accent); }
.sym { font-weight: 700; }
.held { color: var(--accent); font-size: 11px; margin-left: 4px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.pill.NAIK, .pill.BELI, .pill.PEGANG { background: #123321; border-color: #1f6b3d; color: #86efac; }
.pill.TURUN, .pill.JUAL { background: #3b1414; border-color: #7f1d1d; color: #fca5a5; }
.pill.TUNGGU { background: #3a2a0c; border-color: #92400e; color: #fde68a; }

/* ---------- chart ---------- */
.chart-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-title h2 { font-size: 18px; }
.price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chg { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; padding: 6px 14px 0; flex-wrap: wrap; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.sw-fast { background: var(--fast); }
.sw-slow { background: var(--slow); }
.sw-stop { background: var(--stop); }
.chart { height: 400px; width: 100%; }
.chart-rsi { height: 110px; width: 100%; }
.sub-label { padding: 2px 14px; }
.chart-eq { height: 230px; width: 100%; }

/* ---------- analysis ---------- */
.why { padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px 10px; }
.check { padding: 5px 10px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }
.check.ok { border-color: #1f6b3d; }
.check.no { border-color: #7f1d1d; }
.tech { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.tech > div { padding: 9px 14px; border-right: 1px solid #1a2330; border-bottom: 1px solid #1a2330; }
.tech .t-label { color: var(--muted); font-size: 11px; }
.tech .t-val { font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tech .t-hint { color: var(--muted); font-size: 11px; }

/* ---------- news ---------- */
.news-list { overflow: auto; max-height: 860px; }
.news-item { padding: 10px 14px; border-bottom: 1px solid #1a2330; }
.news-item a { color: var(--text); text-decoration: none; font-weight: 600; line-height: 1.35; }
.news-item a:hover { color: var(--accent); }
.news-meta { color: var(--muted); font-size: 11px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.news-sum { color: #b6c2cf; font-size: 12px; margin-top: 4px; line-height: 1.4; }
.tag { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ---------- activity / risk ---------- */
.act-body { max-height: 300px; }
.log { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; padding: 8px 14px;
  white-space: pre-wrap; word-break: break-word; color: #b6c2cf; margin: 0; }
.risk-grid { display: grid; grid-template-columns: 1fr auto; }
.risk-grid > div { padding: 8px 14px; border-bottom: 1px solid #1a2330; }
.risk-grid .rv { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.foot { padding: 0 18px 20px; }

/* ---------- dialog ---------- */
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  max-width: 460px; padding: 18px 20px; }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h3 { margin: 0 0 8px; }
.dialog p { color: #c6d0db; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px;
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login-card input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px;
  padding: 10px 12px; font-size: 15px; }
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.error { color: #fca5a5; min-height: 18px; margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    grid-template-areas: "watch chart" "analysis analysis" "news equity" "news activity" "risk activity"; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .topbar { padding: 10px 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); padding: 10px 16px 16px;
    grid-template-areas: "chart" "analysis" "watch" "news" "equity" "activity" "risk"; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px 0; }
  .alerts { padding: 0 16px; }
  .tech { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 320px; }
  .news-list { max-height: 520px; }
}
