/* ─── Fonts & Reset ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #f5f5f7;
  --bg2: #e8e8ed;
  --surface: rgba(255,255,255,0.8);
  --surface-hover: rgba(255,255,255,0.95);
  --border: rgba(0,0,0,0.08);
  --text: #1d1d1f;
  --text2: #6e6e73;
  --accent: #34c759;
  --accent-dark: #248a3d;
  --red: #ff3b30;
  --yellow: #ff9500;
  --blue: #007aff;
  --sidebar-w: 220px;
  --radius: 14px;
  --shadow: 0 2px 16px rgba(0,0,0,0.07);
  --blur: blur(20px);
}

[data-theme="dark"] {
  --bg: #1c1c1e;
  --bg2: #2c2c2e;
  --surface: rgba(44,44,46,0.85);
  --surface-hover: rgba(58,58,60,0.95);
  --border: rgba(255,255,255,0.1);
  --text: #f5f5f7;
  --text2: #98989d;
  --shadow: 0 2px 20px rgba(0,0,0,0.4);
}

html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  transition: background 0.3s, color 0.3s;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: background 0.3s;
}

.sidebar-brand {
  padding: 0 18px 20px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-brand svg { color: var(--accent); width: 22px; height: 22px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  color: var(--text2);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 10px;
  margin: 2px 8px;
  transition: all 0.18s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: rgba(52,199,89,0.12); color: var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-bottom {
  margin-top: auto;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border);
}

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.page-content { padding: 24px 26px; flex: 1; }

/* ─── Glass Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
}

/* ─── Stats ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  transition: transform 0.18s, background 0.3s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.1); }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.green  { background: rgba(52,199,89,0.14);  color: var(--accent); }
.stat-icon.red    { background: rgba(255,59,48,0.14);   color: var(--red); }
.stat-icon.yellow { background: rgba(255,149,0,0.14);   color: var(--yellow); }
.stat-icon.blue   { background: rgba(0,122,255,0.14);   color: var(--blue); }
.stat-number { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat-label  { font-size: 0.78rem; color: var(--text2); margin-top: 3px; font-weight: 500; }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
  text-align: left; padding: 9px 13px;
  font-size: 0.73rem; font-weight: 600;
  color: var(--text2); text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.14s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
tbody td { padding: 10px 13px; }

/* ─── Badge ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.71rem; font-weight: 600;
}
.badge-green  { background: rgba(52,199,89,0.14);  color: #248a3d; }
.badge-red    { background: rgba(255,59,48,0.14);   color: var(--red); }
.badge-yellow { background: rgba(255,149,0,0.14);   color: #b86e00; }
.badge-blue   { background: rgba(0,122,255,0.14);   color: var(--blue); }
.badge-gray   { background: var(--bg2);              color: var(--text2); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 9px;
  font-size: 0.84rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.18s; text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger  { background: rgba(255,59,48,0.1); color: var(--red); }
.btn-danger:hover  { background: rgba(255,59,48,0.18); }
.btn-ghost   { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover   { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; border-radius: 7px; }
.btn svg { width: 14px; height: 14px; }

/* ─── Form ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-size: 0.875rem; font-family: inherit;
  transition: border 0.18s, background 0.3s; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="range"] { padding: 0; border: none; background: transparent; }
input[type="checkbox"] { width: auto; cursor: pointer; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: 18px; padding: 26px;
  width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity:0; transform: scale(0.95) translateY(8px); } }
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.modal-title { font-size: 1rem; font-weight: 700; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; width: 100%; display: flex;
  align-items: center; justify-content: center; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 38px 34px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo svg { color: var(--accent); width: 40px; height: 40px; }
.login-title { font-size: 1.2rem; font-weight: 700; margin-top: 10px; }

/* ─── Layout helpers ─────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.page-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; }

.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center; margin-bottom: 14px;
}
.filter-bar select, .filter-bar input { width: auto; padding: 7px 11px; font-size: 0.82rem; }

/* ─── Toggle ─────────────────────────────────────────────────────────────── */
.toggle { display: flex; background: var(--bg2); border-radius: 20px; padding: 3px; gap: 2px; }
.toggle-btn {
  padding: 4px 10px; border-radius: 16px;
  border: none; background: transparent;
  color: var(--text2); font-size: 0.75rem;
  font-weight: 600; cursor: pointer; transition: all 0.18s;
  font-family: inherit;
}
.toggle-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ─── Misc ───────────────────────────────────────────────────────────────── */
.alert { padding: 11px 15px; border-radius: 10px; font-size: 0.84rem; margin-bottom: 14px; }
.alert-success { background: rgba(52,199,89,0.1); color: #248a3d; border: 1px solid rgba(52,199,89,0.18); }
.alert-error   { background: rgba(255,59,48,0.1); color: var(--red); border: 1px solid rgba(255,59,48,0.18); }
.text-muted { color: var(--text2); }
.text-sm    { font-size: 0.8rem; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: 14px; }
.mt-6 { margin-top: 22px; }
.d-flex { display: flex; align-items: center; }
.gap-2  { gap: 8px; }
.empty  { color: var(--text2); font-size: 0.875rem; padding: 24px 0; text-align: center; }
.section-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 14px; }

/* ─── Charts ─────────────────────────────────────────────────────────────── */
canvas { max-height: 250px; }
#lineChart { max-height: 150px; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { width: 58px; }
  .sidebar .nav-label, .sidebar .sidebar-brand-text { display: none; }
  .main-wrap { margin-left: 58px; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 14px; }
}
