/* ==========================================================================
   IPL-SaaS — gaya komponen di atas Tailwind CDN
   Palet: ink (navy) untuk permukaan, brand (biru) untuk aksi,
   emerald/amber/rose/sky untuk STATUS.
   ========================================================================== */

:root {
  --brand: #4f6ef7;
  --brand-600: #3b53dd;
  --brand-050: rgba(79, 110, 247, .12);
  --brand-ring: rgba(79, 110, 247, .26);
  --ink-950: #0a0e1c;
  --ink-900: #151b30;
  --ink-850: #1a2138;
  --ink-800: #212940;
  --ink-700: #333d55;
  --ink-600: #48546d;
  --teks: #e9edf6;
  --teks-lemah: #a3aec5;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* scrollbar tipis untuk tabel & nav */
.thin-scroll::-webkit-scrollbar { height: 6px; width: 8px; }
.thin-scroll::-webkit-scrollbar-thumb { background: #333d55; border-radius: 999px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }

/* --------------------------------------------------------------- kartu --- */
.card {
  background: var(--ink-900);
  border: 1px solid var(--ink-800);
  border-radius: 1rem;
}
.card-soft {
  background: linear-gradient(180deg, #19203a 0%, var(--ink-900) 100%);
  border: 1px solid var(--ink-800);
  border-radius: 1rem;
}
.card-garis-atas { position: relative; overflow: hidden; }
.card-garis-atas::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand) 0%, transparent 85%);
}

