:root {
  color-scheme: dark;
  /* Satu tema terminal gelap untuk seluruh aplikasi (sama dengan Market Pulse). */
  --page: #0a0e13;
  --surface: #10161d;
  --surface-2: #151c25;
  --ink: #e6edf3;
  --ink-2: #aab6c3;
  --muted: #8794a4;
  --grid: #1f2a36;
  --axis: #2b3948;
  --border: #1f2a36;
  --accent: #3b82f6;
  --pos: #22c55e;
  --neu: #5c6b7a;
  --neg: #ef4444;
  --pos-text: #22c55e;
  --neg-text: #ef4444;
  --wash-pos: rgba(34, 197, 94, 0.14);
  --wash-neg: rgba(239, 68, 68, 0.14);
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--pos); }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); white-space: nowrap;
}
.topbar nav a:hover { background: var(--surface-2); }
.topbar nav a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.nav-sep { width: 1px; align-self: stretch; margin: 6px 6px; background: var(--border); flex: none; }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.page-head > div > h1 { margin: 0; }

.btn {
  border: 1px solid var(--border); background: var(--surface-2); padding: 7px 14px; font-weight: 600;
  border-radius: 9px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--axis); }
.btn.primary { background: var(--pos); color: #04140a; border-color: var(--pos); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: progress; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; }
footer { text-align: center; padding: 0 16px 24px; }

/* ---------- layout */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
@media (max-width: 960px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-2, .g-main { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .nav-sep { display: none; }
  .topbar-actions { margin-left: auto; }
  #last-update { display: none; }
  main { padding: 16px 16px 32px; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { font-size: 13px; margin: 0 0 2px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.card .sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- segmented control */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- stat tiles */
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 4px; }
.stat .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta-up { color: var(--pos-text); }
.delta-down { color: var(--neg-text); }
.meter { height: 6px; border-radius: 3px; margin-top: 10px; position: relative;
  background: linear-gradient(90deg, var(--neg), var(--neu) 50%, var(--pos)); }
.meter i { position: absolute; top: -4px; width: 4px; height: 14px; border-radius: 2px; background: var(--ink);
  box-shadow: 0 0 0 2px var(--surface); transform: translateX(-2px); }

/* ---------- sentiment chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--border); white-space: nowrap; }
.chip.positif { background: var(--wash-pos); color: var(--pos-text); border-color: transparent; }
.chip.negatif { background: var(--wash-neg); color: var(--neg-text); border-color: transparent; }
.chip.netral { background: var(--surface-2); color: var(--ink-2); }
.tick { display: inline-block; font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 6px;
  background: var(--surface-2); text-decoration: none; border: 1px solid var(--border); }
.tick:hover { border-color: var(--accent); color: var(--accent); }
.cat { font-size: 12px; color: var(--muted); }

/* ---------- legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-pos { background: var(--pos); } .sw-neu { background: var(--neu); } .sw-neg { background: var(--neg); }

/* ---------- ranked rows (HTML bars) */
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 44px; align-items: center; gap: 10px;
  padding: 5px 4px; border-radius: 6px; cursor: default; }
.row:hover { background: var(--surface-2); }
.row .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .name small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.bar { display: flex; height: 12px; gap: 2px; }
.bar b { display: block; height: 100%; min-width: 0; }
.bar b:first-child { border-radius: 4px 0 0 4px; }
.bar b:last-child { border-radius: 0 4px 4px 0; }
.bar b:only-child { border-radius: 0 4px 4px 0; }
.bar .p { background: var(--pos); } .bar .n { background: var(--neu); } .bar .x { background: var(--neg); }
.bar .a { background: var(--accent); }
a.row { text-decoration: none; cursor: pointer; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

/* ---------- news list */
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 12px 0; border-bottom: 1px solid var(--grid); display: grid; gap: 4px; }
.news li:last-child { border-bottom: 0; }
.news .title { font-weight: 600; text-decoration: none; line-height: 1.35; }
.news .title:hover { color: var(--accent); }
.news .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.news .summary { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news li.alert { border-left: 3px solid var(--neg); padding-left: 10px; }

/* ---------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0;
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filters input[type=search] { flex: 1 1 220px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---------- keyword cloud */
.cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.cloud a { text-decoration: none; padding: 2px 10px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--ink-2); }
.cloud a:hover { color: var(--accent); border-color: var(--accent); }


/* ---------- ticker grid */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tcell { display: block; text-decoration: none; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); }
.tcell:hover { border-color: var(--accent); }
.tcell b { font-size: 14px; } .tcell .nm { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcell .ct { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.tcell.pos { box-shadow: inset 3px 0 0 var(--pos); }
.tcell.neg { box-shadow: inset 3px 0 0 var(--neg); }

.price-big { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.star { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.star.on { color: var(--accent); border-color: var(--accent); }

.chart-box { position: relative; height: 240px; }
.chart-box.sm { height: 180px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.skeleton { color: var(--muted); padding: 40px 0; text-align: center; }

#tooltip {
  position: fixed; pointer-events: none; z-index: 50; opacity: 0; transition: opacity .08s;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.45); max-width: 260px;
}
#tooltip.show { opacity: 1; }
#tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
#tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); }
#tooltip .tt-row span:last-child { font-variant-numeric: tabular-nums; color: var(--ink); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); font-weight: 600;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

/* ---------- rumor */
:root { --st-warning: #fab219; --st-serious: #ec835a; --st-good: #0ca30c; --st-critical: #d03b3b; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.status .ic { font-size: 11px; line-height: 1; }
.status.beredar .ic { color: var(--st-warning); }
.status.diawasi .ic { color: var(--st-serious); }
.status.dibantah .ic { color: var(--muted); }
.status.dikonfirmasi .ic { color: var(--st-good); }
.rtag { font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px dashed var(--axis); color: var(--ink-2); white-space: nowrap; }
.notice { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--ink-2); margin-bottom: 16px; }
.thread-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.thread-head h2 { font-size: 15px; text-transform: none; letter-spacing: 0; }
.thread-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--grid); }
.timeline li { position: relative; padding: 6px 0 6px 6px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 12px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--axis); }
.timeline li.t-bantahan::before { border-color: var(--muted); background: var(--muted); }
.timeline li.t-konfirmasi::before { border-color: var(--st-good); background: var(--st-good); }
.timeline li.t-pengawasan::before { border-color: var(--st-serious); background: var(--st-serious); }
.timeline li.t-rumor::before { border-color: var(--st-warning); }
.timeline a { text-decoration: none; font-weight: 500; }
.timeline a:hover { color: var(--accent); }
.timeline .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.more { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; font-size: 13px; }
.cred-tinggi { color: var(--ink); font-weight: 600; } .cred-rendah { color: var(--muted); }

.src-link { font-size: 11.5px; color: var(--muted); text-decoration: none; border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; white-space: nowrap; }
.src-link:hover { color: var(--ink); border-color: var(--axis); }

main { overflow-x: clip; }
@media (max-width: 640px) { .topbar nav a { padding: 8px 12px; } }

/* ---- akun & login ---- */
body.locked .topbar nav, body.locked .topbar-actions { display: none; }
body:not(.is-admin) [data-admin] { display: none !important; }
.userbox { display: inline-flex; gap: 6px; }
.login-card { max-width: 360px; margin: 12vh auto 0; padding: 24px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card label { display: block; margin: 14px 0 4px; font-size: 13px; color: var(--ink-2); }
.login-card input, .form-row input, .form-row select {
  width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font: inherit;
}
.login-card .btn { width: 100%; margin-top: 18px; justify-content: center; }
.form-err { color: var(--neg-text); font-size: 13px; min-height: 18px; margin-top: 10px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.badge-role { padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.badge-role.admin { color: var(--accent); border-color: var(--accent); }
.tbl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 720px) { #btn-me { max-width: 90px; overflow: hidden; text-overflow: ellipsis; } }

/* ---- langganan ---- */
.plan-price { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 2px; }
.plan-price small { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }

#trial-bar { background: var(--wash-pos); border-bottom: 1px solid var(--border); text-align: center; padding: 7px 16px; font-size: 13px; color: var(--ink); }
#trial-bar[hidden] { display: none; }
