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

:root {
  --bg:         #f5f6fa;
  --bg-1:       #ffffff;
  --bg-2:       #f0f2f8;
  --bg-3:       #e8ebf4;
  --border:     #dde1ee;
  --border-lit: #c8cedf;
  --text:       #1a1d2e;
  --text-2:     #4a5068;
  --text-3:     #8890aa;
  --accent:     #3b6ef5;
  --accent-bg:  #eef2ff;
  --accent-dim: #3b6ef520;
  --green:      #16a34a;
  --green-bg:   #dcfce7;
  --green-dim:  #16a34a18;
  --red:        #dc2626;
  --red-bg:     #fee2e2;
  --red-dim:    #dc262618;
  --amber:      #d97706;
  --amber-bg:   #fef3c7;
  --amber-dim:  #d9770618;
  --purple:     #7c3aed;
  --purple-bg:  #ede9fe;
  --font-sans:  'Inter', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', monospace;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --transition: 150ms cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #2550cc; }

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

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .wordmark {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
}
.sidebar-logo .wordmark span { color: var(--accent); }
.sidebar-logo .badge {
  font-family: var(--font-mono);
  font-size: .65rem;
  color: var(--text-3);
  margin-top: 2px;
}

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

.nav-section { margin-bottom: 20px; }
.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--bg-2);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.user-name  { font-size: .82rem; font-weight: 600; }
.user-role  { font-family: var(--font-mono); font-size: .65rem; color: var(--text-3); }

/* ── Main ────────────────────────────────────────────────────── */
.main-content { margin-left: 248px; flex: 1; display: flex; flex-direction: column; }

.topbar {
  height: 54px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg-1);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: .9rem; font-weight: 500; color: var(--text-2); }
.topbar-title span { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page { padding: 28px; flex: 1; }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.3px; color: var(--text); }
.page-subtitle { font-size: .8rem; color: var(--text-3); margin-top: 3px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .9rem; font-weight: 600; color: var(--text); }

/* ── Stats ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
.stat-card.green::after { background: var(--green); }
.stat-card.red::after   { background: var(--red); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.purple::after{ background: var(--purple); }

.stat-label { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -1px; line-height: 1; color: var(--text); }
.stat-sub   { font-size: .75rem; color: var(--text-3); margin-top: 6px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); background: var(--bg-1); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--bg-2);
  color: var(--text-3);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: var(--bg-2); }
.mono { font-family: var(--font-mono); font-size: .8rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-blue   { background: var(--accent-bg); color: var(--accent); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-gray   { background: var(--bg-3);      color: var(--text-2); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #2550cc; border-color: #2550cc; color: #fff; }
.btn-outline { background: #fff; color: var(--text-2); border-color: var(--border-lit); }
.btn-outline:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: var(--text-3); border-color: transparent; padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-2); }
.btn-sm { padding: 5px 12px; font-size: .78rem; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border-lit);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 13px;
  font-family: var(--font-sans);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--text-3); margin-top: 5px; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 20px;
  font-weight: 500;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-error  { background: var(--red-bg);   border: 1px solid #fca5a5; color: #991b1b; }
.alert-success{ background: var(--green-bg); border: 1px solid #86efac; color: #14532d; }
.alert-info   { background: var(--accent-bg);border: 1px solid #93c5fd; color: #1e3a8a; }
.alert-warn   { background: var(--amber-bg); border: 1px solid #fcd34d; color: #78350f; }

/* ── Auth ────────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .mark {
  display: inline-flex;
  width: 52px; height: 52px;
  background: var(--accent-bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 14px;
}
.auth-logo h1 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.auth-logo p  { font-size: .8rem; color: var(--text-3); margin-top: 4px; }

.otp-input {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.8rem;
  letter-spacing: .4em;
  padding: 12px;
  font-weight: 500;
}

.qr-wrap {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-block;
}

/* ── Grids ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 20px; justify-content: flex-end; }
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: #fff;
  transition: all var(--transition);
  text-decoration: none;
}
.page-link:hover  { background: var(--bg-2); color: var(--text); border-color: var(--border-lit); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link.disabled { opacity: .35; pointer-events: none; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,20,40,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Utility ─────────────────────────────────────────────────── */
.flex          { display: flex; }
.items-center  { align-items: center; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.gap-4         { gap: 16px; }
.ml-auto       { margin-left: auto; }
.mt-4          { margin-top: 16px; }
.mt-6          { margin-top: 24px; }
.mb-4          { margin-bottom: 16px; }
.mb-6          { margin-bottom: 24px; }
.text-right    { text-align: right; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted    { color: var(--text-3); }
.text-sm       { font-size: .8rem; }
.font-mono     { font-family: var(--font-mono); }
.divider       { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.w-full        { width: 100%; }

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}
.pulse { animation: pulse 2s ease infinite; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-lit); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
