:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --secondary: #0f172a;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* LAYOUT */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--secondary); position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100; transition: transform .3s; display: flex; flex-direction: column; }
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--header-h); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.page-content { padding: 24px; flex: 1; }

/* SIDEBAR */
.sidebar-logo { padding: 20px 20px 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo h2 { color: #fff; font-size: 18px; font-weight: 700; }
.sidebar-logo p { color: rgba(255,255,255,.4); font-size: 11px; margin-top: 2px; }
.sidebar-user { padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; }
.sidebar-user-info p { color: #fff; font-size: 13px; font-weight: 600; }
.sidebar-user-info span { color: rgba(255,255,255,.45); font-size: 11px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; color: rgba(255,255,255,.25); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(255,255,255,.6); text-decoration: none; transition: all .2s; border-left: 3px solid transparent; font-size: 13.5px; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.06); border-left-color: var(--primary-light); }
.nav-item.active { background: rgba(59,130,246,.15); }
.nav-item i { width: 18px; font-size: 15px; }
.sidebar-bottom { padding: 12px 0; border-top: 1px solid rgba(255,255,255,.08); }

/* CARDS */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; align-items: flex-start; gap: 14px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.blue { background: #eff6ff; color: var(--primary); }
.stat-icon.green { background: #f0fdf4; color: var(--success); }
.stat-icon.amber { background: #fffbeb; color: var(--warning); }
.stat-icon.red { background: #fef2f2; color: var(--danger); }
.stat-icon.cyan { background: #ecfeff; color: var(--info); }
.stat-info p { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.stat-info h3 { font-size: 22px; font-weight: 800; color: var(--text); }
.stat-info small { font-size: 11px; color: var(--text-muted); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: 8px; background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.btn-icon:hover { background: var(--border); }
.btn-block { width: 100%; justify-content: center; }

/* FORMS */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control { width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff; transition: all .2s; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-control.is-invalid { border-color: var(--danger); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; cursor: pointer; transition: all .2s; background: var(--bg); }
.upload-area:hover { border-color: var(--primary); background: #eff6ff; }
.upload-area i { font-size: 28px; color: var(--text-muted); margin-bottom: 8px; display: block; }
.upload-area p { font-size: 13px; color: var(--text-muted); }
.upload-area input[type=file] { display: none; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { background: var(--bg); padding: 11px 14px; font-weight: 700; text-align: left; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-secondary { background: var(--bg); color: var(--text-muted); }
.badge-primary { background: #eff6ff; color: var(--primary); }

/* ALERTS */
.alert { padding: 13px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #ecfeff; color: #155e75; border: 1px solid #a5f3fc; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: scale(.95); transition: transform .2s; }
.modal-overlay.show .modal { transform: scale(1); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* RECEIPT */
.receipt { background: #fff; max-width: 320px; margin: 0 auto; padding: 20px; font-family: 'Courier New', monospace; }
.receipt-header { text-align: center; border-bottom: 2px dashed #333; padding-bottom: 12px; margin-bottom: 12px; }
.receipt-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.receipt-total { border-top: 2px dashed #333; border-bottom: 2px dashed #333; padding: 8px 0; margin: 10px 0; font-weight: 700; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 18px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; text-decoration: none; }
.tab.active, .tab:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

/* PROGRESS BAR */
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; background: var(--primary); transition: width .4s; }
.progress-bar.green { background: var(--success); }
.progress-bar.red { background: var(--danger); }
.progress-bar.amber { background: var(--warning); }

/* LOAN CALCULATOR */
.calc-result { background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; border-radius: var(--radius); padding: 20px; }
.calc-result h3 { font-size: 28px; font-weight: 800; }
.calc-result p { opacity: .8; font-size: 12px; }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.calc-item { background: rgba(255,255,255,.12); border-radius: 8px; padding: 12px; }
.calc-item p { font-size: 11px; opacity: .7; }
.calc-item h4 { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* COLLECTOR DAILY LIST */
.loan-list-item { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; transition: all .2s; }
.loan-list-item:hover { box-shadow: var(--shadow); }
.loan-list-item.paid { border-left: 4px solid var(--success); }
.loan-list-item.pending { border-left: 4px solid var(--warning); }
.loan-list-item.overdue { border-left: 4px solid var(--danger); }

/* TOPBAR */
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 6px; }

/* MOBILE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .calc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* OVERLAY for mobile sidebar */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
.sidebar-overlay.show { display: block; }

/* PRINT */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; }
}

/* SHIMMER LOADING */
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }

/* SEARCH BAR */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 15px; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
