:root {
  --primary: #ff5722; --success: #4caf50; --warning: #ff9800;
  --danger: #f44336; --info: #2196f3; --dark: #1a1a2e;
  --sidebar-w: 240px; --border: #e0e0e0; --bg: #f4f6f9;
  --white: #fff; --radius: 10px; --shadow: 0 2px 12px rgba(0,0,0,.08);
  --font: 'Inter', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: #1a1a2e; }
a { text-decoration: none; color: inherit; }

/* ── Layout ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--dark); color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100; transition: transform .3s;
}
.sidebar-logo {
  padding: 20px 16px; font-size: 18px; font-weight: 800;
  color: var(--primary); border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo small { display: block; font-size: 11px; font-weight: 400; color: #aaa; margin-top: 2px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; cursor: pointer; font-size: 14px;
  font-weight: 500; color: rgba(255,255,255,.7);
  transition: all .2s; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,87,34,.15); color: var(--primary); border-left-color: var(--primary); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 14px;
}
.sidebar-name { font-size: 13px; font-weight: 600; }
.sidebar-role { font-size: 11px; color: #aaa; }
.logout-btn {
  width: 100%; padding: 9px; background: transparent;
  border: 1.5px solid rgba(255,255,255,.35); border-radius: 8px;
  color: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: var(--font); transition: border-color .2s, background .2s;
  margin-top: 10px;
}
.logout-btn:hover { border-color: #ff5722; color: #ff5722; background: rgba(255,87,34,.08); }

/* ── Main ─────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  background: var(--white); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 13px; color: #777; }

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

/* ── Stats Grid ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-icon.orange { background: #fff3e0; }
.stat-icon.green  { background: #e8f5e9; }
.stat-icon.blue   { background: #e3f2fd; }
.stat-icon.red    { background: #ffebee; }
.stat-icon.purple { background: #f3e5f5; }
.stat-val   { font-size: 24px; font-weight: 800; }
.stat-label { font-size: 12px; color: #777; margin-top: 2px; }
.stat-change { font-size: 11px; margin-top: 4px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Section ─────────────────────────────────────────────── */
.section { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.section-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.section-title { font-size: 15px; font-weight: 700; }
.section-body  { padding: 20px; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #777; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge-success  { background: #e8f5e9; color: #2e7d32; }
.badge-danger   { background: #ffebee; color: #c62828; }
.badge-warning  { background: #fff8e1; color: #e65100; }
.badge-info     { background: #e3f2fd; color: #1565c0; }
.badge-default  { background: #f5f5f5; color: #555; }
.badge-primary  { background: #fff3e0; color: #bf360c; }
.badge-purple   { background: #ede7f6; color: #4527a0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: var(--font); transition: all .2s; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-info     { background: var(--info);    color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: #555; }
.btn:hover    { opacity: .88; transform: scale(.99); }
.btn-block    { width: 100%; }

/* ── Form ─────────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control  { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: var(--font); outline: none; transition: border .2s; }
.form-control:focus { border-color: var(--primary); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: #777; margin-top: 4px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 500;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  width: min(520px, 95vw); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: modalIn .2s ease;
}
@keyframes modalIn { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-close  { background: none; border: none; font-size: 20px; cursor: pointer; color: #777; line-height: 1; padding: 4px; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.filter-bar input, .filter-bar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: var(--font); outline: none; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 6px; padding: 16px 0; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); cursor: pointer; font-size: 13px; font-family: var(--font); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: #f5f5f5; }
.page-info { font-size: 13px; color: #777; padding: 6px 0; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: #777; }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; color: #444; }
.empty-sub   { font-size: 13px; }

/* ── Quick charts (pure CSS bar) ─────────────────────────────── */
.mini-chart { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.mini-bar   { flex: 1; background: #ff572222; border-radius: 3px 3px 0 0; transition: height .3s; position: relative; }
.mini-bar:hover { background: var(--primary); }
.mini-bar .bar-tip { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 600; color: var(--primary); white-space: nowrap; display: none; }
.mini-bar:hover .bar-tip { display: block; }

/* ── Dual-panel layout ─────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ── Login Page ─────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1a1a2e,#16213e); }
.login-box  { background: var(--white); border-radius: 16px; padding: 40px; width: min(420px,95vw); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { font-size: 24px; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: 8px; }
.login-sub  { text-align: center; color: #777; font-size: 14px; margin-bottom: 28px; }

/* ── City Tags ─────────────────────────────────────────────── */
.city-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f0f4ff; border: 1px solid #c5d0f5;
  border-radius: 20px; padding: 5px 12px;
  font-size: 13px; font-weight: 500; color: #3a4a8a;
}
.city-tag button:hover { color: var(--danger) !important; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--dark); color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 9999; opacity: 0; transition: all .3s; white-space: nowrap; }
#toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }
#toast.warning { background: var(--warning); }

/* ── Inline alerts ─────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; }
.alert-error   { background: #ffebee; color: #c62828; }
.alert-success { background: #e8f5e9; color: #2e7d32; }

/* ── Summary row ─────────────────────────────────────────────── */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-pill { background: var(--white); border-radius: 8px; padding: 10px 16px; box-shadow: var(--shadow); font-size: 13px; }
.kpi-pill strong { font-size: 16px; font-weight: 800; color: var(--primary); display: block; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
