/* Lighthouse design system — dark mode default
   Reference: Linear / Vercel / Stripe Dashboard quality bar
   Fonts hosted locally under /fonts/ — no external requests. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/InterVariable.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/InterVariable-Italic.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/JetBrainsMono-Medium.woff2') format('woff2');
}

:root {
  --bg-base:        #0a0e1a;
  --bg-elevated:    #0f1421;
  --bg-overlay:     #161b2e;
  --bg-hover:       #1a2138;
  --border-subtle:  #1f2940;
  --border-default: #2a3553;
  --border-strong:  #3a466b;
  --text-primary:   #e5e7eb;
  --text-secondary: #9ca3af;
  --text-tertiary:  #6b7280;
  --accent-blue:    #3b82f6;
  --accent-blue-strong: #2563eb;
  --accent-violet:  #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber:   #f59e0b;
  --accent-red:     #ef4444;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  --t: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-blue); }
hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 24px 0; }

code, pre, .mono { font-family: var(--font-mono); }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
p { margin: 0 0 12px 0; color: var(--text-secondary); }

::selection { background: rgba(59, 130, 246, 0.35); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* App shell ------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.app--no-sidebar { grid-template-columns: 1fr; }

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  padding: 20px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 22px 8px;
  font-weight: 600; font-size: 16px; letter-spacing: -0.2px;
}
.sidebar__brand img { width: 28px; height: 28px; }
.sidebar__brand span.suffix { color: var(--text-tertiary); font-weight: 500; font-size: 13px; }

.nav-section { margin-bottom: 18px; }
.nav-section__label {
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em;
  color: var(--text-tertiary); padding: 0 8px 6px 8px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
  transition: background var(--t), color var(--t);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-primary);
}
.nav-link.active::before {
  content: ''; width: 3px; height: 14px; border-radius: 2px;
  background: var(--accent-blue); margin-left: -8px; margin-right: 4px;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

.sidebar__footer {
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary); font-size: 12px;
}
.sidebar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px; border-radius: var(--radius-sm);
}
.sidebar__user-link {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0; padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: inherit; text-decoration: none;
  transition: background var(--t);
}
.sidebar__user-link:hover { background: var(--bg-hover); color: inherit; }
.sidebar__user .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: white;
}
.sidebar__user .meta { flex: 1; min-width: 0; }
.sidebar__user .meta .email {
  color: var(--text-primary); font-size: 12.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user .meta .role { color: var(--text-tertiary); font-size: 11px; }

/* Main content area */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-tertiary); font-size: 13px;
}
.breadcrumb__sep { color: var(--text-tertiary); opacity: 0.6; }
.breadcrumb__current { color: var(--text-primary); font-weight: 500; }

.topbar__actions { display: flex; align-items: center; gap: 12px; }
.helix-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-violet); border: 1px solid rgba(139, 92, 246, 0.25);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  text-decoration: none; transition: background var(--t), border-color var(--t);
}
a.helix-badge:hover {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.45);
  color: var(--accent-violet);
}

.impersonation-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin: -4px 0 14px 0;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-violet);
  font-size: 12px; font-weight: 600;
  text-decoration: none; transition: background var(--t), border-color var(--t);
}
.impersonation-banner:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--accent-violet);
}
.impersonation-banner__sub {
  margin-left: auto; font-weight: 500; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  opacity: 0.7;
}

