:root {
  --bg: #0b0d12; --bg2: #11141b; --card: #151922; --card2: #1b2030; --line: #252b3a;
  --text: #e8ebf2; --muted: #8b93a7; --dim: #5d6579;
  --accent: #7c9cff; --accent2: #5b7cf0; --red: #ff5d6c; --green: #3ecf8e; --amber: #f5b84b;
  --radius: 14px; --sidebar: 236px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--bg2); border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 30; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; letter-spacing: .2px; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-size: 14px; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--card2); color: var(--text); }
.nav .num { width: 22px; height: 22px; border-radius: 7px; background: var(--card); display: grid; place-items: center; font-size: 11px; color: var(--dim); }
.nav a.active .num { background: var(--accent2); color: #fff; }
.nav .sep { margin: 14px 12px 6px; font-size: 11px; text-transform: uppercase; color: var(--dim); letter-spacing: .6px; }
.side-foot { padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.main { margin-left: var(--sidebar); flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(11,13,18,.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 12px 22px; }
.topbar h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.content { padding: 20px 22px 80px; max-width: 1280px; }
.scrim { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 25; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .content { padding: 14px 12px 90px; }
}

/* Komponen */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .spacer { flex: 1; }
.card h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.up { color: var(--green); } .down { color: var(--red); } .warn { color: var(--amber); } .muted { color: var(--muted); } .dim { color: var(--dim); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); cursor: pointer; font-size: 14px; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #3a4256; }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { background: transparent; border-color: #5a2630; color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: progress; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--accent2); }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: 12px; color: var(--dim); margin-top: 4px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); font-size: 13px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--accent2); color: #fff; border-color: var(--accent2); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { color: var(--green); border-color: #1f4a39; }
.badge.err { color: var(--red); border-color: #5a2630; }
.badge.warn { color: var(--amber); border-color: #5a4520; }
.badge.info { color: var(--accent); border-color: #2a3766; }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.ch-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ch-item:last-child { border-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--card2); flex-shrink: 0; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; }
.thumb { width: 96px; aspect-ratio: 16/9; border-radius: 8px; object-fit: cover; background: var(--card2); flex-shrink: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.notice { border-left: 3px solid var(--accent); background: var(--bg2); padding: 10px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.notice.warn { border-color: var(--amber); }
.notice.err { border-color: var(--red); }
.notice b { color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* Chart */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--dim); font-size: 10px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: rgba(124,156,255,.12); }
.chart .bar { fill: var(--accent2); }
.chart .dot { fill: var(--accent); }
.hbar-bg { fill: var(--card2); } .hbar { fill: var(--accent2); }
.hbar-label { fill: var(--text); font-size: 12px; } .hbar-val { fill: var(--muted); font-size: 12px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 12px 14px; border-radius: 14px; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { background: var(--accent2); color: #fff; align-self: flex-end; max-width: 85%; }
.msg.assistant { background: var(--card); border: 1px solid var(--line); }
.msg .meta { font-size: 11px; color: var(--dim); margin-top: 6px; }
.md h2, .md h3, .md h4 { font-size: 15px; margin: 14px 0 6px; }
.md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 6px 0; } .md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md code { background: var(--bg2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; max-height: 180px; }
.suggest { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.suggest .chip { white-space: nowrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 100; max-width: 92vw; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.err { border-color: #5a2630; color: #ffc3c9; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { padding: 0 0 18px; justify-content: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
details summary { cursor: pointer; color: var(--muted); }
pre.code { background: var(--bg2); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
.grid { margin-bottom: 14px; }
.card .grid:last-child { margin-bottom: 0; }
.btn.disabled { opacity: .5; pointer-events: none; }
hr.dim { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.suggest { margin-top: 12px; }
details { margin-top: 10px; }
.card .row + .field, .card .field + .row { margin-top: 10px; }
.auth-card .btn { width: 100%; }
.btn.menu-btn { display: none; }
@media (max-width: 900px) { .btn.menu-btn { display: inline-flex; } }
.row > select.input, .row > input.input:not(.grow) { width: auto; max-width: 100%; }
@media (max-width: 640px) { .row > select.input { width: 100%; } }
