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

:root {
  --accent:       #5b5fef;
  --accent-light: #eef0ff;
  --accent-dark:  #4348c4;
  --teal:         #00a884;
  --teal-light:   #e6f7f4;
  --amber:        #f59e0b;
  --amber-light:  #fef3c7;
  --red:          #e63946;
  --red-light:    #fde8ea;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-300:     #cbd5e1;
  --gray-400:     #94a3b8;
  --gray-500:     #64748b;
  --gray-600:     #475569;
  --gray-700:     #334155;
  --gray-800:     #1e293b;
  --gray-900:     #0f172a;
  --sidebar-w:    230px;
  --radius:       10px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow:       0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:    0 10px 40px rgba(0,0,0,.16);
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
  flex: 0 0 auto;
}
.sidebar-title { font-weight: 700; font-size: 15px; }
.sidebar-subtitle { font-size: 11px; color: var(--gray-400); }

.sidebar-nav { padding: 14px 10px; flex: 1; }
.nav-group-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--gray-500);
  padding: 12px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--gray-400);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11.5px;
  color: var(--gray-500);
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.global-search { position: relative; flex: 1; max-width: 340px; }
.global-search input {
  width: 100%; padding: 7px 10px 7px 34px;
  border: 1px solid var(--gray-200); border-radius: 8px;
  background: var(--gray-50); font-size: 13px; font-family: var(--font);
  outline: none; color: var(--gray-800);
}
.global-search input:focus { border-color: var(--accent); background: #fff; }
.global-search .si {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 13px; pointer-events: none;
}
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
  box-shadow: var(--shadow-lg); z-index: 9999; overflow: hidden; display: none;
}
.search-dropdown.open { display: block; }
.search-result { padding: 9px 12px; cursor: pointer; display: flex; align-items: flex-start; gap: 8px; border-bottom: 1px solid var(--gray-100); }
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--gray-50); }
.sr-type { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--gray-100); color: var(--gray-500); flex: 0 0 auto; margin-top: 1px; }
.sr-body { flex: 1; min-width: 0; }
.sr-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-sub { font-size: 11.5px; color: var(--gray-400); }

.page-body { padding: 28px; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 20px; }

/* ── Stat tiles ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--gray-500); }
.stat-sub { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  font-family: var(--font);
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-danger { background: var(--red); color: #fff; }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--gray-500);
  padding: 6px 8px;
}
.btn-ghost:hover { color: var(--gray-800); background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ── Search / inputs ── */
.input {
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: var(--font);
  background: #fff;
  color: var(--gray-800);
  outline: none;
  width: 100%;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,95,239,.12); }
.input-group { display: flex; gap: 8px; align-items: center; }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400); font-size: 14px; pointer-events: none;
}
.search-wrap .input { padding-left: 32px; min-width: 240px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500);
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }

/* ── Tags / chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px; font-weight: 600;
}
.chip-accent  { background: var(--accent-light);  color: var(--accent); }
.chip-teal    { background: var(--teal-light);    color: var(--teal); }
.chip-amber   { background: var(--amber-light);   color: #92400e; }
.chip-red     { background: var(--red-light);     color: var(--red); }
.chip-gray    { background: var(--gray-100);      color: var(--gray-600); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-amber  { background: var(--amber-light); color: #92400e; }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

/* ── Avatar ── */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex: 0 0 auto;
  border: 2px solid transparent;
}
.avatar-cell { display: flex; align-items: center; gap: 10px; }
.avatar-name { font-weight: 600; }
.avatar-id   { font-size: 11.5px; color: var(--gray-400); }

/* ── Progress bar ── */
.progress-bar { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 540px; max-width: 95vw;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: #fff; border-radius: 14px 14px 0 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 22px; flex: 1; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 5px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
textarea.input { resize: vertical; min-height: 80px; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn .2s ease;
}
.toast.success { border-left: 3px solid var(--teal); }
.toast.error   { border-left: 3px solid var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } }

/* ── Misc ── */
.text-muted { color: var(--gray-400); }
.text-sm { font-size: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
