:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #EEF2FF;
  --primary-grad: linear-gradient(135deg, #6366F1 0%, #4F46E5 55%, #4338CA 100%);
  --accent: #22C55E;
  --accent-grad: linear-gradient(135deg, #34D399 0%, #059669 100%);
  --blue-grad: linear-gradient(135deg, #60A5FA 0%, #2563EB 100%);
  --orange-grad: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
  --pink-grad: linear-gradient(135deg, #FB7185 0%, #E11D48 100%);
  --purple-grad: linear-gradient(135deg, #A78BFA 0%, #7C3AED 100%);
  --bg: #F3F4FA;
  --surface: #FFFFFF;
  --text: #1B1E2B;
  --text-muted: #6B7280;
  --border: #ECEEF3;
  --danger: #EF4444;
  --warning: #F59E0B;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(30, 41, 82, 0.06);
  --shadow-md: 0 14px 34px rgba(30, 41, 82, 0.10);
  --shadow-lg: 0 24px 48px rgba(30, 41, 82, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--primary); color: #fff; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D8DBE8; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #C2C6D6; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 24px; height: 24px; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #EEF2FF 0%, var(--bg) 60%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 32px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  margin-bottom: 16px;
}

.auth-brand h1 { font-size: 22px; margin: 0 0 6px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary-grad); color: #fff; border: none; box-shadow: 0 8px 18px rgba(79,70,229,.25); }
.btn-primary:hover { box-shadow: 0 10px 22px rgba(79,70,229,.34); transform: translateY(-1px); background: var(--primary-grad); }
.btn-danger { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-block { width: 100%; }

.alert { padding: 12px 14px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }

.auth-link { display: block; text-align: center; margin-top: 20px; font-size: 13px; color: var(--primary); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

/* ---------- Konten halaman (dipakai hampir semua halaman Owner/Cabang/POS-menu) ---------- */
.page-wrap { max-width: 1320px; margin: 0 auto; padding: 26px 28px 60px; }
.page-wrap h1 {
  font-size: 21px; font-weight: 800; margin: 0 0 20px; display: flex; align-items: center; gap: 12px;
}

/* Badge ikon bulat di sebelah judul halaman (mis. "$ Pengeluaran Operasional") — selaras dgn logo POS di sidebar */
.page-icon {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--primary-grad); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px rgba(79,70,229,.30);
}
.page-icon svg { width: 19px; height: 19px; }

.card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 24px 26px;
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 22px;
}
.card h2, .card h3 { margin-top: 0; font-size: 15px; font-weight: 800; }

/* <details class="card"><summary>...</summary></details> dipakai sebagai tombol "buka form tambah"
   yang collapsible (mis. Buat Purchase Order Baru, Kirim Barang ke Cabang). Distyle supaya
   terlihat jelas sebagai tombol aksi, bukan cuma teks biasa. */
details.card { padding: 0; overflow: hidden; }
details.card > summary {
  list-style: none; cursor: pointer; padding: 20px 24px; font-size: 14.5px; font-weight: 800;
  color: var(--primary); display: flex; align-items: center; gap: 10px; transition: background .12s;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary:hover { background: var(--primary-light); }
details.card > summary svg { width: 18px; height: 18px; flex-shrink: 0; }
details.card[open] > summary { border-bottom: 1px solid var(--border); }
details.card > summary::after {
  content: ''; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); margin-left: auto; opacity: .55; transition: transform .15s;
}
details.card[open] > summary::after { transform: rotate(45deg); }
details.card > *:not(summary) { padding: 24px; }

/* Form di dalam card: pakai CSS Grid 2 kolom yang PASTI mengisi penuh lebar card
   (bukan flex dengan lebar maksimum yang bisa nyisain ruang kosong besar kalau field-nya
   sedikit/pendek). Grid selalu membagi rata 2 kolom apa pun isinya -- prediktif & rapi. */
.card form, .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
.card form .field, .grid-2 .field, .grid-3 .field, .grid-2 > label, .grid-3 > label {
  margin-bottom: 0; min-width: 0;
}
.card form .field:has(textarea), .grid-2 .field:has(textarea), .grid-3 .field:has(textarea),
.card form .field.full, .grid-2 .field.full, .grid-3 .field.full {
  grid-column: 1 / -1;
}
.card form .field textarea { min-height: 80px; resize: vertical; width: 100%; }
.card form .checkbox-field, .checkbox-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13.5px; font-weight: 600; }
.card form > .checkbox-row, .card form > .checkbox-field { grid-column: 1 / -1; }
.card form > .grid-2, .card form > .grid-3 { grid-column: 1 / -1; }
.card form > .btn, .card form > button { grid-column: 1 / -1; margin-top: 4px; width: fit-content; min-width: 160px; }
.card form .form-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 4px; }
.card form .form-actions > * { flex: 0 0 auto; }

/* Form filter (Cabang/Karyawan/Dari/Sampai lalu tombol Terapkan) TIDAK memakai grid 2 kolom
   di atas -- ini selalu flex-row rapat, dipakai di halaman seperti Security Center. */
.card form.filter-bar, form.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.card form.filter-bar > div { display: block; }
@media (max-width: 640px) {
  .card form, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

table {
  width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface);
  border-radius: var(--radius-md); overflow: hidden;
}
table thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 800;
  color: var(--text-muted); background: var(--bg); padding: 12px 14px; border-bottom: 1px solid var(--border);
}
table tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #FAFAFD; }
table img { border-radius: 8px; object-fit: cover; }

.badge, .status-pill, .pill {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.badge-ok, .status-active, .pill-active { background: #F0FDF4; color: #15803D; }
.badge-fail, .status-inactive, .pill-inactive { background: #FEF2F2; color: #B91C1C; }
.pill-branch { background: var(--primary-light); color: var(--primary); }
.pill-master { background: #FEF3C7; color: #92400E; }

/* Tombol aksi kecil di baris tabel (Edit / Aktifkan / Nonaktifkan / Hapus, dll) — seragam ukuran & style.
   Setiap varian berdiri sendiri (tidak wajib digabung dengan .btn-sm) supaya aman dipakai di markup lama. */
.row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-sm, .btn-sm-edit, .btn-sm-danger, .btn-sm-success, .btn-sm-neutral {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 8px;
  font-size: 12px; font-weight: 700; border: none; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, transform .1s;
}
.btn-sm:hover, .btn-sm-edit:hover, .btn-sm-danger:hover, .btn-sm-success:hover, .btn-sm-neutral:hover { transform: translateY(-1px); }
.btn-sm, .btn-sm-edit { background: var(--primary-light); color: var(--primary); }
.btn-sm:hover, .btn-sm-edit:hover { background: #E0E4FA; }
.btn-sm-danger { background: #FEF2F2; color: var(--danger); }
.btn-sm-danger:hover { background: #FEE2E2; }
.btn-sm-success { background: #F0FDF4; color: #15803D; }
.btn-sm-success:hover { background: #DCFCE7; }
.btn-sm-neutral { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-sm-neutral:hover { background: #ECEEF5; }

/* Tabel filter bar (tanggal, cabang, tombol Filter/Export) yang muncul di Laporan/Pengeluaran/dll */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar input, .filter-bar select {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 13px; background: var(--surface);
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

/* Tab pill (dipakai di Laporan: Penjualan / Pengeluaran / dll) */
.tab-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab-pills a, .tab-pills button {
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none;
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); cursor: pointer;
}
.tab-pills a.active, .tab-pills button.active { background: var(--primary-grad); color: #fff; border: none; box-shadow: 0 6px 14px rgba(79,70,229,.28); }

/* ---------- App Layout (sidebar + content, dipakai semua halaman Owner/Cabang) ---------- */
.app-layout { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 252px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 0 16px; overflow-y: auto; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.app-sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 4px 20px 18px; font-weight: 700; font-size: 14px;
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.app-sidebar-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--primary-grad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800;
  box-shadow: 0 6px 14px rgba(79,70,229,.30); letter-spacing: .02em;
}
.app-sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.app-sidebar-brand-text strong { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sidebar-brand-text span { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }

.app-nav { display: flex; flex-direction: column; padding: 0 12px; flex: 1; }
.app-nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: #A2A6B8; font-weight: 800; margin: 16px 10px 6px; }
.app-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600; color: #454A5B; text-decoration: none; margin-bottom: 2px;
  transition: background .12s, color .12s;
}
.app-nav a svg { opacity: .8; transition: opacity .12s; }
.app-nav a:hover { background: var(--bg); color: var(--text); }
.app-nav a:hover svg { opacity: 1; }
.app-nav a.active { background: var(--primary-grad); color: #fff; box-shadow: 0 8px 18px rgba(79,70,229,.28); }
.app-nav a.active svg { opacity: 1; }
.app-main { flex: 1; min-width: 0; }

/* ---------- Topbar (search + notification bell, tampil di semua halaman dashboard) ---------- */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.app-topbar-search { flex: 1; max-width: 420px; position: relative; }
.app-topbar-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #A2A6B8; }
.app-topbar-search input {
  width: 100%; padding: 10px 14px 10px 40px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); font-size: 13.5px; color: var(--text);
}
.app-topbar-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.app-topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  position: relative; width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text);
  transition: background .12s;
}
.notif-bell-btn:hover { background: #E9EBF5; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}
.notif-dropdown {
  position: absolute; right: 0; top: 50px; width: 340px; max-width: 90vw;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); overflow: hidden; z-index: 50;
}
.notif-dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-dropdown-head a { color: var(--primary); text-decoration: none; font-size: 12px; font-weight: 600; }
.notif-dropdown-list { max-height: 340px; overflow-y: auto; }
.notif-dropdown-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-item { display: flex; gap: 10px; padding: 12px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item-icon {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px; background: var(--primary-light);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.notif-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 700; }
.notif-item-msg { font-size: 12px; color: var(--text-muted); }
.notif-item-time { font-size: 10px; color: var(--text-muted); }
.notif-dropdown-footer { display: block; text-align: center; padding: 11px; font-size: 12px; font-weight: 600; color: var(--primary); text-decoration: none; border-top: 1px solid var(--border); }
.notif-dropdown-footer:hover { background: var(--bg); }

/* ---------- Leaderboard (Karyawan Terbaik) ---------- */
.leaderboard-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank { width: 30px; font-weight: 800; font-size: 15px; color: var(--text-muted); text-align: center; }
.leaderboard-row.top1 .leaderboard-rank, .leaderboard-row.top2 .leaderboard-rank, .leaderboard-row.top3 .leaderboard-rank { font-size: 20px; }
.leaderboard-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #EEF2FF; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.leaderboard-name { font-weight: 700; font-size: 14px; }
.leaderboard-meta { font-size: 12px; color: var(--text-muted); }
.leaderboard-omzet { margin-left: auto; text-align: right; font-weight: 700; font-size: 14px; color: var(--accent); }
.leaderboard-row.top1 { background: linear-gradient(90deg, #FFFBEB, transparent); }
.badge-trophy { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; color: #92400E; background: #FEF3C7; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }

/* ---------- Purchase Order ---------- */
.po-item-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: center; margin-bottom: 8px; }

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .app-sidebar { width: 100%; height: auto; position: relative; }
  .app-nav { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
  .app-nav-label { display: none; }
  .app-nav a { white-space: nowrap; }
}

/* ---------- Installer Wizard ---------- */
.wizard-page { min-height: 100vh; padding: 40px 20px; }
.wizard-shell { max-width: 640px; margin: 0 auto; }
.wizard-steps { display: flex; gap: 6px; margin-bottom: 28px; }
.wizard-steps .dot {
  flex: 1; height: 4px; border-radius: 2px; background: var(--border);
}
.wizard-steps .dot.active { background: var(--primary); }
.wizard-steps .dot.done { background: var(--accent); }

.wizard-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}
.wizard-card h2 { margin-top: 0; }
.wizard-card p.desc { color: var(--text-muted); font-size: 14px; }

.check-list { list-style: none; padding: 0; margin: 20px 0; }
.check-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge-ok { background: #F0FDF4; color: #15803D; }
.badge-fail { background: #FEF2F2; color: #B91C1C; }

.wizard-actions { display: flex; justify-content: space-between; margin-top: 24px; }
