/* Gaya dasar LAZERP, dibawa dari versi Python (v0.12.4), asal: prototipe LAZERP.dc.html.
   Warna tema memakai CSS custom property di :root (tema bisa diganti di Tahap 1E). */

:root {
  --background: #F4F7FB;
  --surface: #FFFFFF;
  --surfaceAlt: #EEF2F7;
  --border: #E2E8F0;
  --text: #111827;
  --textMuted: #6B7280;
  --sidebarBg: #1E3A8A;
  --sidebarText: #FFFFFF;
  --sidebarTextMuted: rgba(255, 255, 255, 0.6);
  --menuColor: rgba(255, 255, 255, 0.08);
  /* UI-A: menu aktif = garis kiri + latar terang (dulu latar merah penuh, terbaca seperti galat). */
  --menuActive: #93C5FD;
  --menuActiveBg: rgba(255, 255, 255, 0.14);
  --menuText: #FFFFFF;
  --buttonColor: #2563EB;
  --buttonText: #FFFFFF;

  --sidebarWidth: 270px;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: #2563EB; }
a:hover { color: #1D4ED8; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.35); border-radius: 8px; }

.app-root {
  display: flex;
  height: 100vh;
  width: 100%;
  background: var(--background);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

/* ---------- sidebar ---------- */

.sidebar {
  width: var(--sidebarWidth);
  min-width: var(--sidebarWidth);
  background: var(--sidebarBg);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.18s ease, min-width 0.18s ease;
}

.sidebar-head {
  padding: 12px 14px 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  position: relative;
}

/* UI-A: logo kecil + nama usaha dalam satu baris. */
.sidebar-merek { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-logo-box {
  background: transparent;
  border-radius: 9px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  overflow: hidden;
}
.sidebar-logo-box img { width: 40px; height: 40px; object-fit: contain; display: block; }
.sidebar-merek-teks { min-width: 0; }

.sidebar-copyright {
  font-size: 9.5px;
  color: var(--sidebarTextMuted);
  margin-top: 2px;
}

.sidebar.collapsed .sidebar-merek-teks,
.sidebar.collapsed .nav-heading,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-lencana { display: none; }
.sidebar.collapsed .sidebar-merek { justify-content: center; }

.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.15);
  z-index: 2;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 10px; }

.nav-heading {
  padding: 8px 20px 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--sidebarTextMuted);
}
/* Grup yang bisa dilipat (Sistem): judulnya tombol. */
button.nav-lipat {
  display: flex; align-items: center; gap: 6px; width: 100%;
  border: none; background: transparent; cursor: pointer; font-family: inherit; text-align: left;
}
button.nav-lipat:hover { color: var(--sidebarText); }
.nav-panah { display: inline-block; transition: transform 0.15s ease; }
.nav-grup:not(.terlipat) .nav-panah { transform: rotate(90deg); }
.nav-grup.terlipat .nav-item { display: none; }
/* Sidebar kecil hanya menampilkan ikon, jadi semua grup terbuka. */
.sidebar.collapsed .nav-grup.terlipat .nav-item { display: flex; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 1px 10px;
  padding: 5px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Segoe UI', system-ui, sans-serif;
  cursor: pointer;
  text-align: left;
}
.nav-item .nav-icon { font-size: 14px; }
.nav-lencana {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #DC2626; color: #FFFFFF; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  width: calc(100% - 16px);
  margin: 2px 8px;
  padding: 9px 0;
}

/* ---------- area utama ---------- */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 30px 34px;
  color: var(--text);
}

.page-title { font-size: 25px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--textMuted); margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-empty { font-size: 12.5px; color: var(--textMuted); }

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}

/* ---------- dasbor ---------- */

.dash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}
.dash-clock { text-align: right; }
.dash-clock .tanggal { font-size: 13px; font-weight: 700; }
.dash-clock .jam { font-size: 12.5px; color: var(--textMuted); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kpi-head { display: flex; align-items: center; gap: 8px; }
.kpi-icon { font-size: 15px; line-height: 1; }
.kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; }
.kpi-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.kpi-value { font-size: 19px; font-weight: 700; line-height: 1.15; overflow-wrap: break-word; }
.kpi-sub { font-size: 11px; color: var(--textMuted); }

