/* ============================================================
   GKA APLIKASI KEUANGAN — STYLESHEET
   Light / Dark Mode + Collapsible Sidebar
   ============================================================ */

/* ========== CSS VARIABLES — LIGHT MODE ========== */
:root {
  --primary:        #5b5fcf;
  --primary-dark:   #4a4db5;
  --primary-light:  #7b7fe8;
  --secondary:      #f0a500;

  --bg-page:        #f0f2ff;
  --white:          #ffffff;
  --text-dark:      #1a1a2e;
  --text-mid:       #4a4a6a;
  --text-light:     #8888aa;
  --border:         #e0e0f0;

  --shadow:         0 4px 20px rgba(91,95,207,0.12);
  --shadow-hover:   0 8px 30px rgba(91,95,207,0.25);
  --radius:         16px;
  --radius-sm:      10px;

  --success:  #22c55e;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --info:     #3b82f6;

  /* sidebar */
  --sidebar-bg:      #ffffff;
  --sidebar-shadow:  2px 0 20px rgba(0,0,0,0.06);
  --sidebar-link:    #4a4a6a;
  --sidebar-hover:   rgba(91,95,207,0.08);

  /* card / table / form */
  --card-bg:         #ffffff;
  --card-hdr:        linear-gradient(135deg,rgba(91,95,207,.04),rgba(118,75,162,.04));
  --table-hover:     rgba(91,95,207,0.04);
  --table-border:    #e0e0f0;
  --input-bg:        #ffffff;
  --input-border:    #e0e0f0;
  --modal-bg:        #ffffff;
  --pagebtn-bg:      #ffffff;

  /* badges */
  --badge-db:  rgba(59,130,246,.15);
  --badge-kr:  rgba(239,68,68,.15);
  --badge-ne:  rgba(34,197,94,.15);
  --badge-lr:  rgba(245,158,11,.15);

  /* report */
  --report-sec:   rgba(91,95,207,.08);
  --report-total: rgba(91,95,207,.05);

  /* sidebar width */
  --sidebar-w:         220px;
  --sidebar-collapsed: 60px;
}

/* ========== CSS VARIABLES — DARK MODE ========== */
[data-theme="dark"] {
  --primary:       #7b7fe8;
  --primary-dark:  #5b5fcf;
  --primary-light: #9a9ef2;

  --bg-page:    #12122a;
  --white:      #1e1e3a;
  --text-dark:  #e8e8f8;
  --text-mid:   #b0b0d0;
  --text-light: #6868a0;
  --border:     #2e2e52;

  --shadow:       0 4px 20px rgba(0,0,0,.4);
  --shadow-hover: 0 8px 30px rgba(0,0,0,.55);

  --sidebar-bg:    #1a1a36;
  --sidebar-shadow: 2px 0 20px rgba(0,0,0,.35);
  --sidebar-link:  #b0b0d0;
  --sidebar-hover: rgba(123,127,232,.12);

  --card-bg:   #1e1e3a;
  --card-hdr:  linear-gradient(135deg,rgba(123,127,232,.08),rgba(118,75,162,.08));
  --table-hover:  rgba(123,127,232,.08);
  --table-border: #2e2e52;
  --input-bg:     rgba(22,22,48,.5);
  --input-border: #3a3a60;
  --modal-bg:     #1e1e3a;
  --pagebtn-bg:   #1e1e3a;

  --badge-db: rgba(59,130,246,.2);
  --badge-kr: rgba(239,68,68,.2);
  --badge-ne: rgba(34,197,94,.2);
  --badge-lr: rgba(245,158,11,.2);

  --report-sec:   rgba(123,127,232,.1);
  --report-total: rgba(123,127,232,.08);
}

/* ========== RESET ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-dark);
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, #4a4db5 0%, #764ba2 100%);
  box-shadow: 0 2px 20px rgba(0,0,0,.25);
  padding: 0; /* Remove right padding to fix background */
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 12px;
  flex-wrap: nowrap;
  width: 100%; /* Ensure full width */
}

/* Sidebar toggle button (hamburger) di kiri header */
.sidebar-toggle {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  background: rgba(0,0,0,.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  transition: background .2s;
}
.sidebar-toggle:hover { background: rgba(0,0,0,.28); }

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

/* Logo fallback (teks GKA) */
.brand-logo {
  height: 52px;
  min-width: 52px;
  max-width: 100px;
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #1a3a6e;
  border: 2px solid rgba(255,255,255,.3);
  flex-shrink: 0;
  overflow: hidden;
}

/* Logo gambar aktif */
.brand-logo.has-logo {
  background: transparent;
  border: none;
  border-radius: 0;
  height: 60px;
  min-width: unset;
  max-width: 150px;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-info h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-info p { font-size: 11px; color: rgba(255,255,255,.75); margin-top: 2px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding-right: 12px; /* Add padding to keep inside header */
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: rgba(255,255,255,.15);
  border-radius: 40px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  border: 2px solid rgba(255,255,255,.4);
}
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.75); }

/* ===== LOGOUT — MERAH ===== */
.btn-logout {
  padding: 8px 18px;
  background: #e53e3e;
  color: white;
  border: 2px solid #c53030;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 12px rgba(229,62,62,.35);
}
.btn-logout:hover {
  background: #c53030;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(229,62,62,.45);
}

/* ===== DARK MODE TOGGLE ===== */
.dark-toggle {
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 50px;
  padding: 6px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  color: white;
  font-size: 13px; font-weight: 600;
  transition: background .2s;
  white-space: nowrap;
}
.dark-toggle:hover { background: rgba(255,255,255,.28); }
.dark-toggle .toggle-icon { font-size: 16px; }

/* ===== HOME MOBILE BUTTON ===== */
.home-mobile-btn {
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 50px;
  padding: 6px 12px;
  cursor: pointer;
  display: none; /* Hidden by default, shown only on mobile < 700px */
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  transition: background .2s;
  text-decoration: none;
}
.home-mobile-btn:hover { background: rgba(255,255,255,.28); }
.home-mobile-btn .home-icon { font-size: 16px; }


/* ============================================================
   LAYOUT — SIDEBAR + MAIN
   ============================================================ */
.app-body {
  display: flex;
  min-height: calc(100vh - 72px);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  box-shadow: var(--sidebar-shadow);
  padding: 12px 0;
  flex-shrink: 0;
  position: fixed;
  top: 72px;
  bottom: 0;
  left: 0;
  height: calc(100vh - 72px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: width .28s cubic-bezier(.4,0,.2,1), background .3s;
  z-index: 100;
}
.sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Collapsed state */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--sidebar-link);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .2s, color .2s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--sidebar-hover);
  color: var(--primary);
  border-left-color: var(--primary);
}

.nav-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

