:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --fg: #0f172a;
  --muted: #475569;
  --brand: #1c69d4;
  --brand-strong: #1553ad;
  --brand-soft: #eff6ff;
  --accent: #4f46e5;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #1f2937;
  --border-strong: #334155;
  --fg: #f8fafc;
  --muted: #94a3b8;
  --brand: #3b82f6;
  --brand-strong: #2563eb;
  --brand-soft: rgba(59, 130, 246, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
}
.accent-bar { height: 4px; background: linear-gradient(90deg, var(--brand), var(--accent), #0ea5e9); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0.75rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 0.95rem;
}
.brand-title { font-weight: 800; font-size: 1rem; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.76rem; color: var(--muted); }
.nav-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 3.5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.58rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg); font-weight: 600; font-size: 0.88rem;
  text-decoration: none; cursor: pointer; transition: 150ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }

.badge {
  display: inline-flex; align-items: center; padding: 0.22rem 0.65rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow);
}
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.75fr); gap: 1.5rem; align-items: center;
  margin-bottom: 1.4rem;
}
.hero h1 { margin: 0.45rem 0 0.6rem; font-size: clamp(1.55rem, 2.8vw, 2.25rem); line-height: 1.15; letter-spacing: -0.03em; }
.hero p { margin: 0; color: var(--muted); font-size: 0.98rem; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1rem; }
.metric-label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.metric-val { font-size: 1.35rem; font-weight: 800; margin-top: 0.15rem; }

.section-head { margin: 2rem 0 0.9rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.section-head p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.tabs { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab-btn {
  padding: 0.55rem 0.95rem; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg); font-weight: 600; font-size: 0.84rem; cursor: pointer;
}
.tab-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.sandbox-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 1.1rem; }
@media (max-width: 860px) { .sandbox-grid { grid-template-columns: 1fr; } }

.field-label { display: block; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.35rem; }
textarea, input[type="number"], input[type="text"], select {
  width: 100%; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--fg);
  font-family: inherit; font-size: 0.88rem;
}
pre.code-out {
  margin: 0; padding: 0.85rem; border-radius: var(--radius-sm); background: #0f172a; color: #e2e8f0;
  font-size: 0.78rem; overflow-x: auto; max-height: 290px; line-height: 1.45;
}
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; margin-top: 0.6rem; }
table.data-table th, table.data-table td {
  padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left;
}
table.data-table th { color: var(--muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(265px, 1fr)); gap: 1rem; }
.offer-card { display: flex; flex-direction: column; justify-content: space-between; gap: 0.9rem; }
.offer-card.featured { border: 2px solid var(--brand); }
.price-line { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.price-sub { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.check-list { margin: 0.6rem 0 0; padding-left: 1.15rem; font-size: 0.85rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.32rem; }

.chat-box { display: flex; flex-direction: column; gap: 0.55rem; max-height: 280px; overflow-y: auto; padding: 0.75rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.bubble { padding: 0.55rem 0.8rem; border-radius: 10px; font-size: 0.84rem; max-width: 88%; }
.bubble.user { align-self: flex-end; background: var(--brand); color: #fff; }
.bubble.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border-strong); color: var(--fg); }

.footer {
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-size: 0.83rem; color: var(--muted);
}
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 1.2rem; }
.footer h4 { margin: 0 0 0.5rem; color: var(--fg); font-size: 0.88rem; }
.footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--brand); text-decoration: underline; }

.sticky-cro-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
  padding: 0.65rem 1.25rem;
}
.sticky-cro-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
body.has-sticky-cro { padding-bottom: 4.75rem; }
.quick-answer-box {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--brand);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
}
.hidden { display: none !important; }
