:root {
  --primary: #16a085;
  --primary-dark: #0e6655;
  --primary-light: #1abc9c;
  --secondary: #2c3e50;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --info: #2980b9;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --border: #e8ecef;
  --sidebar-bg: #ffffff;
  --sidebar-width: 260px;
  --navbar-height: 64px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg: #0f1923;
  --card-bg: #1a2332;
  --text: #e8edf2;
  --text-muted: #8899aa;
  --border: #2a3a4a;
  --sidebar-bg: #141e2b;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* ===== ROL BO'YICHA RANGLAR ===== */
[data-role="super_admin"] {
  --primary: #8e44ad;
  --primary-dark: #6c3483;
  --primary-light: #a569bd;
}
[data-role="admin"] {
  --primary: #2980b9;
  --primary-dark: #1a5276;
  --primary-light: #5dade2;
}
[data-role="yetakchi"] {
  --primary: #e67e22;
  --primary-dark: #ca6f1e;
  --primary-light: #f0a500;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
  font-size: 14px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
  box-shadow: 2px 0 12px rgba(0,0,0,0.05);
}

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-brand .logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 18px;
}

.sidebar-brand .brand-name {
  font-weight: 700; font-size: 18px;
  color: var(--primary);
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 11px; color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.nav-section { padding: 8px 16px 4px; }
.nav-section span {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted);
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}

.nav-item:hover {
  background: rgba(22, 160, 133, 0.08);
  color: var(--primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(22,160,133,0.15), rgba(22,160,133,0.08));
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--primary);
  border-radius: 0 4px 4px 0; margin-left: -8px;
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; }

.nav-badge {
  margin-left: auto;
  background: var(--danger); color: white;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}

.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Main content */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--navbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 99;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: all 0.2s; text-decoration: none;
}

.btn-icon:hover { background: var(--bg); color: var(--primary); }

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

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px; margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: white;
  flex-shrink: 0;
}

.stat-icon.green { background: linear-gradient(135deg, #27ae60, #1e8449); }
.stat-icon.blue  { background: linear-gradient(135deg, #2980b9, #1a5276); }
.stat-icon.orange{ background: linear-gradient(135deg, #f39c12, #d68910); }
.stat-icon.red   { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.stat-icon.teal  { background: linear-gradient(135deg, #16a085, #0e6655); }
.stat-icon.purple{ background: linear-gradient(135deg, #8e44ad, #6c3483); }

.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 12px; color: var(--success); margin-top: 2px; }

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}

.card-title i { color: var(--primary); }
.card-body { padding: 24px; }

/* Table */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-align: left; border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:hover { background: rgba(22,160,133,0.03); }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-success { background: rgba(39,174,96,0.12); color: #1e8449; }
.badge-warning { background: rgba(243,156,18,0.12); color: #d68910; }
.badge-danger  { background: rgba(231,76,60,0.12);  color: #c0392b; }
.badge-secondary{background: rgba(127,140,141,0.12);color: #5d6d7e; }
.badge-info    { background: rgba(41,128,185,0.12); color: #1a5276; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  text-decoration: none; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1e8449; color: white; }
.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; color: white; }
.btn-outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text);
  font-size: 14px; transition: border-color 0.2s;
}
.form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,160,133,0.1);
}
select.form-control { cursor: pointer; }

/* Status filter tabs */
.status-tabs {
  display: flex; gap: 8px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.status-tab {
  padding: 7px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  transition: all 0.2s;
}
.status-tab:hover { border-color: var(--primary); color: var(--primary); }
.status-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Photo thumbnail */
.photo-thumb {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover; border: 2px solid var(--border);
}

/* GPS pin */
.gps-pin { font-size: 18px; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 20px 0;
}
.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text);
  text-decoration: none; font-size: 13px; font-weight: 500;
  transition: all 0.2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Map container */
.map-container {
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); height: 280px;
}

/* Login page */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0e6655 0%, #1abc9c 50%, #16a085 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.login-card {
  background: white; border-radius: 20px;
  padding: 48px 40px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-logo {
  text-align: center; margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, #16a085, #0e6655);
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 30px; margin-bottom: 12px;
}

.login-logo h1 { font-size: 24px; font-weight: 800; color: #2c3e50; }
.login-logo p  { color: #7f8c8d; font-size: 14px; margin-top: 4px; }

/* Toast messages */
.messages { position: fixed; top: 80px; right: 24px; z-index: 9999; }
.alert {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; margin-bottom: 10px;
  box-shadow: var(--shadow-hover);
  animation: slideIn 0.3s ease;
}
.alert-error { background: #fdecea; color: #c0392b; border-left: 4px solid #e74c3c; }
.alert-success{ background: #eafaf1; color: #1e8449; border-left: 4px solid #27ae60; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Chart */
.chart-wrapper { padding: 8px 0; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 56px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text); }

/* Mobile */
.sidebar-toggle { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Animations */
.fade-in {
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