.trend-card { grid-column: span 2; gap: 16px; }
.trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.trend-head .title { font-size: 14px; font-weight: 700; white-space: nowrap; }
.trend-switch {
  display: flex;
  gap: 3px;
  background: var(--surfaceAlt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
}
.trend-switch button {
  padding: 6px 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--textMuted);
  font-weight: 600;
  font-size: 11.5px;
  cursor: pointer;
}
.trend-switch button.active {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  color: var(--text);
}
.chart { display: flex; align-items: flex-end; gap: 14px; height: 150px; }
.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.chart-val { font-size: 10px; white-space: nowrap; }
.chart-bar { width: 100%; border-radius: 6px 6px 0 0; }
.chart-day { font-size: 11px; color: var(--textMuted); white-space: nowrap; }
.chart-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--textMuted);
}

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surfaceAlt);
  border-radius: 10px;
  padding: 11px 13px;
}
.balance-row .name { font-size: 12.5px; min-width: 0; overflow-wrap: break-word; }
.balance-row .val { font-size: 13px; font-weight: 700; white-space: nowrap; }

.list { display: flex; flex-direction: column; gap: 2px; }
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.list-row .primary { font-size: 12.5px; font-weight: 600; overflow-wrap: break-word; }
.list-row .plain { font-size: 12.5px; min-width: 0; overflow-wrap: break-word; }
.list-row .meta { font-size: 11px; color: var(--textMuted); margin-top: 2px; }
.list-row .amount { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.list-row .amount-sm { font-size: 12px; font-weight: 700; white-space: nowrap; }

.activity-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.activity-row .icon { font-size: 14px; line-height: 1.3; }
.activity-row .body { flex: 1; min-width: 0; }
.activity-row .text { font-size: 12.5px; overflow-wrap: break-word; }
.activity-row .time { font-size: 11px; color: var(--textMuted); margin-top: 2px; }

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.shortcut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surfaceAlt);
  cursor: pointer;
  min-width: 0;
}
.shortcut .icon { font-size: 21px; }
.shortcut .label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

/* ---------- AI Assistant (coming soon) ---------- */

.ai-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 75vh;
  text-align: center;
}
.ai-page .emoji { font-size: 38px; margin-bottom: 10px; }
.ai-page .title { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.ai-page .desc {
  font-size: 13.5px;
  color: var(--textMuted);
  max-width: 360px;
  margin-bottom: 22px;
}
.ai-page .row { display: flex; gap: 8px; width: 100%; max-width: 420px; }
.ai-page input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surfaceAlt);
  font-size: 13px;
  color: var(--text);
}
.ai-page button {
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  background: var(--border);
  color: var(--textMuted);
  font-weight: 600;
  font-size: 13px;
}
.ai-page .soon {
  margin-top: 14px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.06em;
}

/* ---------- placeholder tahap berikutnya ---------- */

.stage-todo {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 40px;
  text-align: center;
  color: var(--textMuted);
  font-size: 13px;
  line-height: 1.7;
}
.stage-todo strong { color: var(--text); }

/* ---------- notifikasi galat ---------- */

.err-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 460px;
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.3);
  z-index: 999;
  white-space: pre-wrap;
}

/* ---------- versi web (v0.13.0) ---------- */

/* Menu kini berupa tautan sungguhan: bisa dibuka di tab baru, tombol Kembali browser jalan. */
a.nav-item { text-decoration: none; background: transparent; color: var(--menuText); }
a.nav-item:hover { background: var(--menuColor); color: var(--menuText); }
a.nav-item.active { background: var(--menuActiveBg); color: var(--menuText); font-weight: 700; }
a.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
  border-radius: 3px; background: var(--menuActive);
}

