:root {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-soft: #dbeafe;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.06);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.5; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  min-width: 44px; min-height: 44px; font-size: 1.2rem; cursor: pointer; color: var(--text);
}

/* Formulir */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field input {
  width: 100%; padding: 0.7rem 0.8rem; border: 1px solid #cbd5e1; border-radius: 10px;
  font-size: 1rem; background: #fff; color: var(--text); min-height: 44px;
}
.field input:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.field .hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.field .error { color: var(--danger); font-size: 0.85rem; margin-top: 0.25rem; }
.input-row { display: flex; gap: 0.5rem; }
.input-row input { flex: 1; }

/* Peringatan */
.alert { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert-info { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary-dark); }
.alert-ok { background: var(--ok-soft); border-color: #bbf7d0; color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }

/* Kartu */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.15rem; word-break: break-word; }
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-error { background: var(--danger-soft); color: var(--danger); }
.badge-wait { background: var(--warn-soft); color: var(--warn); }

/* Tabel */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; width: 40%; font-size: 0.9rem; }

/* Halaman tamu (login, setup, beranda) */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: linear-gradient(160deg, #1e3a8a 0%, #1d4ed8 55%, #3b82f6 100%); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 16px; box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25); padding: 1.75rem; }
.auth-card .logo { font-weight: 800; letter-spacing: 0.04em; color: var(--primary); font-size: 1.1rem; margin-bottom: 0.25rem; }
.auth-card h1 { margin-bottom: 0.25rem; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 1.25rem; }
.stack > * + * { margin-top: 0.75rem; }
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; }

/* Dashboard */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--primary-dark); color: #fff; padding: 1.25rem 0.75rem; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { font-weight: 800; letter-spacing: 0.04em; font-size: 1.15rem; padding: 0 0.75rem 1.25rem; }
.sidebar .brand small { display: block; font-weight: 400; opacity: 0.75; letter-spacing: 0; font-size: 0.8rem; }
.sidebar nav a { display: block; padding: 0.7rem 0.75rem; border-radius: 10px; color: #dbeafe; text-decoration: none; margin-bottom: 0.25rem; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar nav a.active { background: #fff; color: var(--primary-dark); font-weight: 700; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; line-height: 1.2; }
.topbar .who small { color: var(--muted); display: block; }
.content { padding: 1.25rem; max-width: 1000px; }
.menu-toggle { display: none; }
.overlay { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .overlay.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 10; }
  .content { padding: 1rem; }
}

/* Toast */
.toast-container { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; max-width: calc(100vw - 2rem); }
.toast { background: #0f172a; color: #fff; padding: 0.7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
.mt { margin-top: 1rem; }
