/* =====================================================================
   ABForge -- core design system.
   Brand:  #ff7a3d (sunset)  +  #ffb347 (peach)
   Primary CTA: #5aa9ff (blue) -- per Shawn's UX rule (red = warnings only)
   Background: deep slate with subtle gradient panels
===================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #e7ebf3;
  background: #0c1018;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --brand:        #ff7a3d;
  --brand-2:      #ffb347;
  --brand-glow:   rgba(255, 122, 61, 0.35);
  --accent:       #5aa9ff;          /* primary CTAs */
  --accent-hover: #79b8ff;
  --accent-2:     #2a313d;          /* secondary CTAs */
  --bg:           #0c1018;
  --bg-2:         #131826;
  --bg-3:         #1b2236;
  --bg-card:      #161c2d;
  --bg-elevated:  #1f263a;
  --line:         #2a3145;
  --line-soft:    #20273b;
  --text:         #e7ebf3;
  --text-soft:    #b0b8cc;
  --text-mute:    #7a8499;
  --good:         #3ecf8e;
  --warn:         #ffb547;
  --bad:          #ff5566;          /* RED reserved for destructive only */
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- App shell -------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.18s;
}
.sidebar {
  background: linear-gradient(180deg, #0e1320 0%, #0a0e18 100%);
  border-right: 1px solid var(--line-soft);
  padding: 18px 12px 18px 14px;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  padding: 6px 6px 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; color: #0a0e18;
  box-shadow: 0 6px 20px var(--brand-glow);
}
.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.4px;
}

.sb-section {
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-mute);
  margin: 18px 8px 6px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}
.sb-item:hover { background: var(--bg-3); color: var(--text); }
.sb-item.is-active {
  background: linear-gradient(90deg, rgba(255,122,61,0.18), rgba(255,179,71,0.08));
  color: #fff;
  position: relative;
}
.sb-item.is-active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}
.sb-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-icon svg { width: 18px; height: 18px; }