.content {
  padding: 32px;
  max-width: 1400px; width: 100%;
  margin: 0 auto;
  flex: 1;
}
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px 0; }
.page-header .subtitle { color: var(--text-secondary); font-size: 14px; }
.page-header__actions { display: flex; gap: 8px; }

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  font-family: var(--font-sans); font-weight: 500; font-size: 13.5px;
  cursor: pointer; user-select: none; border: 1px solid transparent;
  transition: all var(--t); line-height: 1; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary {
  background: var(--accent-blue); color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset;
}
.btn--primary:hover { background: var(--accent-blue-strong); color: white; }
.btn--secondary {
  background: var(--bg-overlay); color: var(--text-primary);
  border-color: var(--border-default);
}
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-primary); }
.btn--ghost {
  background: transparent; color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn--danger {
  background: rgba(239, 68, 68, 0.12); color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn--danger:hover { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.btn--sm { padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn--lg { padding: 11px 18px; font-size: 14px; }

/* Cards ----------------------------------------------------------------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px;
}
.card--pad-sm { padding: 16px; }
.card--pad-lg { padding: 32px; }
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.card__header h3 { font-size: 15px; font-weight: 600; }

/* Stat pills ------------------------------------------------------------ */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  position: relative; overflow: hidden;
}
.stat-pill__label {
  font-size: 12px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  margin-bottom: 6px;
}
.stat-pill__value {
  font-size: 32px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--text-primary); font-variant-numeric: tabular-nums;
}
.stat-pill__hint { color: var(--text-tertiary); font-size: 12px; margin-top: 4px; }

/* Tables ---------------------------------------------------------------- */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
table.tbl {
  width: 100%; border-collapse: collapse;
}
table.tbl th, table.tbl td {
  padding: 12px 18px; text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
table.tbl th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-tertiary); font-weight: 600;
  background: rgba(255,255,255,0.01);
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td {
  background: rgba(255,255,255,0.02);
}
table.tbl td { font-size: 13.5px; color: var(--text-primary); }
table.tbl td.muted { color: var(--text-secondary); }

/* Badges --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  font-weight: 600;
}
.badge--info { background: rgba(59,130,246,0.12); color: var(--accent-blue); }
.badge--success { background: rgba(16,185,129,0.12); color: var(--accent-emerald); }
.badge--warn { background: rgba(245,158,11,0.12); color: var(--accent-amber); }
.badge--danger { background: rgba(239,68,68,0.12); color: var(--accent-red); }
.badge--violet { background: rgba(139,92,246,0.12); color: var(--accent-violet); }
.badge--neutral { background: rgba(156,163,175,0.12); color: var(--text-secondary); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--ok { background: var(--accent-emerald); box-shadow: 0 0 8px rgba(16,185,129,0.6); }
.dot--warn { background: var(--accent-amber); box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.dot--err { background: var(--accent-red); box-shadow: 0 0 8px rgba(239,68,68,0.6); }
.dot--idle { background: var(--text-tertiary); }

/* Forms ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label {
  font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
}
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=color],
.field select,
.field textarea {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: var(--font-sans); font-size: 14px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
.field .hint { font-size: 12px; color: var(--text-tertiary); }

.toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle__track {
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--border-default);
  position: relative; transition: background var(--t);
}
.toggle__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: white;
  transition: left var(--t);
}
.toggle input:checked + .toggle__track { background: var(--accent-blue); }
.toggle input:checked + .toggle__track::after { left: 16px; }

/* Empty state ----------------------------------------------------------- */
.empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-xl);
}
.empty__art { margin: 0 auto 20px; width: 96px; height: 96px; opacity: 0.85; }
.empty h3 { font-size: 18px; margin-bottom: 6px; }
.empty p { color: var(--text-secondary); max-width: 460px; margin: 0 auto 16px; }

/* Auth pages ------------------------------------------------------------ */
.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(139,92,246,0.18), transparent 60%),
    radial-gradient(1000px 500px at 0% 100%, rgba(59,130,246,0.18), transparent 60%),
    var(--bg-base);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 40px 36px 32px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-card__brand {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 24px;
}
.auth-card__brand img { width: 56px; height: 56px; }
.auth-card__brand .name { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.auth-card .subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 24px; font-size: 13.5px; }

.form-error {
  background: rgba(239,68,68,0.1); color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px;
  font-size: 13px;
}

/* Misc -------------------------------------------------------------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.muted { color: var(--text-secondary); }
.tertiary { color: var(--text-tertiary); }
.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); }
.u-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.code-block {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-mono); font-size: 12.5px;
  color: var(--text-primary); overflow-x: auto; line-height: 1.55;
  position: relative;
}
.code-block .copy {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 10px; font-size: 11px; border-radius: var(--radius-sm);
  background: var(--bg-hover); color: var(--text-secondary);
  border: 1px solid var(--border-default); cursor: pointer;
  font-family: var(--font-sans); transition: all var(--t);
}
.code-block .copy:hover { color: var(--text-primary); border-color: var(--border-strong); }

.kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(139,92,246,0.12); color: var(--accent-violet);
  border: 1px solid rgba(139,92,246,0.25);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}

/* Page transition - subtle fade in */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.content > * { animation: fade-in-up 200ms cubic-bezier(0.4, 0, 0.2, 1); }

/* Responsive */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 18px; }
  .content { padding: 22px 18px; }
}
