/* Reset & Variables */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand colors derived from Refine logo */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;

  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;

  --navy-50: #f0f4f8;
  --navy-100: #d9e2ec;
  --navy-200: #bcccdc;
  --navy-300: #9fb3c8;
  --navy-400: #829ab1;
  --navy-500: #627d98;
  --navy-600: #486581;
  --navy-700: #334e68;
  --navy-800: #243b53;
  --navy-900: #102a43;
  --navy-950: #0b1628;

  --orange-400: #fb923c;
  --orange-500: #f97316;

  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafb;
  --bg-tertiary: #f0f4f8;
  --bg-inverse: var(--navy-950);

  --surface: #ffffff;
  --surface-hover: #f8fafb;
  --surface-border: #e2e8f0;
  --surface-border-hover: #cbd5e1;

  --text-primary: var(--navy-950);
  --text-secondary: var(--navy-600);
  --text-tertiary: var(--navy-400);
  --text-inverse: #ffffff;

  --brand-primary: var(--emerald-500);
  --brand-primary-hover: var(--emerald-600);
  --brand-primary-light: var(--emerald-50);
  --brand-primary-border: var(--emerald-200);
  --brand-primary-shadow: rgba(16, 185, 129, 0.3);

  --brand-secondary: var(--teal-500);
  --brand-accent: var(--orange-500);

  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --input-focus-border: var(--teal-400);
  --input-focus-ring: rgba(45, 212, 191, 0.15);

  --topbar-bg: rgba(255, 255, 255, 0.97);
  --topbar-border: #f0f4f8;

  --card-border: #e2e8f0;
  --card-hover-shadow: 0 4px 12px rgba(11, 22, 40, 0.08);

  --logo-color: var(--emerald-600);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-sm: 0 1px 2px rgba(11, 22, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(11, 22, 40, 0.08);
  --shadow-lg: 0 8px 24px rgba(11, 22, 40, 0.12);

  --topbar-height: 56px;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-primary: var(--navy-950);
  --bg-secondary: #0f1e32;
  --bg-tertiary: #162a46;
  --bg-inverse: #ffffff;

  --surface: #132337;
  --surface-hover: #1a2e4a;
  --surface-border: #1e3a5f;
  --surface-border-hover: #2a4a72;

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: var(--navy-950);

  --brand-primary: var(--emerald-400);
  --brand-primary-hover: var(--emerald-300);
  --brand-primary-light: rgba(16, 185, 129, 0.1);
  --brand-primary-border: rgba(16, 185, 129, 0.2);
  --brand-primary-shadow: rgba(16, 185, 129, 0.25);

  --brand-secondary: var(--teal-400);

  --input-bg: #132337;
  --input-border: #1e3a5f;
  --input-focus-border: var(--teal-400);
  --input-focus-ring: rgba(45, 212, 191, 0.15);

  --topbar-bg: rgba(11, 22, 40, 0.95);
  --topbar-border: #1e3a5f;

  --card-border: #1e3a5f;
  --card-hover-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

  --logo-color: var(--emerald-400);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);

  --red-50: rgba(220, 38, 38, 0.1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

#app {
  min-height: 100vh;
}

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
h2 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
h4 { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); }

/* Top Bar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--topbar-border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.topbar-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--logo-color);
  text-decoration: none;
  cursor: pointer;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.topbar-btn:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.topbar-btn.active {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.topbar-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.topbar-user {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--brand-primary-border);
  margin-left: 0.5rem;
}

/* Main Content */
.main-content {
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* Screen container */
.screen {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes slideOutRight {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}
