:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #ebf5ff;
  --secondary: #6b7280;
  --success: #057a55;
  --danger: #e02424;
  --warning: #c27803;
  --info: #0694a2;
  --bg: #f3f4f6;
  --sidebar-bg: #111827;
  --sidebar-text: #d1d5db;
  --sidebar-active: #1a56db;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --sidebar-width: 240px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card-bg: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
}

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

/* SIDEBAR */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: white;
}
.sidebar-logo .logo-text { color: white; font-size: 16px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub { color: #6b7280; font-size: 11px; }

.sidebar-section { padding: 8px 0; }
.sidebar-section-title { padding: 6px 16px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: #4b5563; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--sidebar-text); text-decoration: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s ease; border-left: 3px solid transparent;
}
.sidebar-item:hover { background: rgba(255,255,255,0.06); color: white; }
.sidebar-item.active { background: rgba(26,86,219,0.15); color: #60a5fa; border-left-color: var(--primary); }
.sidebar-item .si-icon { width: 18px; text-align: center; font-size: 15px; }
.sidebar-item .si-badge {
  margin-left: auto; background: var(--primary); color: white;
  font-size: 10px; padding: 2px 6px; border-radius: 10px;
}

/* MAIN */
.main-wrap { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon { width: 36px; height: 36px; border: 1px solid var(--border); background: var(--card-bg);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: 16px; transition: all 0.15s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

.user-avatar {
  width: 34px; height: 34px; background: var(--primary); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; cursor: pointer;
}

.page-content { padding: 24px; flex: 1; }

/* CARDS */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }

/* STAT CARDS */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.green { background: #d1fae5; color: #057a55; }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.orange { background: #fef3c7; color: #b45309; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #046c4e; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c81e1e; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control { width: 100%; padding: 9px 12px; background: var(--card-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s; outline: none; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  background: var(--bg); border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }
.td-right { text-align: right; font-family: monospace; }
.td-center { text-align: center; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--bg); color: var(--text-muted); }

/* VOUCHER ENTRY TABLE */
.entry-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.entry-table th { background: #1a56db; color: white; padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.entry-table td { padding: 4px 6px; border: 1px solid var(--border); }
.entry-table input, .entry-table select { width: 100%; padding: 5px 8px; border: none; background: transparent; color: var(--text); font-size: 13px; outline: none; }
.entry-table input:focus, .entry-table select:focus { background: var(--primary-light); }
.entry-table tr:nth-child(even) { background: rgba(0,0,0,0.02); }
.entry-table .del-row { cursor: pointer; color: var(--danger); padding: 0 8px; font-size: 16px; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-danger { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--primary); }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-muted); background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

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

/* MISC */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* PAGINATION */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--card-bg); color: var(--text); cursor: pointer; font-size: 12px; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); }

/* CHART */
.chart-container { position: relative; }

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

/* DROPDOWN */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; top: 100%; right: 0; min-width: 180px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); z-index: 50; display: none; padding: 4px 0; }
.dropdown-menu.show { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  font-size: 13px; color: var(--text); text-decoration: none; cursor: pointer; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* RESPONSIVE */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .page-content { padding: 12px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr !important; }
}

/* PRINT */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-wrap { margin-left: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}

/* LOADING */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* TALLY-LIKE KEYBOARD HINTS */
.kb-hint { font-size: 10px; color: var(--text-muted); background: var(--bg);
  border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; font-family: monospace; }

/* AMOUNT DISPLAY */
.amount-dr { color: var(--danger); font-weight: 600; font-family: monospace; }
.amount-cr { color: var(--success); font-weight: 600; font-family: monospace; }
.amount { font-family: monospace; }

/* SIDEBAR TOGGLE */
#sidebar-toggle { display: none; }
@media (max-width: 768px) { #sidebar-toggle { display: flex; } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--secondary); }
