/* ALGO Design System — Nextiva-inspired enterprise dark theme + ALGO brand */

:root {
  /* Backgrounds */
  --bg-deep:       #04071a;
  --bg:            #080d24;
  --bg-elev:       #0d1335;
  --bg-card:       #111940;
  --bg-card-hover: #182050;
  --bg-glass:      rgba(17,25,64,0.85);

  /* Borders */
  --border:        #1c2759;
  --border-strong: #253680;
  --border-glow:   rgba(124,58,237,0.4);

  /* Brand gradient */
  --brand-from:    #7c3aed;
  --brand-to:      #2563eb;
  --grad-brand:    linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  --grad-brand-h:  linear-gradient(135deg, #9f67ff 0%, #3b82f6 100%);
  --grad-text:     linear-gradient(135deg, #c4b5fd 0%, #93c5fd 50%, #6ee7b7 100%);
  --grad-warm:     linear-gradient(135deg, #f97316 0%, #ec4899 100%);

  /* Text */
  --text:          #f0f3ff;
  --text-soft:     #8b9bcf;
  --text-mute:     #4d5a87;
  --text-inverse:  #04071a;

  /* Accent colors */
  --purple:        #a78bfa;
  --blue:          #60a5fa;
  --green:         #34d399;
  --amber:         #fbbf24;
  --pink:          #f472b6;
  --red:           #f87171;
  --cyan:          #22d3ee;

  /* Status */
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 48px;
  --space-9: 64px; --space-10: 96px; --space-11: 128px;

  /* Radius */
  --r-sm: 6px; --r: 10px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;

  /* Shadow */
  --sh-card:   0 4px 32px rgba(0,0,0,0.5);
  --sh-glow:   0 0 60px rgba(124,58,237,0.25);
  --sh-hover:  0 8px 40px rgba(0,0,0,0.6), 0 0 20px rgba(124,58,237,0.15);

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sidebar */
  --sidebar-w: 260px;
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }
h1 { font-size: clamp(2rem, 5vw, 3.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.125rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }
p { color: var(--text-soft); line-height: 1.7; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--purple); }
code { font-family: monospace; background: var(--bg-card); padding: 2px 6px; border-radius: 4px; font-size: 0.875em; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--space-6); }
.page { min-height: 100vh; }

/* ── Gradient text ──────────────────────────────────────────────────────────── */
.grad-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--r-pill);
  font-size: 0.9rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none; transition: all 0.15s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 4px 20px rgba(124,58,237,0.4);
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(124,58,237,0.6); background: var(--grad-brand-h); }
.btn-secondary {
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--purple); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 0.825rem; }
.btn-lg { padding: 16px 36px; font-size: 1rem; }
.btn-icon { padding: 10px; border-radius: var(--r); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--sh-card); }
.card-glass {
  background: var(--bg-glass); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
}
.card-glow { box-shadow: var(--sh-glow); border-color: var(--border-glow); }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-soft); }
.form-input {
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); outline: none; }
.form-input::placeholder { color: var(--text-mute); }
.form-select {
  padding: 12px 16px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text); font-family: var(--font);
  font-size: 0.95rem; width: 100%; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b9bcf' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
  padding-right: 40px;
}
.form-select:focus { border-color: var(--blue); outline: none; }
.form-textarea { resize: vertical; min-height: 100px; }
.form-error { font-size: 0.825rem; color: var(--danger); }

/* ── Badges / Pills ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-active  { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.3); }
.badge-draft   { background: rgba(251,191,36,0.15); color: var(--amber); border: 1px solid rgba(251,191,36,0.3); }
.badge-paused  { background: rgba(251,146,60,0.15); color: #fb923c; border: 1px solid rgba(251,146,60,0.3); }
.badge-completed { background: rgba(59,130,246,0.15); color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }
.badge-new     { background: rgba(167,139,250,0.15); color: var(--purple); border: 1px solid rgba(167,139,250,0.3); }
.badge-qualified { background: rgba(34,211,238,0.15); color: var(--cyan); border: 1px solid rgba(34,211,238,0.3); }
.badge-converted { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.3); }
.badge-enterprise { background: var(--grad-brand); color: #fff; }
.badge-pro { background: rgba(124,58,237,0.2); color: var(--purple); border: 1px solid rgba(124,58,237,0.4); }
.badge-starter { background: rgba(59,130,246,0.15); color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-elev); }
th {
  padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px; font-size: 0.9rem; color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}
tbody tr { background: var(--bg-card); transition: background 0.15s; }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ── Stats ──────────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--space-6);
  transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--sh-card); }
.stat-value { font-size: 2.25rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-mute); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-note { font-size: 0.8rem; color: var(--text-mute); margin-top: 4px; }
.stat-delta { font-size: 0.8rem; font-weight: 600; margin-top: 4px; }
.stat-up { color: var(--green); }
.stat-down { color: var(--red); }

/* ── Navigation ──────────────────────────────────────────────────────────────── */
.nav-top {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(4,7,26,0.9); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; padding: 0 var(--space-6); max-width: 1440px; margin: 0 auto; }
.nav-logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.nav-logo:hover { color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link { padding: 8px 14px; border-radius: var(--r); font-size: 0.9rem; font-weight: 500; color: var(--text-soft); transition: all 0.15s; text-decoration: none; }
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--purple); background: rgba(124,58,237,0.12); }
.nav-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ── Sidebar (authenticated) ────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-header { padding: var(--space-5) var(--space-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-logo { font-weight: 900; font-size: 1.125rem; background: var(--grad-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-section { padding: var(--space-4) var(--space-3); }
.sidebar-section-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); font-weight: 700; padding: 0 var(--space-3); margin-bottom: var(--space-2); }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r); margin-bottom: 2px;
  font-size: 0.875rem; font-weight: 500; color: var(--text-soft);
  text-decoration: none; transition: all 0.15s;
}
.sidebar-link:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.sidebar-link.active { color: var(--purple); background: rgba(124,58,237,0.1); }
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header { padding: var(--space-7) var(--space-7) var(--space-6); border-bottom: 1px solid var(--border); background: var(--bg); }
.page-title { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-mute); font-size: 0.875rem; margin-top: 4px; }
.page-body { padding: var(--space-7); flex: 1; }

