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

/* ── tokens ── */
:root {
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --border:   #e8eaed;
  --border-2: #d1d5db;

  --text:     #111827;
  --text-2:   #4b5563;
  --text-3:   #9ca3af;

  --blue:     #2563eb;
  --blue-bg:  #eff6ff;
  --green:    #16a34a;
  --green-bg: #f0fdf4;
  --amber:    #d97706;
  --amber-bg: #fffbeb;
  --red:      #dc2626;
  --red-bg:   #fef2f2;

  --radius:   8px;
  --r-lg:     12px;
  --trans:    0.15s ease;

  --font: 'Inter', system-ui, sans-serif;
}

/* ── reset ── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }

/* ── scrollbar ── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius:4px; }

/* ── util ── */
.hidden { display:none !important; }

/* ── badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-warning { background: var(--amber-bg); color: var(--amber); }
.badge-danger  { background: var(--red-bg);   color: var(--red); }

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  transition: all var(--trans);
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--border-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ── forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-group input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: var(--surface);
}

/* ────────────────────────────────
   LOGIN
──────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
.login-logo {
  width: 40px;
  height: 40px;
  background: var(--blue);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 auto 20px;
}
.login-card h2 {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card > p {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-2);
  margin-bottom: 28px;
}
.login-submit {
  width: 100%;
  padding: 10px;
  justify-content: center;
}
.demo-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ────────────────────────────────
   LAYOUT
──────────────────────────────── */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ── sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-brand span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--trans);
  text-align: left;
}
.nav-item button:hover {
  background: var(--bg);
  color: var(--text);
}
.nav-item.active button {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 600;
}
.nav-item button svg { flex-shrink: 0; }

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
#logout-btn {
  width: 100%;
  justify-content: center;
  color: var(--text-2);
}

/* ── main ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}
.top-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.page-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.user-name  { font-size: 0.85rem; font-weight: 600; }
.user-role  { font-size: 0.75rem; color: var(--text-3); }

.content-wrapper { padding: 24px 28px 40px; }
.view-section { display: flex; flex-direction: column; gap: 20px; }

/* ────────────────────────────────
   STAT CARDS
──────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: box-shadow var(--trans);
}
.stat-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}
.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}
.stat-trend {
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }
.trend-note { color: var(--text-3); font-weight: 400; }

/* ────────────────────────────────
   CHART CARDS
──────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}
.chart-card, .table-card, .settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
}
.card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.card-header span {
  font-size: 0.78rem;
  color: var(--text-3);
}

/* ────────────────────────────────
   ACTIVITY LIST
──────────────────────────────── */
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-user  { font-size: 0.88rem; font-weight: 600; margin-bottom: 2px; }
.activity-action { font-size: 0.8rem; color: var(--text-2); }
.activity-meta  { text-align: right; }
.activity-time  { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }

/* ────────────────────────────────
   USERS TABLE
──────────────────────────────── */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  max-width: 280px;
}
.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color var(--trans);
}
.search-box input:focus { border-color: var(--blue); }
.search-box input::placeholder { color: var(--text-3); }

.table-responsive { overflow-x: auto; }
table { width:100%; border-collapse:collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th {
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-name { font-weight: 600; font-size: 0.875rem; }
.user-cell-sub  { font-size: 0.75rem; color: var(--text-3); }

/* ────────────────────────────────
   SETTINGS
──────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.settings-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 16px; }

.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-group:last-child { border-bottom: none; }
.toggle-label  { font-size: 0.875rem; font-weight: 500; margin-bottom: 2px; }
.toggle-desc   { font-size: 0.78rem; color: var(--text-3); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity:0; width:0; height:0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--border-2);
  border-radius: 22px;
  cursor: pointer;
  transition: background .25s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider { background: var(--blue); }
input:checked + .slider::before { transform: translateX(18px); }

/* ────────────────────────────────
   ANALYTICS / REPORTS
──────────────────────────────── */
.reports-intro {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 20px;
  line-height: 1.6;
}
.reports-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ────────────────────────────────
   MODAL
──────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,0.35);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--trans);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ────────────────────────────────
   TOAST
──────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s ease;
}
#toast.show { transform: translateY(0); opacity: 1; }
.toast-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}