/* Label teks nav — disembunyikan saat collapse */
.nav-label {
  transition: opacity .2s;
  overflow: hidden;
}
.sidebar.collapsed .nav-label { opacity: 0; }

/* Tooltip saat collapsed */
.sidebar.collapsed .sidebar-nav a {
  position: relative;
  padding-left: 19px;
}
.sidebar.collapsed .sidebar-nav a::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 8px);
  top: 50%; transform: translateY(-50%);
  background: var(--text-dark);
  color: var(--bg-page);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.sidebar.collapsed .sidebar-nav a:hover::after { opacity: 1; }

/* Main shifts with sidebar */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  transition: margin-left .28s cubic-bezier(.4,0,.2,1);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-title {
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 28px;
  letter-spacing: 1px;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  gap: 18px;
  margin-bottom: 32px;
}

.module-card {
  border-radius: var(--radius);
  padding: 26px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform .25s, box-shadow .25s, border-color .25s;
  text-decoration: none;
  color: var(--text-dark);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.module-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.18;
  border-radius: var(--radius);
  transition: opacity .3s;
}
.module-card:hover::before {
  opacity: 0.3;
}
.module-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(255,255,255,.4);
}
.module-icon { font-size: 42px; margin-bottom: 10px; display: block; position: relative; }
.module-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; position: relative; }
.module-desc  { font-size: 11px; color: var(--text-light); position: relative; }