.sidebar-foot {
  padding: 5px 18px 7px;
  font-size: 10.5px;
  color: var(--sidebarTextMuted);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar.collapsed .sidebar-foot { font-size: 0; padding: 6px; }

.status-card { max-width: 640px; }
.status-val.ok { color: #15803D; }
.status-val.gagal { color: #DC2626; }
.status-val { white-space: normal; text-align: right; }

.menu-hp, .sidebar-scrim { display: none; }

/* HP (Opsi 3): sidebar menjadi laci yang digeser masuk. Tablet ke atas tetap tampilan desktop. */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    min-width: 270px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.terbuka { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .sidebar-scrim.terbuka {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
  }
  .main { padding: 64px 16px 24px; }
  .menu-hp {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    z-index: 30;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
  }
  .page-title { font-size: 21px; }

  /* Pilihan "sidebar kecil" dari desktop tidak berlaku untuk laci HP. */
  .sidebar.collapsed .sidebar-merek-teks,
  .sidebar.collapsed .nav-heading { display: block; }
  .sidebar.collapsed button.nav-lipat { display: flex; }
  .sidebar.collapsed .sidebar-merek { justify-content: flex-start; }
  .sidebar.collapsed .nav-label { display: inline; }
  .sidebar.collapsed .nav-lencana { display: inline-flex; }
  .sidebar.collapsed .nav-grup.terlipat .nav-item { display: none; }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    width: calc(100% - 20px);
    margin: 1px 10px;
    padding: 7px 12px;
  }
  .sidebar.collapsed .sidebar-foot { font-size: 10.5px; padding: 10px 18px 14px; }
}

/* ---------- laporan (Tahap 7) ---------- */
.laporan { max-width: 980px; }
table.tabel-laporan { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table.tabel-laporan th, table.tabel-laporan td { padding: 7px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.tabel-laporan th { text-align: left; font-size: 11.5px; color: var(--textMuted); letter-spacing: 0.02em; }
table.tabel-laporan .angka { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tabel-laporan .kepala td { font-weight: 700; background: var(--surfaceAlt); }
table.tabel-laporan .anak td:first-child { padding-left: 28px; }
table.tabel-laporan .subtotal td { font-weight: 600; }
table.tabel-laporan .total td { font-weight: 700; border-top: 2px solid var(--text); }
table.tabel-laporan .redup { color: var(--textMuted); }
table.tabel-laporan a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--textMuted); }
table.tabel-laporan a:hover { color: var(--buttonColor); }
.laporan-grup { margin-bottom: 22px; }
.laporan-grup .card-title { margin-bottom: 10px; }
.kartu-laporan { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.kartu-laporan a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; }
.kartu-laporan a:hover { border-color: var(--buttonColor); }
.kartu-laporan strong { display: block; font-size: 14px; margin-bottom: 4px; }
.kartu-laporan span { font-size: 12px; color: var(--textMuted); }
.kartu-laporan .nanti { opacity: 0.55; pointer-events: none; }

/* ---------- dasbor tindakan (Tahap 7C) ---------- */
.angka-ringkas { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.angka-ringkas .kpi { color: var(--text); text-decoration: none; }
.angka-ringkas .kpi:hover { border-color: var(--buttonColor); }
.kotak-tugas { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.tugas { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #94A3B8; border-radius: 12px; padding: 12px 14px; }
.tugas-merah { border-left-color: #DC2626; }
.tugas-kuning { border-left-color: #D97706; }
.tugas-utama { display: flex; gap: 10px; align-items: flex-start; color: var(--text); text-decoration: none; }
.tugas-utama strong { display: block; font-size: 13.5px; }
.tugas-ikon { font-size: 18px; line-height: 1.2; }
.tugas-teks { display: block; font-size: 12.5px; color: var(--textMuted); margin-top: 2px; }
.tugas-rincian { margin: 8px 0 0 28px; padding: 0; font-size: 12px; }
.tugas-rincian li { margin: 2px 0; }

/* ---------- tombol cetak (Tahap 8A) ---------- */
.tombol-cetak { display: inline-flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.tombol-cetak .asli-pengganti { position: relative; }
.tombol-cetak .asli-pengganti > summary { list-style: none; }
.tombol-cetak .kotak-asli { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 300px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); display: grid; gap: 6px; }

/* ---------- Kirim WhatsApp & email (Tahap 9A) ---------- */
.kirim-kolom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kirim-kolom textarea.ctl { width: 100%; font-family: inherit; line-height: 1.45; }
.templat-dok { border-top: 1px solid var(--border); padding: 10px 0; }
.templat-dok > summary { cursor: pointer; padding: 4px 0; }
.templat-dok code, #templat .hint code { font-size: 0.85em; }
@media (max-width: 900px) { .kirim-kolom { grid-template-columns: 1fr; } }

/* ---------- Saran pesan ulang (Tahap 9B) ---------- */
.tabel-saran .pesan-isian { display: flex; gap: 6px; }
.tabel-saran .pesan-isian input { width: 90px; }
.tabel-saran .pesan-isian select { min-width: 80px; max-width: 170px; }
.tabel-saran td > select { min-width: 150px; max-width: 200px; }
.tabel-saran td:nth-child(2) { min-width: 160px; }
.tabel-saran .saran-ket { font-size: 0.82em; color: var(--textMuted); margin-top: 4px; }
.tabel-saran .saran-ket.lebih { color: #92400E; background: #FEF3C7; border-radius: 4px; padding: 2px 6px; display: inline-block; }
.filter-bar .btn.aktif { border-color: currentColor; font-weight: 600; }

/* Formulir sedang terkirim (cegah klik ganda, lihat app.js): tombol meredup, kursor menunggu. */
form.sedang-kirim button, form.sedang-kirim [type="submit"] { opacity: .6; cursor: progress; }
