:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --yellow: #d97706;
  --yellow-bg: #fffbeb;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
body { background: var(--bg); color: var(--text); line-height: 1.5; }
.hidden { display: none !important; }
.text-muted { color: var(--muted); font-size: 0.9rem; }
.text-primary { color: var(--primary); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--yellow); }
.text-info { color: #0284c7; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Login */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--surface); width: 100%; max-width: 400px; padding: 28px; border-radius: var(--radius); box-shadow: 0 10px 25px rgba(0,0,0,0.06); }
.login-header { text-align: center; margin-bottom: 20px; }
.brand-badge { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; background: var(--primary); color: #fff; font-weight: 700; border-radius: 8px; margin-bottom: 8px; flex-shrink: 0; }
.login-footer { margin-top: 16px; text-align: center; color: var(--muted); }

/* Layout & Sidebar */
.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: #0f172a; color: #f8fafc; display: flex; flex-direction: column; padding: 16px; position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transition: transform 0.25s ease; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid #1e293b; }
.sidebar-brand .brand-badge { margin-bottom: 0; }
.sidebar-brand small { display: block; color: #94a3b8; font-size: 0.78rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; flex: 1; }
.nav-item { display: block; text-decoration: none; color: #cbd5e1; padding: 11px 12px; border-radius: 8px; font-size: 0.95rem; transition: background 0.15s; }
.nav-item:hover, .nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.main-content { flex: 1; margin-left: 250px; padding: 20px; max-width: 1200px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; background: var(--surface); padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--border); gap: 12px; }
.topbar h2 { flex: 1; font-size: 1.25rem; min-width: 0; }
.detail-topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

/* Cards & Grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card-header-flex { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.stats-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.status-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.finance-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; transition: transform 0.15s; }
.status-grid .stat-card { cursor: pointer; }
.status-grid .stat-card:hover { transform: translateY(-2px); }
.stat-label { display: block; font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.25rem; margin-top: 4px; display: block; }
.card-red { border-left: 4px solid var(--red); background: var(--red-bg); }
.card-yellow { border-left: 4px solid var(--yellow); background: var(--yellow-bg); }
.card-green { border-left: 4px solid var(--green); background: var(--green-bg); }
.card-gray { border-left: 4px solid var(--muted); }

/* Transaksi List */
.transaksi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.trx-item { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; border-left: 5px solid var(--muted); transition: box-shadow 0.15s; }
.trx-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.trx-item.status-PENDING { border-left-color: var(--red); }
.trx-item.status-PROSES { border-left-color: var(--yellow); }
.trx-item.status-LUNAS { border-left-color: var(--green); }
.trx-item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.badge { padding: 3px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge-PENDING { background: var(--red-bg); color: var(--red); }
.badge-PROSES { background: var(--yellow-bg); color: var(--yellow); }
.badge-LUNAS { background: var(--green-bg); color: var(--green); }
.badge-DITOLAK, .badge-neutral { background: #e2e8f0; color: #334155; }

/* Forms & Inputs */
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.full-col { grid-column: 1 / -1; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.95rem; background: #fff; }
.input-readonly { background: #f8fafc; font-weight: 600; color: var(--primary); }
.toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar-row input { flex: 2; min-width: 200px; }
.toolbar-row select { flex: 1; min-width: 160px; }
.summary-banner { background: #eff6ff; border: 1px solid #bfdbfe; padding: 12px; border-radius: 8px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.upload-box { border: 1px dashed #cbd5e1; padding: 12px; border-radius: 8px; background: #f8fafc; display: flex; flex-direction: column; gap: 8px; }
.doc-preview { max-width: 100%; max-height: 140px; border-radius: 6px; object-fit: cover; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* Buttons & Tabs */
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; padding: 9px 16px; border: none; border-radius: 7px; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-icon { background: transparent; border: none; font-size: 1.3rem; cursor: pointer; color: inherit; }
.action-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.alert-box { padding: 10px; border-radius: 6px; background: var(--red-bg); color: var(--red); font-size: 0.85rem; margin-bottom: 12px; }
.tabs-bar { display: flex; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.tab-btn { padding: 7px 14px; border: 1px solid var(--border); background: #f8fafc; border-radius: 6px; cursor: pointer; font-weight: 600; }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tables & Lists */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { background: #f8fafc; font-weight: 600; }
.simple-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.simple-list li { padding: 8px 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }
.tempo-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { padding: 5px 10px; border-radius: 6px; font-size: 0.8rem; background: #f1f5f9; border: 1px solid var(--border); }
.chip.paid { background: var(--green-bg); border-color: #86efac; color: var(--green); font-weight: 600; }
.dokumen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 10px; }
.dok-card img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); margin-top: 4px; }

/* Profil & Signature */
.profile-avatar-box { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sig-canvas { border: 2px dashed #94a3b8; border-radius: 8px; background: #fff; touch-action: none; max-width: 100%; display: block; margin-top: 8px; }
.sig-preview-wrapper { margin-top: 14px; }
.sig-saved-img { max-height: 80px; border: 1px solid var(--border); padding: 4px; border-radius: 6px; background: #fff; margin-top: 4px; }
.avatar-img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #e2e8f0; flex-shrink: 0; }
.progress-bar-bg { width: 100%; height: 12px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress-bar-fill { height: 100%; background: var(--green); width: 0%; transition: width 0.3s ease; }

/* Modal Struk */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.65); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal-box { background: #fff; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; border-radius: var(--radius); padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }
.struk-paper { border: 1px solid #cbd5e1; padding: 18px; font-family: 'Courier New', monospace; font-size: 0.86rem; background: #fff; }
.struk-header { text-align: center; border-bottom: 1px dashed #64748b; padding-bottom: 10px; margin-bottom: 10px; }
.struk-row { display: flex; justify-content: space-between; margin: 4px 0; gap: 8px; }
.struk-divider { border-top: 1px dashed #64748b; margin: 10px 0; }
.struk-ttd { margin-top: 18px; margin-left: auto; width: max-content; min-width: 150px; text-align: center; }
.struk-ttd img { max-height: 60px; display: block; margin: 4px auto; }

.kp-notif-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 999; animation: kpFadeIn 0.15s ease; }
.kp-notif-box { background: #fff; width: 100%; max-width: 360px; border-radius: 14px; padding: 24px 20px; text-align: center; box-shadow: 0 20px 35px rgba(0, 0, 0, 0.18); }
.kp-notif-icon { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; margin-bottom: 12px; }
.kp-notif-icon.success { background: var(--green-bg); color: var(--green); }
.kp-notif-icon.error { background: var(--red-bg); color: var(--red); }
.kp-notif-msg { font-size: 0.95rem; color: var(--text); margin-bottom: 18px; line-height: 1.45; }
.kp-notif-actions { display: flex; gap: 8px; justify-content: center; }
@keyframes kpFadeIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* Responsive Mobile */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  #btn-open-sidebar { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; flex-shrink: 0; }
  #btn-close-sidebar { margin-left: auto; }
  .topbar { padding: 10px 14px; margin-bottom: 14px; }
  .topbar h2 { font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-meta { display: none; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 12px; }
}
@media print {
  body * { visibility: hidden; }
  #struk-printable-area, #struk-printable-area * { visibility: visible; }
  #struk-printable-area { position: fixed; left: 0; top: 0; width: 100%; border: none; }
}