/* Dashboard module card colors */
.card-master-data       { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.card-master-data::before { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.card-daftar-akun       { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.card-daftar-akun::before { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.card-kode-pembantu     { background: linear-gradient(135deg, #ccfbf1, #99f6e4); }
.card-kode-pembantu::before { background: linear-gradient(135deg, #0d9488, #5eead4); }
.card-jurnal-umum       { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.card-jurnal-umum::before { background: linear-gradient(135deg, #16a34a, #86efac); }
.card-buku-besar        { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.card-buku-besar::before { background: linear-gradient(135deg, #d97706, #fbbf24); }
.card-neraca-saldo      { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.card-neraca-saldo::before { background: linear-gradient(135deg, #4f46e5, #818cf8); }
.card-neraca-lajur      { background: linear-gradient(135deg, #ffedd5, #fed7aa); }
.card-neraca-lajur::before { background: linear-gradient(135deg, #ea580c, #fb923c); }
.card-laba-rugi         { background: linear-gradient(135deg, #ffe4e6, #fecdd3); }
.card-laba-rugi::before { background: linear-gradient(135deg, #e11d48, #fb7185); }
.card-neraca            { background: linear-gradient(135deg, #fdf2f8, #fce7f3); }
.card-neraca::before    { background: linear-gradient(135deg, #db2777, #f472b6); }
.card-buku-besar-pembantu { background: linear-gradient(135deg, #eef2ff, #e0e7ff); }
.card-buku-besar-pembantu::before { background: linear-gradient(135deg, #6366f1, #a5b4fc); }
.card-neraca-saldo-pembantu { background: linear-gradient(135deg, #cffafe, #a5f3fc); }
.card-neraca-saldo-pembantu::before { background: linear-gradient(135deg, #0891b2, #06b6d4); }
.card-arus-kas          { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }
.card-arus-kas::before  { background: linear-gradient(135deg, #059669, #6ee7b7); }
.card-pengaturan        { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }
.card-pengaturan::before { background: linear-gradient(135deg, #64748b, #94a3b8); }
.card-analisis-keuangan        { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); }
.card-analisis-keuangan::before { background: linear-gradient(135deg, #9333ea, #c084fc); }

[data-theme="dark"] .card-master-data       { background: linear-gradient(135deg, #2e1065, #3b0764); color: #e9d5ff; }
[data-theme="dark"] .card-master-data .module-desc { color: #c4b5fd; }
[data-theme="dark"] .card-daftar-akun       { background: linear-gradient(135deg, #1e3a5f, #172554); color: #bfdbfe; }
[data-theme="dark"] .card-daftar-akun .module-desc { color: #93c5fd; }
[data-theme="dark"] .card-kode-pembantu     { background: linear-gradient(135deg, #134e4a, #022c22); color: #99f6e4; }
[data-theme="dark"] .card-kode-pembantu .module-desc { color: #5eead4; }
[data-theme="dark"] .card-jurnal-umum       { background: linear-gradient(135deg, #14532d, #052e16); color: #bbf7d0; }
[data-theme="dark"] .card-jurnal-umum .module-desc { color: #86efac; }
[data-theme="dark"] .card-buku-besar        { background: linear-gradient(135deg, #451a03, #292524); color: #fde68a; }
[data-theme="dark"] .card-buku-besar .module-desc { color: #fbbf24; }
[data-theme="dark"] .card-neraca-saldo      { background: linear-gradient(135deg, #312e81, #1e1b4b); color: #c7d2fe; }
[data-theme="dark"] .card-neraca-saldo .module-desc { color: #818cf8; }
[data-theme="dark"] .card-neraca-lajur      { background: linear-gradient(135deg, #431407, #292524); color: #fed7aa; }
[data-theme="dark"] .card-neraca-lajur .module-desc { color: #fb923c; }
[data-theme="dark"] .card-laba-rugi         { background: linear-gradient(135deg, #4c0519, #292524); color: #fecdd3; }
[data-theme="dark"] .card-laba-rugi .module-desc { color: #fb7185; }
[data-theme="dark"] .card-neraca            { background: linear-gradient(135deg, #4a0e2b, #292524); color: #fce7f3; }
[data-theme="dark"] .card-neraca .module-desc { color: #f472b6; }
[data-theme="dark"] .card-buku-besar-pembantu { background: linear-gradient(135deg, #1e1b4b, #172554); color: #e0e7ff; }
[data-theme="dark"] .card-buku-besar-pembantu .module-desc { color: #a5b4fc; }
[data-theme="dark"] .card-neraca-saldo-pembantu { background: linear-gradient(135deg, #164e63, #083344); color: #a5f3fc; }
[data-theme="dark"] .card-neraca-saldo-pembantu .module-desc { color: #67e8f9; }
[data-theme="dark"] .card-arus-kas          { background: linear-gradient(135deg, #064e3b, #022c22); color: #a7f3d0; }
[data-theme="dark"] .card-arus-kas .module-desc { color: #6ee7b7; }
[data-theme="dark"] .card-pengaturan        { background: linear-gradient(135deg, #1e293b, #0f172a); color: #e2e8f0; }
[data-theme="dark"] .card-pengaturan .module-desc { color: #94a3b8; }
[data-theme="dark"] .card-analisis-keuangan        { background: linear-gradient(135deg, #3b0764, #2e1065); color: #e9d5ff; }
[data-theme="dark"] .card-analisis-keuangan .module-desc { color: #c084fc; }

[data-theme="dark"] .module-card { border-color: transparent; }
[data-theme="dark"] .module-card:hover { border-color: rgba(255,255,255,.15); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.stat-card {
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: var(--shadow);
  transition: background .3s;
  border-left: 5px solid transparent;
}
.stat-card h3 {
  font-size: 14px; font-weight: 700;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(0,0,0,.08);
}

.stat-master-data { background: linear-gradient(135deg, #eef2ff, #e0e7ff); border-left-color: #6366f1; }
.stat-master-data h3 { color: #4338ca; }
.stat-ringkasan-akun { background: linear-gradient(135deg, #fdf2f8, #fce7f3); border-left-color: #ec4899; }
.stat-ringkasan-akun h3 { color: #db2777; }
.stat-transaksi { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border-left-color: #22c55e; }
.stat-transaksi h3 { color: #16a34a; }

[data-theme="dark"] .stat-master-data { background: linear-gradient(135deg, #1e1b4b, #312e81); border-left-color: #818cf8; }
[data-theme="dark"] .stat-master-data h3 { color: #a5b4fc; }
[data-theme="dark"] .stat-ringkasan-akun { background: linear-gradient(135deg, #4a0e2b, #831843); border-left-color: #f472b6; }
[data-theme="dark"] .stat-ringkasan-akun h3 { color: #f9a8d4; }
[data-theme="dark"] .stat-transaksi { background: linear-gradient(135deg, #052e16, #14532d); border-left-color: #4ade80; }
[data-theme="dark"] .stat-transaksi h3 { color: #86efac; }
[data-theme="dark"] .stat-card h3 { border-bottom-color: rgba(255,255,255,.1); }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-value { font-weight: 600; color: var(--text-dark); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 800; color: var(--primary); }
.page-subtitle { font-size: 13px; color: var(--text-light); margin-top: 2px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 9px 20px; border-radius: 8px; border: none;
  cursor: pointer; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .2s; text-decoration: none;
}
.btn-primary   { background: var(--primary);   color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: var(--success);   color: white; }
.btn-danger    { background: var(--danger);    color: white; }
.btn-warning   { background: var(--warning);   color: white; }
.btn-secondary { background: var(--border);    color: var(--text-mid); }
.btn-info      { background: var(--info);      color: white; }
.btn-info:hover { background: #2563eb; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background .3s;
}
.card-header {
  padding: 16px 22px;
  border-bottom: 2px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card-hdr);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--primary); }
.card-body  { padding: 18px 22px; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; padding: 11px 14px;
  text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child  { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--table-border); transition: background .15s; }
tbody tr:hover { background: var(--table-hover); }
tbody td { padding: 10px 14px; color: var(--text-dark); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-light); font-size: 12px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group  { margin-bottom: 18px; }
.form-label  { display: block; font-size: 13px; font-weight: 600; color: var(--text-mid); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 2px solid var(--input-border); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-dark);
  background: var(--input-bg);
  transition: border .2s, background .3s, color .3s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(91,95,207,.12);
}

/* Date input styling */
input[type="text"].form-control.flatpickr-input {
  position: relative;
  font-family: inherit;
  cursor: pointer;
}
input[type="text"].form-control.flatpickr-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  filter: var(--calendar-icon-filter, invert(0));
}
input[type="text"].form-control.flatpickr-input:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}
[data-theme="dark"] input[type="text"].form-control.flatpickr-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* Flatpickr Custom Theme */
.flatpickr-calendar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.flatpickr-months {
  background: var(--primary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  color: white;
  font-weight: 600;
}
.flatpickr-weekday {
  color: var(--text-mid);
  font-weight: 600;
}
.flatpickr-day {
  color: var(--text-dark);
}
.flatpickr-day:hover {
  background: var(--table-hover);
  border-color: var(--primary-light);
}
.flatpickr-day.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.flatpickr-day.today {
  border-color: var(--primary);
}
.flatpickr-day.disabled {
  color: var(--text-light);
}
[data-theme="dark"] .flatpickr-calendar {
  background: var(--card-bg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
[data-theme="dark"] .flatpickr-months .flatpickr-prev-month svg,
[data-theme="dark"] .flatpickr-months .flatpickr-next-month svg {
  fill: white;
}

select.form-control option { background: var(--card-bg); color: var(--text-dark); }
.form-row   { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-group { position: relative; }

/* ---- Autocomplete Dropdown (inside forms) ---- */
.form-group .autocomplete-wrap { position: relative; }
.form-group .ac-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 1100;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-hover);
  max-height: 220px; overflow-y: auto; display: none;
  margin-top: 2px;
}
.form-group .ac-item {
  padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border); transition: background 0.12s;
}
.form-group .ac-item:last-child { border-bottom: none; }
.form-group .ac-item:hover,
.form-group .ac-item.highlight { background: rgba(91,95,207,0.1); }
.form-group .ac-item .ac-kode {
  font-family: monospace; font-size: 11px; font-weight: 600;
  color: var(--primary); background: rgba(91,95,207,0.08);
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.form-group .ac-item .ac-nama { font-size: 12px; color: var(--text-dark); }
.form-group .ac-empty {
  padding: 16px; text-align: center; color: var(--text-light); font-size: 12px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-debet   { background: var(--badge-db); color: #3b82f6; }
.badge-kredit  { background: var(--badge-kr); color: #ef4444; }
.badge-neraca  { background: var(--badge-ne); color: #22c55e; }
.badge-labarugi{ background: var(--badge-lr); color: #f59e0b; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 500; display: flex; align-items: flex-start; justify-content: center;
  backdrop-filter: blur(4px);
  overflow-y: auto; padding: 5vh 0;
}
.modal {
  background: var(--modal-bg);
  border-radius: var(--radius);
  width: min(90vw,640px); max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  transition: background .3s;
  display: flex; flex-direction: column;
}
.modal-wide { width: min(96vw,1200px); }
.modal-header {
  padding: 18px 22px; border-bottom: 2px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }
.modal-body  { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer{
  padding: 14px 22px; border-top: 2px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: rgba(34,197,94,.1);  color: #15803d; border: 1px solid rgba(34,197,94,.3); }
.alert-danger  { background: rgba(239,68,68,.1);  color: #b91c1c; border: 1px solid rgba(239,68,68,.3); }
[data-theme="dark"] .alert-success { color: #4ade80; }
[data-theme="dark"] .alert-danger  { color: #f87171; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar .form-control { width: auto; min-width: 180px; }

/* ============================================================
   NERACA LAJUR
   ============================================================ */
.nl-table thead th { font-size: 11px; padding: 8px 10px; }
.nl-table tbody td { padding: 7px 10px; font-size: 12px; }
.nl-table .group-header td { background: var(--report-sec); font-weight: 700; color: var(--primary); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { display: flex !important; gap: 4px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.page-btn {
  padding: 7px 12px; border: 2px solid var(--border); border-radius: 6px;
  cursor: pointer; font-size: 13px; background: var(--pagebtn-bg);
  color: var(--text-dark); transition: all .2s;
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; white-space: nowrap;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   LAPORAN — LABA RUGI / NERACA
   ============================================================ */
.report-section { margin-bottom: 24px; }
.report-section-title {
  font-size: 13px; font-weight: 700; color: var(--primary);
  padding: 8px 14px; background: var(--report-sec);
  border-left: 4px solid var(--primary);
  margin-bottom: 8px; border-radius: 0 6px 6px 0;
}
.report-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 14px 7px 28px; font-size: 13px; gap: 16px;
  border-bottom: 1px solid var(--border); color: var(--text-dark);
}
.report-row span:last-child {
  text-align: right; white-space: nowrap;
}
.report-row.total {
  font-weight: 700; background: var(--report-total);
  padding-left: 14px; color: var(--primary);
}
.report-row.grand-total {
  font-weight: 800; background: var(--primary); color: white;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding-left: 14px;
}

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box { position: relative; }
.search-box .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); pointer-events: none;
}
.search-box .form-control { padding-left: 36px; }

/* ============================================================
   MISC
   ============================================================ */
.positive { color: var(--success); }
.negative { color: var(--danger); }
.zero     { color: var(--text-light); }
.no-sidebar .main-content { margin-left: 0; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: white;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LOGO UPLOAD (settings)
   ============================================================ */
.logo-dropzone {
  position: relative; border: 2px dashed var(--primary-light);
  border-radius: var(--radius-sm); background: var(--report-sec);
  cursor: pointer; transition: border-color .2s, background .2s;
  overflow: hidden; min-height: 110px;
  display: flex; align-items: center; justify-content: center;
}
.logo-dropzone:hover, .logo-dropzone.dragover {
  border-color: var(--primary); background: rgba(91,95,207,.1);
}
.logo-file-input {
  position: absolute; inset: 0; opacity: 0;
  width: 100%; height: 100%; cursor: pointer; z-index: 1;
}
.logo-dropzone-inner { text-align: center; padding: 20px; pointer-events: none; }
.logo-dropzone-icon { font-size: 30px; display: block; margin-bottom: 6px; }
.logo-dropzone-text { font-size: 13px; font-weight: 600; color: var(--text-mid); margin-bottom: 4px; }
.logo-dropzone-hint { font-size: 11px; color: var(--text-light); }
.logo-file-chosen {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; width: 100%; pointer-events: none;
}
.logo-new-preview {
  height: 60px; max-width: 120px; width: auto;
  object-fit: contain; border-radius: 6px;
  border: 2px solid var(--primary-light); flex-shrink: 0;
}
.logo-file-name { font-size: 12px; color: var(--text-mid); word-break: break-all; }
.logo-preview-box { display: flex; align-items: center; gap: 16px; }
.logo-preview-img {
  height: 80px; max-width: 160px; width: auto;
  object-fit: contain; border-radius: 8px;
  border: 2px solid var(--primary-light);
  background: rgba(0,0,0,.04); padding: 4px;
}
.logo-empty { text-align: center; padding: 18px 0 8px; color: var(--text-light); font-size: 13px; }
.logo-empty-icon { font-size: 36px; margin-bottom: 6px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4a4db5 0%, #764ba2 100%);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  width: 100%; max-width: 420px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #4a4db5 0%, #764ba2 100%);
  padding: 36px 32px 28px;
  text-align: center;
}
.login-logo {
  width: 88px; height: 88px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 26px; color: #1a3a6e;
  border: 3px solid rgba(255,255,255,.35);
  overflow: hidden;
}
.login-logo.has-logo { background: transparent; border: none; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-app-name {
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.8); letter-spacing: 2px;
  text-transform: uppercase; margin-bottom: 4px;
}
.login-company {
  font-size: 18px; font-weight: 800; color: #ffffff; line-height: 1.2;
}
.login-body { padding: 32px; }
.login-body h2 {
  font-size: 17px; font-weight: 700; color: var(--text-dark);
  margin-bottom: 22px; text-align: center;
}
.login-body .form-group { margin-bottom: 16px; }
.login-btn {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, #5b5fcf, #764ba2);
  color: white; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: opacity .2s, transform .15s;
  margin-top: 8px;
}
.login-btn:hover { opacity: .92; transform: translateY(-1px); }
.login-footer {
  text-align: center; padding: 14px 32px 24px;
  font-size: 12px; color: var(--text-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Sidebar overlay untuk mobile */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.5);
  display: none;
  backdrop-filter: blur(2px);
}

@media (max-width: 1200px) {
  .modules-grid { grid-template-columns: repeat(3,1fr); }
}

/* Show Home button on mobile screens < 700px */
@media (max-width: 700px) {
  .home-mobile-btn {
    display: flex;
  }
}

@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed); overflow: visible; }
  .sidebar .nav-label { opacity: 0; }
  .sidebar .sidebar-nav a { position: relative; padding-left: 19px; }
  .sidebar .sidebar-nav a::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 8px);
    top: 50%; transform: translateY(-50%);
    background: var(--text-dark);
    color: var(--bg-page);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 300;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
  }
  .sidebar .sidebar-nav a:hover::after { opacity: 1; }
  .main-content { margin-left: var(--sidebar-collapsed); }
}

@media (max-width: 768px) {
  /* ── Header compact ── */
  .app-header { height: 60px; padding: 0 12px 0 0; gap: 8px; }
  .sidebar-toggle { width: 56px; height: 60px; font-size: 18px; }
  .brand-logo { height: 40px; min-width: 40px; max-width: 80px; font-size: 13px; }
  .brand-logo.has-logo { height: 44px; max-width: 100px; }
  .brand-logo-img { max-width: 90px; }
  .brand-info h1 { font-size: 15px; }
  .brand-info p { font-size: 10px; }
  .header-right { gap: 8px; }
  .user-badge { padding: 4px 10px; gap: 8px; }
  .user-avatar { width: 28px; height: 28px; font-size: 12px; }
  .user-name { font-size: 12px; }
  .user-role { font-size: 10px; }
  .dark-toggle { padding: 4px 10px; font-size: 12px; }
  .dark-toggle .toggle-label { display: none; }
  .dark-toggle .toggle-icon { font-size: 14px; }
  .home-mobile-btn { padding: 4px 10px; }
  .home-mobile-btn .home-icon { font-size: 14px; }
  .user-badge .user-name,
  .user-badge .user-role { display: none; }
  .btn-logout { padding: 5px 12px; font-size: 12px; }

  /* ── Sidebar slide ── */
  .sidebar { transform: translateX(-100%); transition: transform .28s, width .28s; width: var(--sidebar-w); z-index: 100; padding-top: 72px; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; padding: 20px; }
  .modules-grid { grid-template-columns: repeat(2,1fr); }
  .stats-grid { grid-template-columns: 1fr; }

  /* ── Layout stack ── */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header .btn { width: 100%; justify-content: center; }
  .form-row-2,
  .form-row-3,
  .form-row-4 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { width: 100%; min-width: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .pagination-info { display: none; }
  .pagination-wrap { justify-content: center; }

  /* ── Card/table ── */
  .card-body { padding: 14px; }
  table { font-size: 12px; }
  thead th,
  tbody td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  /* ── Header very compact ── */
  .app-header { height: 52px; padding: 0 6px 0 0; gap: 4px; }
  .sidebar-toggle { width: 44px; height: 52px; font-size: 16px; }
  .header-brand { gap: 8px; }
  .brand-logo { height: 32px; min-width: 32px; max-width: 50px; font-size: 11px; border-width: 1px; }
  .brand-logo.has-logo { height: 36px; max-width: 70px; }
  .brand-logo-img { max-width: 60px; }
  .brand-info h1 { font-size: 12px; }
  .brand-info p { font-size: 9px; margin-top: 1px; }
  .header-right { gap: 4px; }
  .user-badge { padding: 2px 6px; gap: 4px; border-radius: 30px; }
  .user-avatar { width: 22px; height: 22px; font-size: 9px; border-width: 1px; }
  .dark-toggle { padding: 2px 6px; font-size: 10px; border-width: 1px; }
  .dark-toggle .toggle-icon { font-size: 12px; }
  .home-mobile-btn { padding: 2px 6px; border-width: 1px; }
  .home-mobile-btn .home-icon { font-size: 12px; }
  .btn-logout { padding: 3px 8px; font-size: 10px; gap: 3px; border-width: 1px; box-shadow: 0 2px 6px rgba(229,62,62,.3); }

  /* ── Page content ── */
  .home-title { font-size: 16px; margin-bottom: 16px; letter-spacing: 0; }
  .modules-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .module-card { padding: 14px 8px; }
  .module-icon { font-size: 28px; margin-bottom: 6px; }
  .module-title { font-size: 11px; margin-bottom: 0; }
  .module-desc { display: none; }
  .stat-card { padding: 14px 16px; }
  .stat-card h3 { font-size: 13px; margin-bottom: 10px; }
  .stat-row { font-size: 12px; padding: 7px 0; }

  .main-content { padding: 10px !important; }

  /* ── Card header ── */
  .card-header { padding: 10px 12px; flex-direction: column; gap: 8px; align-items: stretch; }
  .card-header .btn { width: 100%; justify-content: center; }

  /* ── Modal full layar ── */
  .modal { width: 100vw; max-height: 100vh; border-radius: 0; }
  .modal-wide { width: 100vw; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-title { font-size: 14px; }
  .modal-footer { padding: 10px 14px; flex-direction: column; gap: 6px; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* ── Summary ── */
  .summary-item { min-width: 80px; padding: 6px 10px; }
  .summary-label { font-size: 9px; }
  .summary-value { font-size: 13px; }

  /* ── Pagination ── */
  .page-btn { min-width: 28px; height: 28px; font-size: 11px; padding: 0 6px; }
  .page-btn-nav { min-width: 50px !important; font-size: 10px !important; padding: 0 6px !important; }

  /* ── Filter ── */
  .filter-bar { gap: 6px; }
  .filter-bar .form-control { font-size: 12px; padding: 6px 10px; }

  /* ── Table ── */
  thead th,
  tbody td { padding: 5px 6px; font-size: 10px; }
  .table-wrap { margin: 0 -10px; }
  .card-body { padding: 8px; }

  /* ── Detail grid ── */
  .detail-label { flex-basis: 80px; font-size: 11px; }
  .detail-value { font-size: 11px; }
  .detail-row { padding: 6px 0; font-size: 11px; }

  /* ── Misc ── */
  .alert { font-size: 11px; padding: 8px 10px; margin-bottom: 10px; }
  .form-label { font-size: 11px; }
  .form-control { font-size: 12px; padding: 7px 10px; }
  .form-row-2,
  .form-row-3,
  .form-row-4 { grid-template-columns: 1fr; gap: 8px; }
  .btn { font-size: 12px; padding: 7px 14px; }
  .btn-sm { font-size: 10px; padding: 4px 8px; }
  .page-title { font-size: 17px; }
  .page-subtitle { font-size: 11px; }
  .home-title { font-size: 16px; }
  table td code { font-size: 10px !important; }
}

@media (max-width: 360px) {
  .app-header { height: 46px; padding: 0 4px 0 0; gap: 2px; }
  .sidebar-toggle { width: 36px; height: 46px; font-size: 14px; }
  .header-brand { gap: 6px; }
  .brand-logo { height: 26px; min-width: 26px; font-size: 9px; }
  .brand-logo.has-logo { height: 30px; max-width: 50px; }
  .brand-logo-img { max-width: 45px; }
  .brand-info h1 { font-size: 10px; }
  .brand-info p { display: none; }
  .header-right { gap: 2px; }
  .user-badge { padding: 1px 4px; }
  .user-avatar { width: 18px; height: 18px; font-size: 8px; }
  .dark-toggle { padding: 1px 4px; font-size: 9px; }
  .dark-toggle .toggle-icon { font-size: 10px; }
  .home-mobile-btn { padding: 1px 4px; }
  .home-mobile-btn .home-icon { font-size: 10px; }
  .btn-logout { padding: 2px 5px; font-size: 9px; }
  .main-content { padding: 8px !important; }
  .modules-grid { gap: 6px; }
  .module-card { padding: 10px 6px; }
  .module-icon { font-size: 22px; }
  .module-title { font-size: 10px; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .app-header, .page-header .btn, .filter-bar, .btn { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  body { background: white; }
  .card { box-shadow: none; }
}

/* ============================================================
   TAMBAHAN: BADGE ROLE & STATUS USER
   ============================================================ */
.badge-role-admin  { background: rgba(139,92,246,.15); color: #7c3aed; }
.badge-role-op     { background: rgba(59,130,246,.12); color: #1d4ed8; }
.badge-aktif       { background: rgba(34,197,94,.15);  color: #15803d; }
.badge-nonaktif    { background: rgba(239,68,68,.12);  color: #b91c1c; }

[data-theme="dark"] .badge-role-admin { background: rgba(139,92,246,.25); color: #a78bfa; }
[data-theme="dark"] .badge-role-op    { background: rgba(59,130,246,.22); color: #60a5fa; }
[data-theme="dark"] .badge-aktif      { background: rgba(34,197,94,.22);  color: #4ade80; }
[data-theme="dark"] .badge-nonaktif   { background: rgba(239,68,68,.22);  color: #f87171; }

/* ============================================================
   MODAL HEADER BERWARNA
   ============================================================ */
.modal-header {
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header .modal-title { font-size: 15px; font-weight: 700; }

/* Modal add — biru */
.modal-add .modal-header  { background: linear-gradient(135deg,var(--primary),var(--primary-dark)); }
.modal-add .modal-title,
.modal-add .modal-close { color: white; }
/* Modal edit — oranye */
.modal-edit .modal-header { background: linear-gradient(135deg,#f59e0b,#d97706); }
.modal-edit .modal-title,
.modal-edit .modal-close { color: white; }
/* Modal delete — merah */
.modal-delete .modal-header { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.modal-delete .modal-title,
.modal-delete .modal-close { color: white; }
/* Modal default — biru/ungu */
.modal:not(.modal-add):not(.modal-edit):not(.modal-delete) .modal-header {
  background: linear-gradient(135deg,var(--primary),var(--primary-dark));
}
.modal:not(.modal-add):not(.modal-edit):not(.modal-delete) .modal-title { color: white; }
.modal:not(.modal-add):not(.modal-edit):not(.modal-delete) .modal-close { color: rgba(255,255,255,.8); }

.form-section-title {
  font-size: 13px; font-weight: 700; color: var(--primary);
  padding: 6px 0; margin-bottom: 10px;
  border-bottom: 2px solid var(--border);
  letter-spacing: .3px;
}

.modal-detail .modal-header { background: linear-gradient(135deg,#6366f1,#4f46e5); }
.modal-detail .modal-title,
.modal-detail .modal-close { color: white; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
}
.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-label {
  flex: 0 0 160px;
  font-weight: 600;
  color: var(--text-light);
}
.detail-value {
  flex: 1;
  color: var(--text-dark);
}
.detail-row-full {
  grid-column: 1 / -1;
}
.detail-row-full .detail-label { flex-basis: 160px; }

/* ============================================================
   TOMBOL AKSI TABEL — lebih berwarna
   ============================================================ */
.btn-warning {
  background: linear-gradient(135deg,#f59e0b,#d97706);
  color: white; border: none;
  box-shadow: 0 2px 8px rgba(245,158,11,.3);
}
.btn-warning:hover {
  background: linear-gradient(135deg,#d97706,#b45309);
  box-shadow: 0 4px 12px rgba(245,158,11,.4);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg,#ef4444,#b91c1c);
  color: white; border: none;
  box-shadow: 0 2px 8px rgba(239,68,68,.3);
}
.btn-danger:hover {
  background: linear-gradient(135deg,#b91c1c,#991b1b);
  box-shadow: 0 4px 12px rgba(239,68,68,.4);
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(135deg,var(--primary),var(--primary-dark));
  color: white; border: none;
  box-shadow: 0 2px 8px rgba(91,95,207,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg,var(--primary-dark),#3a3da0);
  box-shadow: 0 4px 12px rgba(91,95,207,.4);
  transform: translateY(-1px);
}
.btn-success {
  background: linear-gradient(135deg,#22c55e,#16a34a);
  color: white; border: none;
  box-shadow: 0 2px 8px rgba(34,197,94,.3);
}
.btn-success:hover {
  background: linear-gradient(135deg,#16a34a,#15803d);
  box-shadow: 0 4px 12px rgba(34,197,94,.4);
  transform: translateY(-1px);
}

/* ============================================================
   DARK MODE — pastikan semua background beneran berubah
   ============================================================ */
[data-theme="dark"] body           { background: #12122a; }
[data-theme="dark"] .sidebar       { background: var(--sidebar-bg); }
[data-theme="dark"] .card          { background: var(--card-bg); }
[data-theme="dark"] .modal         { background: var(--modal-bg); }
[data-theme="dark"] table tbody td { color: var(--text-dark); }
[data-theme="dark"] .form-control  {
  background: var(--input-bg);
  color: var(--text-dark);
  border-color: var(--input-border);
}
[data-theme="dark"] .page-btn      { background: var(--pagebtn-bg); color: var(--text-dark); }
[data-theme="dark"] .card-header   { border-color: var(--border); }
[data-theme="dark"] .modal-footer  { border-color: var(--border); }
[data-theme="dark"] .modal-header  { border-color: var(--border); }
[data-theme="dark"] thead th       { background: linear-gradient(135deg, #4a4db5, #3a3da0); }

/* ============================================================
   SUMMARY BAR — Total Debet/Kredit di atas tabel
   ============================================================ */
.summary-bar {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  background: var(--card-hdr);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 18px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  flex: 1;
}
.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-light);
  font-weight: 600;
}
.summary-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dark);
}
.summary-value.debet  { color: #3b82f6; }
.summary-value.kredit { color: #ef4444; }
.summary-value.selisih-ok  { color: #22c55e; background: rgba(34,197,94,0.1); padding:4px 12px; border-radius:8px; }
.summary-value.selisih-err { color: #ef4444; background: rgba(239,68,68,0.1); padding:4px 12px; border-radius:8px; }

[data-theme="dark"] .summary-item { background: rgba(255,255,255,.03); }

/* ============================================================
   PAGINATION LENGKAP — First, Prev, numbers, Next, Last
   ============================================================ */
.pagination-wrap {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--border);
}
.pagination-info {
  font-size: 13px;
  color: var(--text-light);
}
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--pagebtn-bg);
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.page-btn:hover  { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); font-weight: 700; }
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-btn.page-ellipsis { background: transparent; border-color: transparent; cursor: default; }
.page-btn.page-ellipsis:hover { background: transparent; color: var(--text-dark); }
.page-btn-nav { min-width: 80px !important; padding: 0 12px !important; font-weight: 600; background: var(--pagebtn-bg) !important; }

/* ── COLLAPSE/EXPAND SUMMARY SECTION ── */
.btn-collapse {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.15);
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s;
  line-height: 1;
}
.btn-collapse:hover { background: rgba(255,255,255,.28); }

#collapsibleSection {
  overflow: hidden;
  max-height: 400px;
  transition: max-height .35s ease, opacity .25s ease;
  opacity: 1;
}
#collapsibleSection.section-collapsed {
  max-height: 0;
  opacity: 0;
}

/* ============================================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ============================================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
  /* Hide sidebar completely on mobile - not needed */
  .sidebar {
    display: none !important;
  }
  
  /* Sidebar overlay - also hide */
  .sidebar-overlay {
    display: none !important;
  }
  
  /* Main content takes full width on mobile */
  .main-content {
    margin-left: 0 !important;
    width: 100%;
    padding: 16px 12px;
  }
  
  /* Header adjustments - KEEP IN ONE LINE */
  .app-header {
    flex-wrap: nowrap; /* IMPORTANT: No wrapping! */
    padding: 8px 10px;
    gap: 8px;
    min-height: auto;
    width: 100%;
  }
  
  /* Hide sidebar toggle on mobile - no sidebar needed */
  .sidebar-toggle {
    display: none !important;
  }
  
  .header-brand {
    flex: 1;
    min-width: 0;
    max-width: 50%; /* Limit to give space for buttons */
    order: 0;
  }
  
  .brand-logo {
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    font-size: 13px;
  }
  
  .brand-logo.has-logo {
    height: 36px;
    max-width: 70px;
  }
  
  .brand-info {
    min-width: 0;
    flex: 1;
  }
  
  .brand-info h1 {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .brand-info p {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .header-right {
    display: flex;
    gap: 6px;
    width: auto; /* NOT 100% - stay inline */
    justify-content: flex-end;
    order: 1; /* Stay in same row */
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  
  .dark-toggle {
    padding: 6px 8px;
    font-size: 12px;
    min-width: auto;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
  }
  
  .home-mobile-btn {
    padding: 6px 8px;
    border-radius: 8px;
  }
  
  .home-mobile-btn .home-icon {
    font-size: 18px;
  }
  
  .dark-toggle .toggle-label {
    display: none; /* Hide text, keep icon only */
  }
  
  .dark-toggle .toggle-icon {
    font-size: 18px;
  }
  
  /* Hide user badge on very small mobile */
  .user-badge {
    display: none;
  }
  
  /* Logout: Keep red background */
  .btn-logout {
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    background: #e53e3e;
    border-color: #c53030;
    border-radius: 8px;
    min-width: auto;
  }
  
  /* Cards */
  .card {
    margin-bottom: 16px;
  }
  
  .card-header {
    padding: 14px 16px;
    font-size: 15px;
  }
  
  .card-body {
    padding: 16px;
  }
  
  /* Tables - horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px;
    font-size: 13px;
  }
  
  table th,
  table td {
    padding: 10px 8px;
  }
  
  /* Form layouts */
  .form-row {
    flex-direction: column;
  }
  
  .form-group {
    margin-bottom: 14px;
  }
  
  .form-label {
    font-size: 13px;
  }
  
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 10px 12px;
  }
  
  /* Buttons */
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-group .btn {
    width: 100%;
  }
  
  /* Action buttons */
  .action-btns {
    flex-direction: column;
    gap: 8px;
  }
  
  .action-btns .btn {
    width: 100%;
  }
  
  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 500px;
    margin: 20px;
  }
  
  /* Summary section */
  .summary-wrap {
    flex-direction: column;
    padding: 12px 16px;
  }
  
  .summary-item {
    width: 100%;
    min-width: auto;
  }
  
  /* Pagination */
  .pagination-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .pagination {
    justify-content: center;
  }
  
  .page-btn {
    min-width: 32px;
    height: 32px;
    font-size: 12px;
  }
  
  .page-btn-nav {
    min-width: 70px !important;
  }
  
  /* Stats grid */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  /* Alert */
  .alert {
    padding: 12px;
    font-size: 13px;
  }
  
  /* Dashboard home */
  .home-title {
    font-size: 16px;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
  }
  
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .module-card {
    padding: 20px 10px;
  }
  
  .module-icon {
    font-size: 32px;
  }
  
  .module-title {
    font-size: 13px;
  }
  
  .module-desc {
    font-size: 11px;
  }
}

/* Medium phones (401px-500px) - Samsung A51, etc */
@media (min-width: 401px) and (max-width: 500px) {
  .app-header {
    padding: 8px 12px;
  }
  
  .sidebar-toggle {
    width: 40px;
    height: 40px;
  }
  
  .brand-logo {
    height: 36px;
    min-width: 36px;
    max-width: 36px;
    font-size: 13px;
  }
  
  .brand-logo.has-logo {
    height: 36px;
    max-width: 70px;
  }
  
  .brand-info h1 {
    font-size: 13px;
  }
  
  .brand-info p {
    font-size: 9px;
  }
  
  .user-badge {
    padding: 4px 8px;
    gap: 5px;
  }
  
  .user-avatar {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }
  
  .user-name {
    font-size: 11px;
  }
  
  .user-role {
    font-size: 9px;
  }
  
  .btn-logout {
    padding: 6px 10px;
    font-size: 10px;
  }
  
  .dark-toggle {
    padding: 6px 8px;
  }
  
  .home-mobile-btn {
    padding: 6px 8px;
  }
  
  .dark-toggle .toggle-icon {
    font-size: 14px;
  }
  
  .home-mobile-btn .home-icon {
    font-size: 14px;
  }
  
  /* Ensure header stays full width */
  .app-header {
    padding: 10px;
  }
  
  /* Dashboard */
  .home-title {
    font-size: 14px;
    margin-bottom: 14px;
    letter-spacing: 0.3px;
  }
  
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .module-card {
    padding: 18px 8px;
  }
  
  .module-icon {
    font-size: 30px;
  }
  
  .module-title {
    font-size: 12px;
  }
  
  .module-desc {
    font-size: 10px;
  }
}

/* iPhone 14 Pro Max and similar (401px-450px) */
@media (min-width: 401px) and (max-width: 450px) {
  .app-header {
    padding: 10px;
    width: 100%;
  }
  
  .header-brand {
    max-width: 60%;
  }
  
  .brand-info h1 {
    font-size: 13px;
  }
  
  .brand-info p {
    font-size: 9px;
  }
  
  .header-right {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  
  .dark-toggle {
    padding: 6px 8px;
  }
  
  .home-mobile-btn {
    padding: 6px 8px;
  }
  
  .user-badge {
    padding: 4px 8px;
  }
  
  .btn-logout {
    padding: 6px 10px;
    font-size: 10px;
  }
}

/* Very small mobile - Icon only logout (<700px) */
@media (max-width: 700px) {
  .app-header {
    padding: 8px;
  }
  
  .header-brand {
    max-width: 55%;
  }
  
  .brand-info h1 {
    font-size: 12px;
  }
  
  .brand-info p {
    font-size: 8px;
  }
  
  /* Hide user badge completely on small screens */
  .user-badge {
    display: none !important;
  }
  
  /* Dark mode toggle - icon only */
  .dark-toggle {
    padding: 6px;
    min-width: 32px;
  }
  
  .dark-toggle .toggle-icon {
    font-size: 16px;
  }
  
  /* Home mobile button - icon only */
  .home-mobile-btn {
    padding: 6px;
    min-width: 32px;
  }
  
  .home-mobile-btn .home-icon {
    font-size: 16px;
  }
  
  /* Logout button - ICON ONLY (hide text, keep icon) */
  .btn-logout {
    padding: 6px 8px;
    min-width: 36px;
    font-size: 16px; /* Icon size */
    overflow: hidden;
    text-indent: -9999px; /* Hide text */
    position: relative;
  }
  
  .btn-logout::after {
    content: '🔒';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-indent: 0;
    font-size: 16px;
  }
  
  /* === COMPREHENSIVE PAGE OPTIMIZATIONS === */
  
  /* Main content */
  .main-content {
    padding: 10px 8px;
  }
  
  /* Cards */
  .card {
    margin-bottom: 14px;
    border-radius: 10px;
  }
  
  .card-header {
    padding: 10px 12px;
    font-size: 13px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  /* Tables - Responsive with horizontal scroll */
  .table-wrapper,
  .master-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  
  table {
    min-width: 600px;
    font-size: 11px;
  }
  
  table th {
    padding: 8px 6px;
    font-size: 10px;
    white-space: nowrap;
  }
  
  table td {
    padding: 8px 6px;
    font-size: 11px;
  }
  
  /* Sticky first column */
  table th:first-child,
  table td:first-child {
    position: sticky;
    left: 0;
    background: var(--card-bg);
    z-index: 2;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
  }
  
  table th:first-child {
    z-index: 3;
    background: var(--table-header-bg);
  }
  
  /* Master data tables */
  .master-table table {
    min-width: 700px;
  }
  
  /* Compact buttons in tables */
  .btn-sm {
    padding: 4px 6px;
    font-size: 12px;
    min-width: 28px;
  }
  
  /* Forms */
  .form-group {
    margin-bottom: 12px;
  }
  
  .form-label {
    font-size: 11px;
    margin-bottom: 4px;
  }
  
  .form-control,
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 14px;
    padding: 8px 10px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  /* Buttons */
  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .btn-primary,
  .btn-success,
  .btn-danger,
  .btn-warning {
    min-height: 36px;
  }
  
  /* Tabs */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -8px 16px -8px;
    padding: 0 8px;
  }
  
  .tab-btn {
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
  }
  
  .tab-content {
    padding: 12px 8px;
  }
  
  .tab-header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }
  
  .tab-header button {
    width: 100%;
  }
  
  /* Modals */
  .modal-content {
    width: 95%;
    max-width: 100%;
    margin: 10px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-header {
    padding: 12px;
  }
  
  .modal-header h3 {
    font-size: 15px;
  }
  
  .modal-body {
    padding: 12px;
  }
  
  .modal-footer {
    padding: 12px;
    flex-direction: column;
    gap: 8px;
  }
  
  .modal-footer .btn {
    width: 100%;
  }
  
  /* Badges */
  .badge,
  .code-badge {
    font-size: 10px;
    padding: 3px 8px;
  }
  
  /* Pagination */
  .pagination-wrap {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }
  
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .page-btn {
    min-width: 30px;
    height: 30px;
    font-size: 11px;
    padding: 0 6px;
  }
  
  /* Alerts */
  .alert {
    padding: 10px;
    font-size: 12px;
    margin-bottom: 12px;
  }
  
  /* Stats */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-row {
    font-size: 11px;
  }
  
  /* Dashboard */
  .home-title {
    font-size: 14px;
    margin-bottom: 12px;
  }
  
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .module-card {
    padding: 16px 8px;
  }
  
  .module-icon {
    font-size: 28px;
  }
  
  .module-title {
    font-size: 11px;
  }
  
  .module-desc {
    font-size: 9px;
  }
  
  /* Jurnal Entry */
  .entry-container {
    padding: 8px;
  }
  
  .entry-header {
    padding: 12px;
    margin: -8px -8px 12px -8px;
  }
  
  .entry-header h1 {
    font-size: 16px;
  }
  
  .entries-table {
    margin: 0 -12px;
    padding: 0 12px;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .summary-value {
    font-size: 18px;
  }
  
  /* Reports */
  .report-header {
    padding: 12px;
  }
  
  .report-header h2 {
    font-size: 16px;
  }
  
  /* Empty states */
  .empty-state {
    padding: 30px 10px;
  }
  
  .empty-icon {
    font-size: 40px;
  }
  
  /* Action buttons */
  .action-btns,
  .btn-group {
    flex-direction: column;
    gap: 6px;
  }
  
  .action-btns .btn,
  .btn-group .btn {
    width: 100%;
  }
  
  /* Inline buttons stay horizontal */
  td .btn-group {
    flex-direction: row;
    gap: 4px;
  }
  
  td .btn-group .btn {
    width: auto;
  }
  
  /* Filter/Search rows */
  .filter-row,
  .search-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .filter-row input,
  .filter-row select,
  .search-row input,
  .search-row select {
    width: 100%;
  }
  
  /* Summary wrap */
  .summary-wrap {
    flex-direction: column;
    padding: 10px;
  }
  
  .summary-item {
    width: 100%;
  }
  
  /* Typography */
  h1 { font-size: 18px; }
  h2 { font-size: 16px; }
  h3 { font-size: 14px; }
  h4 { font-size: 13px; }
}

/* Small phones (400px and below) - Samsung A21s */
@media (max-width: 400px) {
  .main-content {
    padding: 12px 8px;
  }
  
  .app-header {
    padding: 10px 12px;
  }
  
  .brand-info h1 {
    font-size: 14px;
  }
  
  .brand-info p {
    font-size: 10px;
  }
  
  .card-header {
    padding: 12px;
    font-size: 14px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  table {
    font-size: 12px;
  }
  
  table th,
  table td {
    padding: 8px 6px;
  }
  
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
    padding: 8px 10px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .page-btn {
    min-width: 28px;
    height: 28px;
    font-size: 11px;
    padding: 0 6px;
  }
  
  .page-btn-nav {
    min-width: 60px !important;
    font-size: 11px;
  }
  
  .sidebar {
    width: 260px;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .app-header {
    padding: 8px 12px;
  }
  
  .header-brand {
    flex-direction: row;
    gap: 8px;
  }
  
  .brand-info h1 {
    font-size: 14px;
  }
  
  .brand-info p {
    font-size: 10px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .btn,
  .page-btn,
  a.nav-link,
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .btn:hover,
  .page-btn:hover,
  table tr:hover {
    /* Keep original state */
  }
}

/* Print styles */
@media print {
  .sidebar,
  .app-header,
  .btn,
  .action-btns,
  .pagination-wrap {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .card {
    break-inside: avoid;
  }
}
