:root {
  --bg-base:        #060D1F;
  --bg-surface:     #0D1530;
  --bg-elevated:    #1A2545;
  --border:         #243058;
  --text-primary:   #FFFFFF;
  --text-secondary: #8A9BC0;
  --text-muted:     #4A5878;
  --accent-blue:    #38C4F0;
  --accent-violet:  #7C5CE6;
  --gradient:       linear-gradient(135deg, #38C4F0, #7C5CE6);
  --success:        #2DD4A0;
  --warning:        #F0A038;
  --danger:         #F05858;
  --sidebar-width:  240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 128px;
  pointer-events: none;
  z-index: 0;
}

h1,h2,h3,h4 { font-family: 'Space Grotesk', sans-serif; }

/* ── TYPOGRAPHY ── */
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-blue);
}
.muted { color: var(--text-muted); font-size: 13px; }

/* ── LOGO ── */
.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.logo-x { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.logo-x-wrap { position: relative; display: inline-block; }
.logo-node { position: absolute; top: 3px; right: -6px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent-blue); box-shadow: 0 0 5px var(--accent-blue); }

/* ── PORTAL LAYOUT ── */
.portal-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10;
  padding: 0;
}
.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-client-info {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-client-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.sidebar-client-company {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms, background 150ms;
  position: relative;
}
.nav-item:hover { color: var(--text-primary); background: rgba(56,196,240,0.04); }
.nav-item.active { color: var(--accent-blue); background: rgba(56,196,240,0.08); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--gradient);
  border-radius: 0 2px 2px 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent-blue);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 150ms;
}
.logout-btn:hover { color: var(--danger); }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-width));
}
.page-header {
  margin-bottom: 32px;
}
.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-secondary); font-size: 14px; }

/* ── CARDS ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  transition: border-color 200ms;
}
.card:hover { border-color: rgba(56,196,240,0.2); }
.card-accent { position: relative; overflow: hidden; }
.card-accent::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-violet), transparent);
  opacity: 0.5;
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
}
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label { font-size: 12px; color: var(--text-muted); font-family: 'Space Grotesk', sans-serif; letter-spacing: 0.04em; text-transform: uppercase; }
.stat-delta { font-size: 11px; margin-top: 6px; font-family: 'Space Grotesk', sans-serif; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── BUTTONS ── */
.btn-primary {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(56,196,240,0.2);
  transition: transform 150ms, box-shadow 150ms;
  display: inline-block;
  text-decoration: none;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(56,196,240,0.3); }
.btn-secondary {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
  display: inline-block;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--accent-blue); background: rgba(56,196,240,0.06); }
.btn-sm { font-size: 11px; padding: 6px 12px; }

/* ── STATUS PILLS ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.pill-success { background: rgba(45,212,160,0.1); border: 1px solid rgba(45,212,160,0.25); color: var(--success); }
.pill-warning { background: rgba(240,160,56,0.1); border: 1px solid rgba(240,160,56,0.25); color: var(--warning); }
.pill-danger  { background: rgba(240,88,88,0.1); border: 1px solid rgba(240,88,88,0.25); color: var(--danger); }
.pill-blue    { background: rgba(56,196,240,0.08); border: 1px solid rgba(56,196,240,0.2); color: var(--accent-blue); }
.pill-muted   { background: rgba(74,88,120,0.2); border: 1px solid rgba(74,88,120,0.3); color: var(--text-muted); }

/* ── PHASE STEPPER ── */
.phase-stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 40px;
  position: relative;
}
.phase-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.phase-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.phase-step.done:not(:last-child)::after,
.phase-step.active:not(:last-child)::after {
  background: linear-gradient(90deg, var(--accent-blue), var(--border));
}
.phase-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 200ms;
}
.phase-step.done .phase-dot {
  background: rgba(45,212,160,0.15);
  border-color: var(--success);
  color: var(--success);
}
.phase-step.active .phase-dot {
  background: rgba(56,196,240,0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(56,196,240,0.3);
}
.phase-label {
  margin-top: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.phase-step.active .phase-label { color: var(--accent-blue); }
.phase-step.done .phase-label { color: var(--success); }

/* ── PHASE CARDS ── */
.phase-cards { display: flex; flex-direction: column; gap: 12px; }
.phase-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  transition: border-color 200ms;
}
.phase-card.active-phase { border-color: rgba(56,196,240,0.3); background: rgba(56,196,240,0.03); }
.phase-card.done-phase { opacity: 0.7; }
.phase-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.phase-card-title { font-family: 'Space Grotesk', sans-serif; font-size: 14px; font-weight: 600; }
.phase-card-body { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.phase-feedback-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms;
}
.phase-feedback-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.feedback-form { margin-top: 12px; display: none; }
.feedback-form.open { display: block; }
.feedback-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  margin-bottom: 8px;
  outline: none;
  transition: border-color 150ms;
}
.feedback-textarea:focus { border-color: var(--accent-blue); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(36,48,88,0.5);
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(56,196,240,0.02); }
.td-primary { color: var(--text-primary); font-family: 'Space Grotesk', sans-serif; font-weight: 500; }

/* ── MESSAGES ── */
.message-thread { display: flex; flex-direction: column; gap: 16px; max-height: 480px; overflow-y: auto; padding-right: 4px; }
.message-bubble {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}
.message-bubble.from-admin { align-self: flex-start; }
.message-bubble.from-client { align-self: flex-end; align-items: flex-end; }
.bubble-body {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
}
.from-admin .bubble-body { background: var(--bg-elevated); border: 1px solid var(--border); border-top-left-radius: 4px; color: var(--text-secondary); }
.from-client .bubble-body { background: rgba(56,196,240,0.12); border: 1px solid rgba(56,196,240,0.2); border-top-right-radius: 4px; color: var(--text-primary); }
.bubble-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: 'Space Grotesk', sans-serif; }
.message-input-area { margin-top: 20px; display: flex; gap: 10px; align-items: flex-end; }
.message-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  resize: none;
  min-height: 48px;
  outline: none;
  transition: border-color 150ms;
}
.message-input:focus { border-color: var(--accent-blue); }

/* ── API KEYS ── */
.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(36,48,88,0.5);
}
.key-row:last-child { border-bottom: none; }
.key-service { font-family: 'Space Grotesk', sans-serif; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.key-masked { font-family: 'Space Grotesk', sans-serif; font-size: 12px; color: var(--text-muted); letter-spacing: 0.1em; }

/* ── FORM INPUTS ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 150ms;
}
.form-input:focus { border-color: var(--accent-blue); }
.form-input::placeholder { color: var(--text-muted); }

/* ── CHART CONTAINER ── */
.chart-wrap {
  position: relative;
  height: 260px;
}

/* ── CALENDLY EMBED ── */
.calendly-placeholder {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.login-glow {
  position: fixed;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56,196,240,0.08) 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.demo-creds {
  background: rgba(56,196,240,0.06);
  border: 1px solid rgba(56,196,240,0.15);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 12px;
  font-family: 'Space Grotesk', sans-serif;
}
.demo-creds .cred-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.demo-creds .cred-row:last-child { margin-bottom: 0; }
.demo-creds .cred-key { color: var(--text-muted); }
.demo-creds .cred-val { color: var(--accent-blue); font-weight: 600; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
