/* ============================================================
   Nexus IT — Design System
   ============================================================ */
:root {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e6e8ef;
  --border-strong: #d6d9e3;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --muted: #64748b;

  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;

  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --danger: #ef4444;
  --danger-50: #fef2f2;
  --info: #0ea5e9;
  --info-50: #f0f9ff;
  --purple: #8b5cf6;
  --purple-50: #f5f3ff;
  --pink: #ec4899;
  --pink-50: #fdf2f8;

  --sidebar-bg: #0b1220;
  --sidebar-bg-2: #0e162a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-strong: #f1f5f9;
  --sidebar-active: #4f46e5;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.18);

  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.flex { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.items-center { align-items: center; }
.grow { flex: 1; }
.right { margin-left: auto; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-6 { padding: 24px; }

/* ============================================================
   Login screen
   ============================================================ */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, #1e1b4b 0%, #0b1220 50%, #020617 100%);
  z-index: 100;
}
.login-card {
  width: 460px; max-width: 92vw;
  background: white; border-radius: 20px;
  padding: 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}
.login-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 6px;
}
.login-brand h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 8px 0 22px; }
.login-roles { display: grid; gap: 10px; }
.role-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  background: var(--surface-2); border-radius: 12px;
  text-align: left; transition: 120ms;
}
.role-btn:hover { border-color: var(--primary); background: var(--primary-50); transform: translateY(-1px); }
.role-btn .role-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: white; font-weight: 700;
  display: grid; place-items: center; flex: 0 0 36px;
}
.role-btn strong { display: block; font-size: 14px; }
.role-btn span { color: var(--muted); font-size: 12px; }
.login-form { display: grid; gap: 14px; }
.login-field { display: grid; gap: 6px; text-align: left; }
.login-field span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.login-field input {
  padding: 11px 13px; border: 1px solid var(--border);
  background: var(--surface-2); border-radius: 10px;
  font-family: var(--font); font-size: 14px; outline: none; transition: 120ms;
}
.login-field input:focus { border-color: var(--primary); background: var(--surface); }
.login-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 9px; padding: 9px 12px; font-size: 12.5px;
}
.login-submit { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.login-foot { margin-top: 20px; font-size: 11.5px; text-align: center; }

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #1e293b;
  /* Lift the sidebar's stacking context above the main content (topbar=30,
     content=0) so popouts like the business switcher render over the cards.
     Stays below modals (80) and toasts (200). */
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #1e293b;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: var(--sidebar-text-strong); font-size: 15px; }
.brand-text span { color: #64748b; font-size: 11.5px; }

.nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 6px; }

.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: 100ms;
  position: relative;
}
.nav-item svg { flex: 0 0 16px; opacity: 0.8; }
.nav-item:hover { background: #16213a; color: var(--sidebar-text-strong); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.2), rgba(79, 70, 229, 0.05));
  color: white;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -4px; top: 6px; bottom: 6px;
  width: 3px; background: var(--primary); border-radius: 3px;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid #1e293b;
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  background: #111c33;
  padding: 10px;
  border-radius: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  color: white; font-weight: 700; font-size: 13px;
  display: inline-grid; place-items: center;
  vertical-align: middle;
  flex: 0 0 34px;
}
/* Gap between the initials circle and the name in tables (sidebar avatar
   uses its own flex spacing, so scope this to tables only). */
.table .avatar { margin-right: 8px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta strong { color: white; font-size: 13px; }
.user-meta span { color: #94a3b8; font-size: 11px; }
.icon-btn {
  background: transparent; border: 0; color: inherit;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  position: relative;
  transition: 100ms;
}
.icon-btn:hover { background: rgba(148, 163, 184, 0.12); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  border: 2px solid var(--surface);
}

/* ============================================================
   Topbar
   ============================================================ */
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar .icon-btn { color: var(--text-2); }
.topbar .icon-btn:hover { background: var(--bg-soft); }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  width: 420px; max-width: 100%;
  color: var(--muted);
}
.search input {
  border: 0; background: transparent; outline: none;
  flex: 1; min-width: 0; color: var(--text);
}
.search input::placeholder { color: var(--text-3); }
.search kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-family: var(--font);
}
.mobile-menu { display: none; }

/* ============================================================
   Content
   ============================================================ */
.content {
  padding: 24px;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px; flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.015em;
  font-weight: 700;
}
.page-head .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 1024px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; transform: translateX(-100%); z-index: 50; transition: transform 200ms; }
  .sidebar.open { transform: none; }
  .mobile-menu { display: grid; }
  .search { width: auto; }
}