/* ── Grid backgrounds ───────────────────────────────────────────────────────── */
.bg-grid {
  background-image:
    linear-gradient(rgba(124,58,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}
.bg-radial {
  background: radial-gradient(ellipse at 60% 0%, rgba(124,58,237,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 0% 80%, rgba(37,99,235,0.08) 0%, transparent 50%);
}

/* ── Section spacing ────────────────────────────────────────────────────────── */
.section { padding: var(--space-10) 0; }
.section-sm { padding: var(--space-7) 0; }
.section-lg { padding: var(--space-11) 0; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.footer { background: var(--bg); border-top: 1px solid var(--border); padding: var(--space-9) 0 var(--space-7); }
.footer-grid { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: var(--space-8); margin-bottom: var(--space-8); }
.footer-col-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--text); margin-bottom: var(--space-4); }
.footer-link { display: block; color: var(--text-mute); font-size: 0.875rem; margin-bottom: var(--space-3); transition: color 0.15s; }
.footer-link:hover { color: var(--text-soft); }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; padding-top: var(--space-6); border-top: 1px solid var(--border); }
.footer-copy { font-size: 0.825rem; color: var(--text-mute); }

/* ── Marketing hero ─────────────────────────────────────────────────────────── */
.hero {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; position: relative; overflow: hidden;
  padding: var(--space-11) var(--space-6);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(124,58,237,0.2) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 30%, rgba(37,99,235,0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(52,211,153,0.06) 0%, transparent 45%);
  z-index: 0; filter: blur(60px);
}
.hero > * { position: relative; z-index: 1; }
.hero-eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: var(--r-pill); background: rgba(124,58,237,0.12); border: 1px solid rgba(124,58,237,0.3); font-size: 0.8rem; font-weight: 600; color: var(--purple); margin-bottom: var(--space-5); width: fit-content; }
.hero h1 { max-width: 14ch; margin-bottom: var(--space-5); }
.hero p { font-size: 1.125rem; max-width: 55ch; margin-bottom: var(--space-7); }
.hero-actions { display: flex; gap: var(--space-4); flex-wrap: wrap; }

/* ── Auth ────────────────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); background: var(--bg-deep); }
.auth-card { width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: var(--space-7); }
.auth-title { font-size: 1.5rem; font-weight: 800; text-align: center; margin-bottom: var(--space-2); }
.auth-sub { font-size: 0.875rem; text-align: center; color: var(--text-mute); margin-bottom: var(--space-6); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.auth-divider { display: flex; align-items: center; gap: var(--space-4); margin: var(--space-5) 0; color: var(--text-mute); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Toast / Alert ──────────────────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--r); font-size: 0.875rem; margin-bottom: var(--space-4); border: 1px solid; }
.alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: var(--green); }
.alert-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: var(--red); }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--amber); }
.alert-info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: var(--blue); }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-6); }
.tab { padding: 10px 18px; font-size: 0.875rem; font-weight: 500; color: var(--text-mute); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; border-radius: var(--r) var(--r) 0 0; }
.tab:hover { color: var(--text-soft); }
.tab.active { color: var(--purple); border-bottom-color: var(--purple); background: rgba(124,58,237,0.06); }

/* ── Progress bar ────────────────────────────────────────────────────────────── */
.progress { height: 6px; background: var(--bg-elev); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--grad-brand); border-radius: 3px; transition: width 0.5s ease; }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-7 { gap: var(--space-7); }
.gap-8 { gap: var(--space-8); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-mute); }
.text-soft { color: var(--text-soft); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--amber); }
.text-brand { color: var(--purple); }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-4xl { max-width: 56rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opacity-50 { opacity: 0.5; }
.rounded-full { border-radius: var(--r-pill); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .nav-links { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 2rem; }
  .page-body { padding: var(--space-5); }
  .page-header { padding: var(--space-5); }
  .hero { padding: var(--space-9) var(--space-5); }
  h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
  h2 { font-size: clamp(1.25rem, 3vw, 2rem); }
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 20px rgba(124,58,237,0.3); } 50% { box-shadow: 0 0 40px rgba(124,58,237,0.6); } }
.animate-fadeUp { animation: fadeUp 0.6s ease both; }
.animate-pulse { animation: pulse 2s ease infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-glow { animation: glow 2s ease infinite; }
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }