:root {
  --bg: #0E1116;
  --panel: #151A22;
  --panel-2: #1C222C;
  --line: #222832;
  --line-2: #2A313C;
  --text: #E6E8EB;
  --muted: #9AA4B2;
  --faint: #7D8796;
  --up: #3FB950;
  --up-bg: #14301C;
  --down: #F2555A;
  --down-bg: #3A1618;
  --warn: #F0B429;
  --warn-bg: #33270F;
  --info: #7FB2FF;
  --info-bg: #15243A;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--info); }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); } .faint { color: var(--faint); }

.app { min-height: 100vh; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: rgba(14,17,22,.92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; }
.search { flex: 1; display: flex; justify-content: flex-end; }
.search input {
  width: 100%; max-width: 220px; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel); text-transform: uppercase;
}
.search input::placeholder { text-transform: none; color: var(--faint); }

/* ---------- layout ---------- */
.view { flex: 1; padding: 16px 16px calc(env(safe-area-inset-bottom) + 88px); outline: none; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--faint); }
.stat .v { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons & chips ---------- */
.btn { text-decoration: none;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--panel-2); cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--up); border-color: var(--up); color: #0B1F10; font-weight: 600; }
.btn.danger { color: var(--down); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--panel); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 13px;
}
.chip[aria-pressed="true"] { border-color: var(--up); background: var(--up-bg); color: var(--text); font-weight: 600; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 5px; background: var(--panel-2); color: var(--muted); }
.tag.up { background: var(--up-bg); color: var(--up); }
.tag.down { background: var(--down-bg); color: #FF8A8E; }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--info-bg); color: var(--info); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--panel);
  color: var(--text); text-decoration: none; min-height: 56px;
}
.score-box {
  flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--panel-2);
  display: flex; align-items: center; justify-content: center; font: 700 15px var(--mono);
}
.score-box.hi { background: var(--up-bg); color: var(--up); }
.score-box.lo { background: var(--down-bg); color: #FF8A8E; }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .code { font: 700 15px var(--mono); }
.row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row .price { font: 600 15px var(--mono); }
.row .chg { font: 600 12px var(--mono); }

.news-item { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--panel); text-decoration: none; color: var(--text); }
.news-item .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--faint); }
.news-item .title { font-weight: 500; line-height: 1.4; }
.sentbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-2); }
.sentbar span { display: block; height: 100%; }

/* ---------- stock page ---------- */
.price-big { font: 600 30px var(--mono); }
.chart-box { height: 320px; border-radius: var(--radius); overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.scores .stat { text-align: center; background: var(--panel); }
.scores .stat .v { font: 700 20px var(--mono); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { flex: none; min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--up); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); font-weight: 600; text-align: right; }
.signals { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.note { font-size: 12px; color: var(--faint); line-height: 1.5; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; color: var(--faint); font-weight: 500; padding: 10px 8px; white-space: nowrap; }
td { text-align: right; padding: 10px 8px; border-top: 1px solid var(--line); font-family: var(--mono); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 14px; }
th:last-child, td:last-child { padding-right: 14px; }
tbody tr { cursor: pointer; }
tbody tr:active { background: var(--panel-2); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); width: 100%;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; align-items: end; }
.banner { padding: 12px 14px; border-radius: 12px; background: var(--warn-bg); border: 1px solid #4A3A16; color: #E9D7A6; font-size: 13px; }

/* ---------- login ---------- */
.login { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.error { color: #FF8A8E; font-size: 13px; min-height: 18px; }

/* ---------- states ---------- */
.skeleton { background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; min-height: 56px; }
@keyframes sk { to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--faint); padding: 24px 8px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 760px; margin: 0 auto; background: rgba(18,22,29,.96); border-top: 1px solid var(--line);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 8px); backdrop-filter: blur(10px);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: 11px; min-height: 48px; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tabbar a[aria-current="page"] { color: var(--up); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 20;
  background: var(--panel-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}

@media (min-width: 700px) {
  .view { padding-left: 24px; padding-right: 24px; }
  .chart-box { height: 400px; }
}

/* ---------- v1.0 multi-pengguna ---------- */
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--up); }
.field textarea {
  min-height: 72px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg); width: 100%; resize: vertical; font: inherit; color: inherit; line-height: 1.45;
}
details summary { cursor: pointer; }
button.banner { font: inherit; color: #E9D7A6; }