/* -------------------------------------------------------------- tombol --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1rem;
  border-radius: .75rem;
  font-weight: 600;
  font-size: .875rem;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: var(--ink-800); color: var(--teks); border-color: var(--ink-700); }
.btn-ghost:hover { background: #26304b; }
.btn-danger { background: #be123c; color: #fff; }
.btn-danger:hover { background: #9f1239; }
.btn-warn { background: #d97706; color: #1c1207; }
.btn-warn:hover { background: #b45309; color: #fff; }
.btn-outline { background: transparent; color: #cfd7e8; border-color: var(--ink-700); }
.btn-outline:hover { background: var(--ink-800); border-color: #43507007; }
.btn-sm { padding: .45rem .7rem; font-size: .78rem; border-radius: .6rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; flex: 1 1 auto; }
.btn { flex: 0 0 auto; }
.badge { flex: 0 0 auto; }

/* ---------------------------------------------------------------- form --- */
.input, .select, .textarea {
  width: 100%;
  background: #0d1424;
  border: 1px solid #2a3450;
  color: var(--teks);
  border-radius: .7rem;
  padding: .65rem .8rem;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.input::placeholder, .textarea::placeholder { color: #6b7897; }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--teks-lemah); margin-bottom: .3rem; }
.help { font-size: .74rem; color: #7f8ca9; }
.checkbox { width: 1.15rem; height: 1.15rem; accent-color: var(--brand); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8f9dbb 50%), linear-gradient(135deg, #8f9dbb 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 2.2rem; }

/* --------------------------------------------------------------- tabel --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.data th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #8f9dbb;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--ink-800);
  white-space: nowrap;
  background: #101728;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data td { padding: .65rem .75rem; border-bottom: 1px solid #1b2236; vertical-align: middle; }
table.data tbody tr:hover { background: #18203a; }
table.data tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------------- badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-emerald { background: rgba(16,185,129,.14); color: #34d399; border-color: rgba(16,185,129,.3); }
.badge-amber   { background: rgba(245,158,11,.14); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.badge-rose    { background: rgba(244,63,94,.14);  color: #fb7185; border-color: rgba(244,63,94,.3); }
.badge-slate   { background: rgba(143,157,187,.12);color: #cfd7e8; border-color: rgba(143,157,187,.25); }
.badge-sky     { background: rgba(14,165,233,.14); color: #38bdf8; border-color: rgba(14,165,233,.3); }
.badge-violet  { background: rgba(139,92,246,.14); color: #a78bfa; border-color: rgba(139,92,246,.3); }
.badge-brand   { background: var(--brand-050); color: #9ab3ff; border-color: rgba(79,110,247,.35); }

/* --------------------------------------------- navigasi atas (responsif) -
   Menu disusun dalam baris yang boleh MELIPAT (bukan geser horizontal) supaya
   tidak ada menu yang tersembunyi di luar layar. Beberapa menu membuka submenu
   berkelompok dengan keterangan singkat per anak menu. */
.nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  padding-bottom: .5rem;
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .75rem;
  border-radius: .7rem;
  font-size: .82rem;
  font-weight: 600;
  color: #aab5cd;
  white-space: nowrap;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, color .15s;
  /* PENTING: jangan pernah mengecil (terjepit) sehingga teks menu bertumpuk. */
  flex: 0 0 auto;
  cursor: pointer;
}
.nav-item:hover { background: var(--ink-800); color: var(--teks); }
.nav-item.active { background: var(--brand-050); color: #9ab3ff; border-color: rgba(79,110,247,.35); }

.nav-grup { position: relative; }
.nav-chev { height: .9rem; width: .9rem; opacity: .7; }
.nav-toggle[aria-expanded="true"] { background: var(--ink-800); color: var(--teks); }

.nav-panel {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  z-index: 50;
  width: max-content;
  min-width: 15rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: .35rem;
  border-radius: .9rem;
  border: 1px solid var(--ink-800);
  background: var(--ink-900);
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
}
.nav-panel-item {
  display: block;
  padding: .45rem .6rem;
  border-radius: .6rem;
  text-decoration: none;
}
.nav-panel-item:hover { background: var(--ink-800); }
.nav-panel-label { display: block; font-size: .82rem; font-weight: 600; color: var(--teks); }
.nav-panel-hint { display: block; font-size: .68rem; line-height: 1.35; color: #8492a8; }
.nav-panel-section {
  padding: .45rem .6rem .15rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6f7d95;
}
/* ikon & label pendek hanya dipakai di HP */
.nav-ikon { display: none; height: 1.15rem; width: 1.15rem; }
.nav-teks-hp { display: none; }

@media (max-width: 640px) {
  /* Di HP menu pindah ke BILAH BAWAH: mudah dijangkau jempol, header tetap
     tipis sehingga isi halaman dapat ruang lebih banyak. Submenu terbuka
     sebagai panel di atas bilah, selebar layar. */
  .nav-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: space-between;
    gap: .1rem;
    padding: .3rem .35rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    background: var(--ink-900);
    border-top: 1px solid var(--ink-800);
    box-shadow: 0 -8px 20px rgba(0,0,0,.35);
  }
  .nav-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: .12rem;
    padding: .32rem .15rem;
    font-size: .6rem;
    font-weight: 600;
    line-height: 1.1;
    border-radius: .6rem;
    text-align: center;
  }
  .nav-ikon { display: block; }
  .nav-teks-penuh { display: none; }
  .nav-teks-hp { display: inline; }
  .nav-chev { display: none; }
  .nav-grup { position: static; flex: 1 1 0; min-width: 0; }
  .nav-grup > .nav-item { width: 100%; }
  .nav-panel {
    top: auto;
    bottom: calc(100% + .45rem);
    left: .4rem;
    right: .4rem;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: 62vh;
    overflow-y: auto;
  }
  /* beri ruang bawah supaya isi halaman tidak tertutup bilah menu */
  main { padding-bottom: 5.4rem !important; }
}

/* ---------------------------------------------------------- stat card --- */
.stat {
  border-radius: 1rem;
  border: 1px solid var(--ink-800);
  background: var(--ink-900);
  padding: .9rem 1rem;
}
.stat .stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #8f9dbb; }
.stat .stat-value { font-size: 1.3rem; font-weight: 800; margin-top: .15rem; line-height: 1.2; }

/* ------------------------------------------------------ tombol darurat --- */
.panic-btn {
  width: 100%;
  border-radius: 1.25rem;
  background: radial-gradient(circle at 50% 30%, #f43f5e 0%, #be123c 70%);
  color: #fff;
  font-weight: 900;
  letter-spacing: .06em;
  padding: 1.7rem 1rem;
  font-size: 1.15rem;
  box-shadow: 0 12px 40px -12px rgba(244, 63, 94, .8);
  border: 2px solid rgba(255,255,255,.15);
  transition: transform .15s;
}
.panic-btn:active { transform: scale(.97); }
.panic-btn.armed { animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 12px 40px -12px rgba(244,63,94,.85); }
  50% { box-shadow: 0 0 0 14px rgba(244,63,94,.12), 0 12px 40px -12px rgba(244,63,94,.85); }
}

/* ------------------------------------------------------------ avatar ----- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .7rem;
  background: var(--ink-800);
  color: #9ab3ff;
  font-weight: 800;
  font-size: .8rem;
  flex: 0 0 auto;
}

/* ------------------------------------- kwitansi: tampil seperti kertas --- */
.kwitansi-paper {
  background: #ffffff;
  color: #0f172a;
  border-radius: .75rem;
  border: 1px solid #cbd5e1;
  max-width: 780px;
  margin: 0 auto;
}
.kwitansi-paper table { width: 100%; border-collapse: collapse; }
.kwitansi-paper .row-k { color: #475569; font-size: .8rem; padding: .35rem 0; width: 34%; }
.kwitansi-paper .row-v { font-weight: 700; font-size: .9rem; padding: .35rem 0; }
.kwitansi-paper .garis { border-top: 1px dashed #94a3b8; margin: .9rem 0; }

/* --------------------------------------------------------------- cetak --- */
@media print {
  .no-print { display: none !important; }
  .kwitansi-paper { border: none !important; box-shadow: none !important; max-width: 100% !important; }
  header, footer, #toast-wrap, nav { display: none !important; }
  main { max-width: 100% !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card, .stat { border-color: #ccc !important; background: #fff !important; }
  table.data th { background: #eee !important; color: #000 !important; }
  table.data td, table.data th { border-color: #ddd !important; color: #000 !important; }
  a { color: #000 !important; text-decoration: none; }
}

/* ---------------------------------------------------------------- util --- */
.divider { height: 1px; background: var(--ink-800); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
a.link { color: #9ab3ff; text-decoration: underline; text-underline-offset: 2px; }
[x-cloak] { display: none !important; }
.kosong { padding: 2rem 1rem; text-align: center; color: #818ea9; font-size: .85rem; }
.kosong .ikon { font-size: 1.8rem; display: block; margin-bottom: .4rem; opacity: .7; }
