:root {
  --bg: #060a18;
  --panel: #0b1124;
  --line: rgba(130, 150, 255, .14);
  --text: #e6ebff;
  --muted: #8b95ba;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
}
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(1100px 560px at 85% -10%, rgba(99, 102, 241, .14), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, .08), transparent 60%), var(--bg);
}
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Kerangka */
.side { width: 16rem; background: #080d1f; }
@media (max-width: 1023px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
}
@media (min-width: 1024px) { .side.collapsed { display: none; } }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
.topbar { background: rgba(8, 13, 31, .7); backdrop-filter: blur(8px); }

.logo {
  width: 2.5rem; height: 2.5rem; border-radius: .75rem; display: grid; place-items: center;
  background: linear-gradient(135deg, #38bdf8, #6366f1); color: #fff;
  box-shadow: 0 0 24px rgba(99, 102, 241, .45);
}
.logo-custom { background: transparent; box-shadow: none; overflow: hidden; }
.logo-img { width: 100%; height: 100%; object-fit: contain; }
.nav {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: .8rem;
  color: #b4bee6; font-size: .95rem; font-weight: 500; transition: background .15s, color .15s;
}
.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-active {
  color: #fff; background: linear-gradient(90deg, #5b5bf0, #7c4dff);
  box-shadow: 0 6px 22px rgba(99, 102, 241, .35);
}

/* Kartu */
.card {
  background: linear-gradient(180deg, rgba(20, 29, 62, .75), rgba(11, 17, 38, .92));
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.card-title { font-weight: 700; font-size: 1.05rem; }
.stat { position: relative; overflow: hidden; }
.stat-blue { background: linear-gradient(135deg, rgba(37, 99, 235, .38), rgba(11, 17, 38, .92) 65%); border-color: rgba(56, 189, 248, .35); }
.stat-purple { background: linear-gradient(135deg, rgba(124, 58, 237, .38), rgba(11, 17, 38, .92) 65%); border-color: rgba(167, 139, 250, .35); }
.stat-green { background: linear-gradient(135deg, rgba(5, 150, 105, .36), rgba(11, 17, 38, .92) 65%); border-color: rgba(52, 211, 153, .35); }
.stat-amber { background: linear-gradient(135deg, rgba(217, 119, 6, .38), rgba(11, 17, 38, .92) 65%); border-color: rgba(251, 191, 36, .35); }
.stat-ico { width: 3rem; height: 3rem; border-radius: .8rem; display: grid; place-items: center; flex-shrink: 0; }
.ico-blue { background: rgba(56, 189, 248, .18); color: var(--blue); }
.ico-purple { background: rgba(167, 139, 250, .2); color: var(--purple); }
.ico-green { background: rgba(52, 211, 153, .18); color: var(--green); }
.ico-amber { background: rgba(251, 191, 36, .18); color: var(--amber); }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border-radius: .6rem;
  padding: .55rem 1rem; font-size: .875rem; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  background: rgba(255, 255, 255, .07); color: #dfe5ff; transition: background .15s, opacity .15s;
}
.btn:hover { background: rgba(255, 255, 255, .13); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #5b5bf0, #7c4dff); color: #fff; box-shadow: 0 4px 16px rgba(99, 102, 241, .35); }
.btn-primary:hover { background: linear-gradient(135deg, #6a6af5, #8b5dff); }
.btn-danger { background: rgba(248, 113, 113, .15); color: #fca5a5; }
.btn-danger:hover { background: rgba(248, 113, 113, .26); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.ib {
  width: 2rem; height: 2rem; display: inline-grid; place-items: center; border-radius: .5rem; cursor: pointer;
  background: rgba(255, 255, 255, .07); color: #cbd5ff; border: 0; transition: background .15s;
}
.ib:hover { background: rgba(255, 255, 255, .15); }
.ib-red { background: rgba(248, 113, 113, .2); color: #fca5a5; }
.ib-red:hover { background: rgba(248, 113, 113, .35); }
.ib-green { background: rgba(52, 211, 153, .2); color: #6ee7b7; }
.ib-green:hover { background: rgba(52, 211, 153, .35); }

/* Form */
.inp {
  width: 100%; border-radius: .6rem; padding: .6rem .85rem; color: var(--text); outline: none;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
}
.inp:focus { border-color: #7c7cff; box-shadow: 0 0 0 3px rgba(124, 124, 255, .2); }
.inp option { background: #0b1124; }
.lbl { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.pill-select {
  display: inline-flex; align-items: center; gap: .5rem; padding: 0 .6rem; height: 2.4rem; border-radius: .7rem;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: #cbd5ff;
}
.pill-select select { background: transparent; border: 0; color: inherit; font-size: .85rem; outline: none; cursor: pointer; }
.pill-select option { background: #0b1124; }
.avatar {
  width: 2.4rem; height: 2.4rem; border-radius: 999px; font-weight: 700; font-size: .85rem; color: #fff; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #a855f7);
}
.usermenu {
  position: absolute; right: 0; top: 3rem; z-index: 60; min-width: 11rem; padding: .5rem; border-radius: .8rem;
  background: #0d1430; border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

/* Status */
.pill {
  display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .65rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
}
.pill-green { background: rgba(52, 211, 153, .14); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, .3); }
.pill-red { background: rgba(248, 113, 113, .14); color: #fca5a5; border: 1px solid rgba(248, 113, 113, .3); }
.pill-amber { background: rgba(251, 191, 36, .14); color: #fcd34d; border: 1px solid rgba(251, 191, 36, .3); }
.pill-gray { background: rgba(148, 163, 184, .14); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, .3); }
.dot { width: .6rem; height: .6rem; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot-green { background: #34d399; box-shadow: 0 0 10px #34d399; }
.dot-red { background: #f87171; box-shadow: 0 0 10px #f87171; }
.dot-gray { background: #64748b; }
.dot-amber { background: #fbbf24; box-shadow: 0 0 10px #fbbf24; }

/* Tabel */
.tbl { width: 100%; font-size: .875rem; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: .7rem 1rem; background: rgba(255, 255, 255, .03); white-space: nowrap; }
.tbl td { padding: .7rem 1rem; border-top: 1px solid rgba(255, 255, 255, .06); }
.tbl tbody tr:hover { background: rgba(255, 255, 255, .025); }
.row-line > * + * { border-top: 1px solid rgba(255, 255, 255, .06); }

/* Dialog */
dialog.modal {
  margin: auto; padding: 1.25rem; width: calc(100% - 2rem); color: var(--text);
  background: #0b1124; border: 1px solid var(--line); border-radius: 1rem;
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .65); }

/* Terminal tiruan */
.term { background: #050813; border: 1px solid var(--line); border-radius: .7rem; font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: .8rem; }

/* Chart */
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; font-size: .75rem; padding: .5rem .65rem; border-radius: .5rem;
  background: rgba(8, 12, 30, .95); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); white-space: nowrap;
}

/* Toast */
.toast-box { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .65rem .9rem; border-radius: .7rem; font-size: .85rem; background: #0d1430; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); max-width: 22rem; }
.toast-error { border-color: rgba(248, 113, 113, .5); color: #fecaca; }
.toast-ok { border-color: rgba(52, 211, 153, .5); color: #a7f3d0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Mobile: navigasi bawah ---------- */
:root { --bnav: calc(62px + env(safe-area-inset-bottom)); }
.app-shell { height: 100vh; height: 100dvh; }
.fill-page { height: calc(100vh - 72px - 3rem); height: calc(100dvh - 72px - 3rem); }
.mob-only { display: none !important; }
.bnav, .sheet { display: none; }
@media (max-width: 1023px) {
  .desk-only { display: none !important; }
  .mob-only { display: flex !important; }
  .side { display: none; }
  .topbar { height: 56px !important; padding-left: 1rem !important; padding-right: 1rem !important; }
  .topbar h1 { font-size: 1.1rem; }
  .mob-logo .logo { width: 2rem; height: 2rem; border-radius: .6rem; }
  .mob-logo .logo svg { width: 1.1rem; height: 1.1rem; }
  #main { padding: 1rem !important; padding-bottom: calc(var(--bnav) + 1rem) !important; }
  .fill-page { height: calc(100vh - 56px - 2rem - var(--bnav)); height: calc(100dvh - 56px - 2rem - var(--bnav)); }
  .inp, select, textarea { font-size: 16px !important; } /* cegah auto-zoom iOS */
  .pill-select select { max-width: 5.5rem; }

  .bnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: var(--bnav); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(8, 13, 31, .92); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    justify-content: space-around; align-items: stretch;
  }
  .bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #8b95ba; font-size: 11px; font-weight: 500; background: none; border: 0;
    -webkit-tap-highlight-color: transparent; position: relative;
  }
  .bnav-item.active { color: #fff; }
  .bnav-item.active::before {
    content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, #5b5bf0, #7c4dff);
  }
  .bnav-item.active svg { color: #a5b4fc; }

  .sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom));
    background: #0b1124; border-top: 1px solid var(--line); border-radius: 1.2rem 1.2rem 0 0;
    transform: translateY(105%); transition: transform .22s ease; max-height: 85dvh; overflow: auto;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
  }
  .sheet.open { transform: none; }
  .sheet-grip { width: 2.5rem; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .2); margin: 0 auto .9rem; }
  .sheet-item {
    display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .9rem .4rem;
    border-radius: .9rem; background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
    color: #b4bee6; font-size: 12px; text-align: center;
  }
  .sheet-item.active { color: #fff; background: linear-gradient(135deg, #5b5bf0, #7c4dff); border-color: transparent; }

  /* Tabel ringkas di layar kecil */
  .tbl th, .tbl td { padding: .6rem .7rem; }
}
@media (max-width: 639px) {
  .tbl-bots th:nth-child(n+3):nth-child(-n+6), .tbl-bots td:nth-child(n+3):nth-child(-n+6) { display: none; }
  .tbl-files th:nth-child(4), .tbl-files td:nth-child(4) { display: none; }
}

@media (max-width: 639px) {
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: .75rem !important; }
  .stat-grid .stat { padding: .8rem !important; }
  .stat-grid .stat > .flex { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .stat-grid .stat-ico { width: 2.2rem; height: 2.2rem; border-radius: .6rem; }
  .stat-grid .stat-ico svg { width: 1.2rem; height: 1.2rem; }
  .stat-grid .text-3xl { font-size: 1.45rem; }
  .stat-grid .stat .text-sm { font-size: .78rem; }
  .stat-grid .stat > svg { height: 1.8rem !important; margin-top: .5rem; }
  .card.p-5 { padding: 1rem; }
  .tbl th, .tbl td { padding: .55rem .5rem; }
  .pill-select select { max-width: 3.4rem; }
}

/* Jam realtime di top bar */
.clock { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; font-size: .9rem; font-weight: 600; color: #e2e8ff; letter-spacing: .02em; cursor: default; user-select: none; }
@media (max-width: 640px) { .clock { font-size: .78rem; padding: 0 .45rem; } .clock-ms { display: none; } }

/* Tombol tambahan terminal (HP) */
.tkeys { display: flex; gap: .35rem; overflow-x: auto; padding: .45rem .1rem .1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tkeys::-webkit-scrollbar { display: none; }
.tkey { flex: 0 0 auto; min-width: 2.6rem; height: 2.4rem; padding: 0 .6rem; border-radius: .5rem; border: 1px solid var(--line); background: rgba(255,255,255,.07); color: #e2e8ff; font: 600 .85rem ui-monospace, Menlo, Consolas, monospace; touch-action: manipulation; user-select: none; }
.tkey:active { background: rgba(99,102,241,.35); }
.tkey-mod.on { background: linear-gradient(135deg,#5b5bf0,#7c4dff); border-color: transparent; color: #fff; }
