:root {
  --bg: #0b1020;
  --panel: #121a33;
  --panel-2: #172041;
  --line: #26314f;
  --text: #eef2ff;
  --muted: #9aa7c7;
  --accent: #f5c85b;
  --primary: #4f6df0;
  --primary-d: #3b55cf;
  --danger: #ef6b6b;
  --ok: #3ccf9b;
  --side-w: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: inherit; }
.muted { color: var(--muted); }
svg { width: 20px; height: 20px; flex: none; }
i[data-icon] { display: inline-flex; }

/* ---------- Kerangka ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg,#4f6df0,#2f48c4); color: #fff; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
nav a, .side-foot a, .side-foot button {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  background: none; border: 0; font: inherit; font-weight: 500; cursor: pointer; width: 100%; text-align: left;
}
nav a:hover, .side-foot a:hover, .side-foot button:hover { background: var(--panel-2); color: var(--text); }
nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11,16,32,.92); backdrop-filter: blur(8px); z-index: 5; }
.topbar h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.who { color: var(--muted); font-size: 14px; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1100px; width: 100%; }
.scrim { display: none; }

/* ---------- Komponen ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 4px; font-size: 17px; }
.panel .lead { color: var(--muted); margin: 0 0 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 14px; }
.banner { background: rgba(245,200,91,.1); border: 1px solid rgba(245,200,91,.45); color: #fbe3a0; padding: 13px 16px; border-radius: 12px; margin-bottom: 20px; }
.banner a { color: var(--accent); font-weight: 700; }

.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 14px; align-items: center; }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #14b8a0); border-radius: 99px; }
.bar-row .ct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar p { margin: 0; color: var(--muted); }

.app-list { display: flex; flex-direction: column; gap: 12px; }
.app-row { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.app-row.off { opacity: .6; }
.app-row .icon-tile { --tile: 52px; }
.app-info { min-width: 0; }
.app-info strong { display: block; font-size: 16px; }
.app-info .sub { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-info .url { color: var(--accent); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.app-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.clicks { color: var(--muted); font-size: 13px; margin-right: 6px; white-space: nowrap; }

.icon-tile {
  --tile: 72px;
  width: var(--tile); height: var(--tile);
  border-radius: calc(var(--tile) * .25);
  display: grid; place-items: center; color: #fff; flex: none; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}
.icon-tile svg { width: 48%; height: 48%; }
.icon-tile .emoji { font-size: calc(var(--tile) * .5); line-height: 1; }
.icon-tile.has-img { background: rgba(255,255,255,.08); }
.icon-tile.has-img img { width: 100%; height: 100%; object-fit: contain; padding: 12%; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { border-color: #3a4a78; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 7px 10px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); border-radius: 10px; width: 36px; height: 36px; display: inline-grid; place-items: center; cursor: pointer; font-size: 22px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, nav a:focus-visible, input:focus-visible, .seg button:focus-visible, .icon-grid button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* switch */
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: rgba(60,207,155,.25); border-color: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--ok); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* form */
label { display: block; margin: 16px 0 6px; font-weight: 700; font-size: 14px; }
input[type=text], input[type=password], input:not([type]), input[type=url], input[type=file] {
  width: 100%; padding: 11px 13px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; font: inherit;
}
input[type=color] { width: 100%; height: 42px; padding: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
input::placeholder { color: #5f6c91; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 12px 0 0; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.form-error { color: #ff9a9a; background: rgba(239,107,107,.1); border: 1px solid rgba(239,107,107,.4); padding: 10px 12px; border-radius: 10px; margin: 14px 0 0; }
.form-grid { max-width: 560px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; }
dialog::backdrop { background: rgba(3,6,16,.72); }
dialog form { padding: 22px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h3 { margin: 0; font-size: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.preview { display: flex; align-items: center; gap: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 16px 0 0; }
.preview .icon-tile { --tile: 52px; }
.pv-text { display: flex; flex-direction: column; min-width: 0; }
.pv-text strong { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-text span { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--bg); border: 1px solid var(--line); padding: 4px; border-radius: 12px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 4px; border-radius: 9px; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.pane { margin-top: 12px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.icon-grid button { aspect-ratio: 1; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; color: var(--muted); cursor: pointer; }
.icon-grid button:hover { color: var(--text); border-color: #3a4a78; }
.icon-grid button.on { color: #fff; border-color: var(--accent); background: var(--panel-2); }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--panel-2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: var(--danger); color: #ffb3b3; }
#toast.ok { border-color: var(--ok); }

.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }

/* ---------- Halaman login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(900px 420px at 50% -10%, #1b2a55, transparent 70%), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: 0 30px 60px -25px rgba(0,0,0,.7); }
.login-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login-card .muted { margin: 0 0 8px; }
.login-card .btn { margin-top: 20px; }
.back { display: block; text-align: center; margin-top: 18px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }

/* ---------- Responsif ---------- */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; z-index: 30; }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(3,6,16,.6); z-index: 20; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px; }
  .who { display: none; }
  .app-row { grid-template-columns: auto 1fr; }
  .app-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .bar-row { grid-template-columns: 100px 1fr 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* koreksi: label.switch tidak boleh memakai margin label umum */
label.switch { display: block; margin: 0; }

select { width: 100%; padding: 11px 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 11px; font: inherit; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.media-prev { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.media-prev img { max-height: 64px; max-width: 160px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); object-fit: contain; }
.media-prev.bg img { max-height: 80px; max-width: 200px; object-fit: contain; }

textarea { width: 100%; padding: 11px 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 11px; font: inherit; resize: vertical; min-height: 72px; }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; display: grid; place-items: center; background: none; border: 0; border-radius: 9px; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--panel-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg.seg3 { grid-template-columns: repeat(3, 1fr); }
