:root {
  --bg: #f7f7f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #7c5cc4;
  --primary-text: #ffffff;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --sidebar-bg: #ffffff;
  --sidebar-text: #374151;
  --sidebar-active: #f3effa;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
[data-theme="dark"] {
  --bg: #0f1220;
  --card: #171a2b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #2a2e45;
  --primary: #6366f1;
  --primary-text: #ffffff;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --sidebar-bg: #12142280;
  --sidebar-text: #d1d5db;
  --sidebar-active: #262b47;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; width: 320px; }
.login-card h1 { margin: 0 0 20px; font-size: 1.4rem; text-align: center; }
.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font-size: 0.9rem; width: 100%; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: none; background: var(--primary); color: var(--primary-text); font-weight: 600; cursor: pointer; font-size: 0.9rem; text-decoration: none; }
.btn.secondary { background: var(--border); color: var(--text); }
.error { color: var(--danger); font-size: 0.85rem; }
.success { color: var(--success); font-size: 0.85rem; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border); padding: 8px 0 16px; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 60; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 2px 0 12px rgba(0,0,0,0.15); }
.sidebar.open { transform: translateX(0); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: transparent; z-index: 55; }
.sidebar-overlay.open { display: block; }
.sidebar.open ~ .sidebar-overlay ~ .main { margin-left: 260px; }
@media (max-width: 768px) {
  .sidebar.open ~ .sidebar-overlay ~ .main { margin-left: 0; }
  .sidebar-overlay { background: rgba(0,0,0,0.35); }
}
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px 16px; }
.sidebar .brand { font-weight: 700; font-size: 1.1rem; }
.sidebar-close { background: none; border: none; color: var(--sidebar-text); font-size: 1.1rem; cursor: pointer; }
.hamburger { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.right-panel { position: fixed; top: 0; right: 0; height: 100vh; width: 250px; background: var(--card); box-shadow: 0 0 35px rgba(154,161,171,0.25); padding: 20px 0; z-index: 999; transform: translateX(100%); transition: transform 0.25s ease; overflow-y: auto; }
.right-panel.open { transform: translateX(0); }
.right-panel a { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 20px; color: #7c5cc4; font-size: 0.875rem; text-decoration: none; border-bottom: 1px solid var(--border); }
.right-panel a:hover, .right-panel a.active { background: var(--sidebar-active); }
.right-panel-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 998; display: none; }
.right-panel-overlay.open { display: block; }
.sidebar a { display: block; padding: 9px 18px; color: var(--sidebar-text); text-decoration: none; font-size: 0.88rem; }
.sidebar a:hover, .sidebar a.active { background: var(--sidebar-active); }
.sidebar .nav-icon { display: inline-block; width: 20px; }
.nav-parent { display: flex; align-items: center; width: 100%; padding: 9px 18px; background: none; border: none; color: var(--sidebar-text); font-size: 0.88rem; font-family: inherit; text-align: left; cursor: pointer; }
.nav-parent:hover { background: var(--sidebar-active); }
.nav-parent .chevron { margin-left: auto; transition: transform 0.15s; font-size: 0.75rem; }
.nav-group.open .nav-parent .chevron { transform: rotate(90deg); }
.nav-children { display: none; background: rgba(0,0,0,0.08); }
[data-theme="dark"] .nav-children { background: rgba(0,0,0,0.2); }
.nav-group.open .nav-children { display: block; }
.nav-children a { padding-left: 46px; font-size: 0.85rem; }
.quick-add-menu { display: none; }
.quick-add-menu a { padding: 8px 14px !important; color: var(--text) !important; }
.quick-add-menu a:hover { background: var(--sidebar-active); }
.nav-group.open .quick-add-menu { display: block; }
.main { flex: 1; min-width: 0; transition: margin-left 0.2s ease; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar .actions { display: flex; align-items: center; gap: 12px; }
.theme-toggle { cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 0.85rem; }
.content { padding: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }

.grid-6, .grid-4, .grid-3, .grid-2 { display: grid; gap: 14px; margin-bottom: 20px; grid-template-columns: repeat(1, 1fr); }
@media (min-width: 576px) {
  .grid-6, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(6, 1fr); }
}
.stat, .card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.stat .value { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }

.stat2 { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.stat2-row { display: flex; align-items: center; gap: 10px; }
.stat2-icon { font-size: 1.4rem; line-height: 1; }
.stat2-value { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.stat2-label { font-size: 0.85rem; font-weight: 700; margin-top: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.active { background: #16d39a; color: #fff; }
.badge.inactive { background: #ff7588; color: #fff; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }

.list-toolbar-top { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.btn-teal { background: #17b8a6; color: #fff; }
.btn-purple-solid { background: #7c5cc4; color: #fff; }
.list-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.list-controls .per-page { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.list-controls .per-page select { width: auto; padding: 4px 8px; }
.list-controls .search-box input { width: 220px; }
.export-icons { display: flex; gap: 6px; }
.export-icons button { width: 34px; height: 34px; border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 0.85rem; }
.export-pdf { background: #e83e8c; }
.export-excel { background: #ffc107; }
.export-print { background: #17a2b8; }
.export-delete { background: #dc3545; }
.export-cols { background: #7c5cc4; position: relative; }
.thumb-img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; background: var(--border); vertical-align: middle; }

.action-dropdown { position: relative; display: inline-block; }
.action-dropdown .action-menu { display: none; position: absolute; right: 0; top: 110%; background: var(--card); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); min-width: 120px; z-index: 50; }
.action-dropdown.open .action-menu { display: block; }
.action-dropdown .action-menu a, .action-dropdown .action-menu button { display: block; width: 100%; text-align: left; padding: 8px 14px; font-size: 0.85rem; color: var(--text); text-decoration: none; background: none; border: none; cursor: pointer; }
.action-dropdown .action-menu a:hover, .action-dropdown .action-menu button:hover { background: var(--sidebar-active); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--card); border-radius: 8px; width: 440px; max-width: 92vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); text-align: right; }
