:root {
  --bg: #0e1117;
  --panel: #161b26;
  --panel-2: #1c2230;
  --border: #262d3d;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #4a9eff;
  --bull: #26a69a;
  --bear: #ef5350;
  --warn: #e0a800;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Topbar ---------- */

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

.brand { display: flex; align-items: center; gap: 9px; }
.brand h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bull);
  box-shadow: 0 0 8px var(--bull);
}

.controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 130px;
}

.toggle {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  padding-bottom: 7px;
  cursor: pointer;
}
.toggle input { accent-color: var(--accent); }

button {
  font-family: inherit;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s;
}

button.ghost {
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 12px;
}
button.ghost:hover { border-color: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
  padding: 9px 14px;
}
button.primary:hover { background: #6bb0ff; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.quote { margin-left: auto; display: flex; align-items: baseline; gap: 10px; }
.price { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.change { font-size: 13px; font-variant-numeric: tabular-nums; }
.change.up { color: var(--bull); }
.change.down { color: var(--bear); }

/* ---------- Layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  min-height: 0;
}

.chart-pane { display: flex; flex-direction: column; min-width: 0; }
#chart { flex: 1; min-height: 320px; }

.chart-meta {
  display: flex;
  gap: 20px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.side-pane {
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 11px;
  font-size: 13px;
  border-radius: 0;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 14px; gap: 12px; }
.tab-panel.active { display: flex; }

/* Jadwal dan Riwayat tidak punya area scroll dalam sendiri (beda dengan
   Analisa/Tanya yang scroll di .output / .chat-log) — panelnya sendiri yang
   harus bisa digulir, kalau tidak konten bawah (termasuk tombol Simpan)
   terpotong di layar pendek. */
#panel-wa.active,
#panel-history.active { overflow-y: auto; }

.output { flex: 1; overflow-y: auto; min-height: 0; }
.hint { color: var(--muted); line-height: 1.6; font-size: 13px; margin: 0; }

/* ---------- Analysis ---------- */

.badges { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid;
}
.badge.bullish { color: var(--bull); border-color: var(--bull); background: rgba(38, 166, 154, 0.1); }
.badge.bearish { color: var(--bear); border-color: var(--bear); background: rgba(239, 83, 80, 0.1); }
.badge.neutral { color: var(--muted); border-color: var(--muted); background: rgba(139, 147, 167, 0.1); }
.badge.meta { color: var(--muted); border-color: var(--border); }

.headline { font-size: 15px; font-weight: 600; line-height: 1.45; margin: 0 0 10px; }

.block { margin-bottom: 16px; }
.block h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 6px;
  font-weight: 600;
}
.block p { margin: 0; line-height: 1.6; color: #cfd4e0; }
.block ul { margin: 0; padding-left: 18px; line-height: 1.6; color: #cfd4e0; }
.block li { margin-bottom: 4px; }

.levels { display: flex; gap: 8px; flex-wrap: wrap; }
.level {
  font-variant-numeric: tabular-nums;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.level.sup { color: var(--bull); }
.level.res { color: var(--bear); }

.scenario {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 7px;
  padding: 11px 12px;
  margin-bottom: 10px;
}
.scenario.long { border-left-color: var(--bull); }
.scenario.short { border-left-color: var(--bear); }
.scenario h4 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.scenario .dir { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.scenario.long .dir { color: var(--bull); }
.scenario.short .dir { color: var(--bear); }

.kv { display: grid; grid-template-columns: 74px 1fr; gap: 3px 10px; font-size: 12.5px; line-height: 1.5; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; color: #cfd4e0; }

/* ---------- Chat ---------- */

.chat-log { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

.msg { padding: 9px 12px; border-radius: 9px; line-height: 1.6; font-size: 13px; white-space: pre-wrap; }
.msg.user { background: var(--accent); color: #06121f; align-self: flex-end; max-width: 85%; }
.msg.bot { background: var(--panel-2); border: 1px solid var(--border); align-self: flex-start; }

.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.chat-form input:focus { outline: none; border-color: var(--accent); }

/* ---------- Misc ---------- */

.loading { color: var(--muted); font-size: 13px; }
.loading::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.error {
  color: var(--bear);
  background: rgba(239, 83, 80, 0.08);
  border: 1px solid rgba(239, 83, 80, 0.3);
  border-radius: 6px;
  padding: 10px 12px;
  line-height: 1.55;
  font-size: 13px;
}

.disclaimer {
  padding: 7px 18px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* ---------- Gaya analisa ---------- */

.style-pick {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.style-pick select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
}

/* ---------- Berita ---------- */

.news-updated { font-size: 10.5px; color: var(--muted); }

.news-item {
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 10px;
  margin-bottom: 12px;
}

.news-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.news-src { font-size: 10.5px; color: var(--muted); }

.news-title { margin: 0 0 3px; font-size: 12.5px; line-height: 1.45; font-weight: 500; }
.news-note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.impact {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.impact.tinggi { color: var(--bear); border-color: var(--bear); }
.impact.sedang { color: #e0a800; border-color: #e0a800; }
.impact.rendah { color: var(--muted); }

.agenda { margin: 0; padding-left: 0; list-style: none; }
.agenda li {
  font-size: 11.5px;
  line-height: 1.6;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.agenda li:last-child { border-bottom: none; }

.badge.sentimen-positif { color: var(--bull); border-color: var(--bull); }
.badge.sentimen-negatif { color: var(--bear); border-color: var(--bear); }
.badge.sentimen-netral { color: var(--muted); }

/* ---------- Riwayat ---------- */

.history-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.history-bar .toggle { font-size: 11px; }
.history-bar button { padding: 5px 10px; font-size: 11px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--accent); }

.history-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.history-pair { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }

.history-del {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  padding: 0 3px;
  cursor: pointer;
}
.history-del:hover { color: var(--bear); }

.history-headline {
  margin: 0 0 7px;
  font-size: 12.5px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-foot {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
}

.badge.arsip { border-style: dashed; }

/* ---------- Jadwal WhatsApp ---------- */

.wa-transport { font-size: 11.5px; margin-bottom: 12px; }
.wa-ok { color: var(--bull); }
.wa-bad { color: var(--bear); }

.wa-enable { display: flex; margin-bottom: 14px; font-size: 12.5px; }

.wa-checks { display: flex; flex-direction: column; gap: 7px; }
.wa-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}
.wa-check input { accent-color: var(--accent); }

.wa-presets { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.wa-presets button { padding: 4px 9px; font-size: 10.5px; }

.hour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.hour-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 0;
  cursor: pointer;
}
.hour-chip:hover { border-color: var(--accent); }
.hour-chip.on {
  background: var(--accent-dim, rgba(74, 158, 255, 0.15));
  border-color: var(--accent);
  color: var(--text);
}

#panel-wa select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  width: 100%;
}

#wa-save { margin-top: 14px; width: 100%; }

.wa-info {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.wa-actions { display: flex; gap: 8px; margin-top: 14px; }
.wa-actions button { flex: 1; padding: 8px 6px; font-size: 11.5px; }

/* ---------- Halaman login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
}

.login-head { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.login-head h1 { font-size: 16px; margin: 0; font-weight: 600; }

.login-card form { display: flex; flex-direction: column; gap: 14px; }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-card input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }

.login-card button { margin-top: 4px; }

.logout {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 12px;
}
.logout:hover { color: var(--text); border-color: var(--bear); }

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 980px) {
  body { overflow: auto; height: auto; }
  .layout { grid-template-columns: 1fr; }
  #chart { height: 55vh; }
  .side-pane { border-left: none; border-top: 1px solid var(--border); }
  .quote { margin-left: 0; }
}
