:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
  --navbar-h: 64px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary-light: #1e3a5f;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  display: flex; flex-direction: column; transition: transform .3s;
}
.sidebar-brand {
  padding: 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .logo {
  width: 40px; height: 40px; background: var(--primary); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px;
}
.sidebar-brand h1 { font-size: 16px; font-weight: 700; }
.sidebar-brand span { font-size: 11px; color: var(--text-muted); display: block; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-radius: 8px; color: var(--text-muted); cursor: pointer;
  transition: all .2s; margin-bottom: 2px; font-size: 14px;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item i { width: 20px; text-align: center; }
.nav-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 14px 14px 6px; font-weight: 600; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); text-align: center; }

/* Main */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.navbar {
  height: var(--navbar-h); background: var(--surface); 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;
}
.navbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; color: var(--text); cursor: pointer; }
.navbar-search {
  display: flex; align-items: center; background: var(--bg); border-radius: 8px;
  padding: 8px 14px; gap: 8px; width: 280px;
}
.navbar-search input { border: none; background: none; outline: none; width: 100%; color: var(--text); font-size: 14px; }
.navbar-right { display: flex; align-items: center; gap: 8px; }
.nav-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
.nav-btn {
  width: 40px; height: 40px; border-radius: 8px; border: none; background: var(--bg);
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 16px; position: relative; transition: all .2s;
}
.nav-btn:hover { background: var(--primary-light); color: var(--primary); }
.badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}
.profile { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.profile:hover { background: var(--bg); }
.profile-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
.profile-info span { display: block; font-size: 13px; font-weight: 600; }
.profile-info small { font-size: 11px; color: var(--text-muted); }

.content { padding: 24px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: 12px; padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat-card .icon {
  width: 44px; height: 44px; border-radius: 10px; display: flex;
  align-items: center; justify-content: center; font-size: 18px; margin-bottom: 12px;
}
.stat-card .icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card .icon.green { background: #dcfce7; color: #16a34a; }
.stat-card .icon.red { background: #fee2e2; color: #dc2626; }
.stat-card .icon.purple { background: #ede9fe; color: #7c3aed; }
[data-theme="dark"] .stat-card .icon.blue { background: #1e3a5f; }
[data-theme="dark"] .stat-card .icon.green { background: #14532d; }
[data-theme="dark"] .stat-card .icon.red { background: #7f1d1d; }
[data-theme="dark"] .stat-card .icon.purple { background: #4c1d95; }
.stat-card .label { font-size: 13px; color: var(--text-muted); }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card {
  background: var(--surface); border-radius: 12px; padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 12px 14px; background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg); }
.table-pagination {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pagination-info { color: var(--text-muted); font-size: 13px; }
.pagination-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pagination-controls .form-control { width: auto; min-width: 84px; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #e0f2fe; color: #0891b2; }
.badge-primary { background: #dbeafe; color: #2563eb; }
[data-theme="dark"] .badge-success { background: #14532d; }
[data-theme="dark"] .badge-warning { background: #78350f; }
[data-theme="dark"] .badge-danger { background: #7f1d1d; }
[data-theme="dark"] .badge-info { background: #164e63; }
[data-theme="dark"] .badge-primary { background: #1e3a5f; }

/* Buttons */
.btn {
  padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 14px;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar .form-control { width: auto; min-width: 160px; }

/* Activity */
.activity-list { list-style: none; }
.activity-list li {
  display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.activity-list li:last-child { border-bottom: none; }
.activity-icon {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px;
}
.activity-text strong { font-weight: 600; }
.activity-text small { display: block; color: var(--text-muted); margin-top: 2px; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ''; position: absolute; left: -24px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--border); border: 2px solid var(--surface);
}
.timeline-item.done::before { background: var(--success); }
.timeline-item.active::before { background: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.2); }
.timeline-item h4 { font-size: 14px; font-weight: 600; }
.timeline-item p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Calendar */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 13px; }
.cal-header { font-weight: 600; color: var(--text-muted); padding: 8px 4px; }
.cal-day { padding: 10px 4px; border-radius: 8px; cursor: default; }
.cal-day.other { color: var(--text-muted); opacity: .4; }
.cal-day.today { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day.event { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* Warga */
.td-top { vertical-align: top; }
.table-action-stack { display: flex; gap: 6px; align-items: center; }

/* Agenda */
.agenda-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.agenda-card-next { border-color: var(--success); background: rgba(22,163,74,.08); }
.agenda-card-past { background: rgba(148,163,184,.12); border-color: var(--border); opacity: .85; }
.agenda-card h4 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.agenda-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; color: var(--text-muted); }
.agenda-meta i { width: 16px; color: var(--primary); }
.agenda-actions { margin-top: 12px; display: flex; gap: 8px; }

/* Summary boxes */
.summary-box { background: var(--bg); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.summary-box .row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }
.summary-box .total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }

/* Notification dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); width: 320px; z-index: 60;
}
.dropdown-menu.show { display: block; }
.dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.notif-item:hover { background: var(--bg); }
.notif-item small { color: var(--text-muted); display: block; margin-top: 2px; }

/* Overlay sidebar mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
.sidebar-overlay.show { display: block; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 20px;
  box-shadow: var(--shadow-lg); z-index: 300; display: none; font-size: 14px;
  align-items: center; gap: 10px;
}
.toast.show { display: flex; }

/* Chart container */
.chart-container { position: relative; height: 280px; }

/* Responsive */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .navbar-search { display: none; }
  .nav-date { display: none; }
  .profile-info { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
