:root {
  /* Color palette — dark, professional */
  --bg-base: #0a0b0d;
  --bg-surface: #121418;
  --bg-elevated: #1a1d23;
  --bg-elevated-hover: #21252c;
  --border: #23272f;
  --border-strong: #2e333b;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);

  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --neutral: #6b7280;

  --text-primary: #e6e8eb;
  --text-muted: #8a8f98;
  --text-faint: #40464f;

  /* Spacing — strict 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 999px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-fast: 100ms var(--ease);
  --t-base: 150ms var(--ease);
  --t-slow: 250ms var(--ease);

  /* Layout */
  --sidebar-width: 240px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

#root {
  height: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: var(--fs-base);
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
  min-width: 44px;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent);
  color: white;
}
.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn--secondary:hover {
  background: var(--bg-elevated-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn--danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}
.btn--danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--danger);
}

.btn--icon {
  width: 32px;
  padding: 0;
}

.btn--lg {
  height: 40px;
  padding: 0 var(--space-4);
  font-size: var(--fs-md);
}

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-base);
  z-index: 100;
}

.loading__spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Form helpers */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.field__error {
  color: var(--danger);
  font-size: var(--fs-sm);
  margin-top: var(--space-1);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: var(--space-4);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.modal__body {
  padding: var(--space-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.modal__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Avatar */
.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  user-select: none;
  background: var(--accent);
  overflow: hidden;
  font-size: 11px;
  width: 28px;
  height: 28px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--md { width: 32px; height: 32px; font-size: 12px; }
.avatar--lg { width: 40px; height: 40px; font-size: 14px; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge--accent { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.badge--success { color: var(--success); border-color: rgba(34, 197, 94, 0.4); }
.badge--warning { color: var(--warning); border-color: rgba(245, 158, 11, 0.4); }
.badge--danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); }

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* Visually hidden */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