/* ---------- Topbar ------------------------------------------------ */
.topbar {
  background: rgba(12, 16, 24, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.page-title { font-size: 15px; font-weight: 600; color: var(--text); }

.site-picker {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 8px;
  color: var(--text-soft);
  font-size: 13px;
}
.site-picker select {
  background: transparent; border: 0; color: var(--text);
  font-size: 13px; padding: 4px; outline: none;
}
.site-picker select option { background: var(--bg-3); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  color: #0a0e18; font-weight: 700; font-size: 13px;
  cursor: pointer;
}

.impersonation-banner {
  background: linear-gradient(90deg, #ff5566, #ff8088);
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}

/* ---------- Content area ----------------------------------------- */
.app-content {
  padding: 28px 32px 80px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px; font-weight: 700; margin: 0;
  color: #fff; letter-spacing: 0.2px;
}
.page-header p { color: var(--text-mute); margin: 4px 0 0; font-size: 13px; }

/* ---------- Buttons --------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s, transform 0.08s, box-shadow 0.14s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #0a0e18;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(90,169,255,0.25);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #0a0e18; }

.btn-brand {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #1a0e08;
  border-color: var(--brand);
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-brand:hover { filter: brightness(1.06); color: #1a0e08; }

.btn-secondary {
  background: var(--accent-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover { background: #353d4d; }

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }

.btn-danger {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}
.btn-danger:hover { filter: brightness(1.1); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

/* ---------- Cards ------------------------------------------------ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 14px; color: #fff;
  margin: 0;
}
.card-sub { font-size: 12px; color: var(--text-mute); margin: 0; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--brand-glow), transparent 60%);
  opacity: 0.5; pointer-events: none;
}
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-mute); font-weight: 600;
}
.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px; font-weight: 700; color: #fff;
  margin-top: 6px;
}
.kpi-delta { font-size: 12px; margin-top: 4px; color: var(--text-mute); }
.kpi-delta.up { color: var(--good); }
.kpi-delta.down { color: var(--warn); }

/* Tables */
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th, .table td {
  text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.table th { color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; font-size: 11px; }
.table tr:hover td { background: rgba(255,255,255,0.02); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }

.bar-cell { position: relative; min-width: 120px; }
.bar-cell .bar {
  height: 22px; border-radius: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  opacity: 0.85;
}
.bar-cell .bar.alt { background: linear-gradient(90deg, var(--accent), #8ec5ff); }

/* Forms */
.form-row { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-soft); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,169,255,0.15);
}
.form-help { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.form-textarea { font-family: 'JetBrains Mono', Menlo, Consolas, monospace; font-size: 12.5px; min-height: 120px; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-soft);
  border: 1px solid var(--line);
}
.badge.running { background: rgba(62, 207, 142, 0.15); color: var(--good); border-color: rgba(62, 207, 142, 0.3); }
.badge.draft   { background: var(--bg-elevated); color: var(--text-mute); }
.badge.paused  { background: rgba(255, 181, 71, 0.15); color: var(--warn); border-color: rgba(255, 181, 71, 0.3); }
.badge.complete{ background: rgba(90, 169, 255, 0.15); color: var(--accent); border-color: rgba(90,169,255,0.3); }
.badge.brand   { background: var(--brand-glow); color: var(--brand-2); border-color: var(--brand); }

/* Code snippet */
.snippet {
  background: #0a0d14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #d8e0ee;
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0 12px;
}
.snippet-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

/* Charts */
.chart-wrap { padding: 6px 0; }
.chart-canvas { width: 100%; height: 100%; }

/* Marketing pages */
.marketing-shell {
  display: flex; flex-direction: column; min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 122, 61, 0.15), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(90,169,255,0.10), transparent 60%),
    var(--bg);
}
.marketing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  position: sticky; top: 0;
  background: rgba(12, 16, 24, 0.7);
  backdrop-filter: blur(10px);
  z-index: 50;
  border-bottom: 1px solid var(--line-soft);
}
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-link {
  color: var(--text-soft); font-weight: 500;
  font-size: 14px;
}
.nav-link:hover { color: #fff; }

.hero {
  padding: 70px 24px 90px;
  text-align: center;
  max-width: 980px; margin: 0 auto;
}
.hero-eyebrow {
  display: inline-block;
  background: var(--brand-glow);
  border: 1px solid rgba(255, 122, 61, 0.4);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--brand-2);
  margin-bottom: 24px;
}
.hero-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 56px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1px;
  margin: 0 0 18px;
  background: linear-gradient(180deg, #fff 0%, #b0b8cc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-title .brand-grad {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  font-size: 18px; color: var(--text-soft);
  max-width: 720px; margin: 0 auto 36px;
}
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-meta { color: var(--text-mute); font-size: 13px; margin-top: 18px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  padding: 40px 24px 80px;
  max-width: 1100px;
  margin: 0 auto;
}
.feature {
  background: rgba(22, 28, 45, 0.7);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.feature-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.feature-icon svg { width: 24px; height: 24px; color: #1a0e08; }
.feature h3 { margin: 0 0 6px; font-family: 'Space Grotesk', sans-serif; font-size: 17px; color: #fff; }
.feature p { margin: 0; color: var(--text-soft); font-size: 13.5px; line-height: 1.55; }

/* Pricing */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px 80px;
}
.plan {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 28px 24px;
  position: relative;
}
.plan.featured {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 20px 60px rgba(255, 122, 61, 0.15);
  transform: scale(1.02);
}
.plan-name { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; color: var(--brand-2); margin: 0; }
.plan-tag { color: var(--text-mute); font-size: 12.5px; margin: 4px 0 18px; min-height: 32px; }
.plan-price { font-family: 'Space Grotesk', sans-serif; font-size: 38px; font-weight: 700; color: #fff; line-height: 1; }
.plan-price .per { font-size: 13px; color: var(--text-mute); font-weight: 500; margin-left: 4px; }
.plan-feats { list-style: none; padding: 18px 0 22px; margin: 0; }
.plan-feats li { font-size: 13px; padding: 5px 0; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }
.plan-feats li.no { color: var(--text-mute); opacity: 0.6; }
.plan-feats li::before { content: '✓'; color: var(--good); font-weight: 700; }
.plan-feats li.no::before { content: '·'; color: var(--text-mute); }

/* Auth forms */
.auth-box {
  max-width: 420px; margin: 60px auto;
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 32px;
}
.auth-box h1 {
  margin: 0 0 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px; color: #fff;
}
.auth-box p.sub { color: var(--text-mute); font-size: 13px; margin: 0 0 22px; }
.auth-box .err { background: rgba(255,85,102,0.15); color: var(--bad); border: 1px solid rgba(255,85,102,0.3); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.auth-box .ok { background: rgba(62,207,142,0.15); color: var(--good); border: 1px solid rgba(62,207,142,0.3); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.auth-box .btn { width: 100%; justify-content: center; }
.auth-foot { text-align: center; color: var(--text-mute); font-size: 13px; margin-top: 14px; }

/* Footer */
.marketing-foot {
  margin-top: auto;
  border-top: 1px solid var(--line-soft);
  padding: 32px 24px;
  text-align: center;
  color: var(--text-mute);
  font-size: 12.5px;
}

/* Tabs */
.tabs {
  display: flex; gap: 6px; border-bottom: 1px solid var(--line-soft);
  margin-bottom: 22px; padding: 0 4px;
}
.tab {
  padding: 9px 16px; color: var(--text-mute); font-size: 13px; font-weight: 600;
  border: 0; background: transparent; cursor: pointer; border-bottom: 2px solid transparent;
  text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-2); border-bottom-color: var(--brand); }

/* Util */
.row { display: flex; gap: 16px; align-items: stretch; }
.row > * { flex: 1; }
.row-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.muted { color: var(--text-mute); }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; }
.text-mute { color: var(--text-mute); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.copy-btn { cursor: pointer; }

/* Responsive */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero-title { font-size: 36px; }
  .pricing-grid { grid-template-columns: 1fr; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}
