:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #059669;
  --accent-hover: #047857;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;
  --err-bg: #fee2e2;
  --err-ink: #991b1b;
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* Topbar */
.topbar {
  background: #0f172a;
  color: #fff;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-ai {
  background: #2563eb;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 4px;
  vertical-align: middle;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.92rem;
}

.nav-links a {
  color: #cbd5e1;
  text-decoration: none;
}

.nav-links a:hover {
  color: #fff;
}

.status-pill {
  background: #1e293b;
  border: 1px solid #334155;
  color: #93c5fd;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
}

/* Hero */
.hero {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  padding: 48px 0 56px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 36px;
  align-items: center;
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(147, 197, 253, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.hero h1 {
  font-size: 2.35rem;
  line-height: 1.15;
  margin: 0 0 14px;
  letter-spacing: -0.03em;
}

.subtitle {
  color: #cbd5e1;
  font-size: 1.03rem;
  margin: 0 0 20px;
}

.hero-bullets {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.88rem;
  color: #a7f3d0;
}

/* Upload Card */
.upload-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.35);
}

.dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
}

.drop-icon {
  font-size: 1.7rem;
  margin-bottom: 6px;
}

.drop-title {
  font-weight: 700;
  font-size: 1rem;
}

.drop-sub {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.selected-file {
  margin-top: 10px;
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
}

.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.toggle-field small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.full-width {
  width: 100%;
}

.error-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--err-bg);
  color: var(--err-ink);
  font-size: 0.88rem;
}

.loading-bar {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--primary);
  font-weight: 600;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #bfdbfe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Results */
.results-section {
  padding: 36px 0 20px;
}

.results-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
}

.export-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.preset-select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 600;
}

.paywall-banner {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.unlocked-banner {
  background: var(--ok-bg);
  color: var(--ok-ink);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 18px;
}

/* Affiliate Cards */
.affiliate-card {
  background: var(--surface);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

.affiliate-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.affiliate-head h3 {
  margin: 0 0 4px;
  font-size: 1.08rem;
}

.affiliate-head p {
  margin: 0;
  font-size: 0.88rem;
}

.disclosure-pill {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.affiliate-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 960px) {
  .affiliate-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .affiliate-grid {
    grid-template-columns: 1fr;
  }
}

.aff-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.aff-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #047857;
  background: #d1fae5;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.aff-title {
  font-weight: 800;
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.aff-desc {
  font-size: 0.82rem;
  color: var(--muted);
}

.aff-cta {
  display: block;
  text-align: center;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 7px;
}

.aff-cta:hover {
  background: var(--primary);
}

.affiliate-disclosure {
  margin-top: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.kpi-val {
  font-size: 2rem;
  font-weight: 800;
  margin: 4px 0;
  color: var(--ink);
}

.kpi-foot {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

/* Calculator */
.calculator-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

@media (max-width: 800px) {
  .calculator-card {
    grid-template-columns: 1fr;
  }
}

.calculator-card h3 {
  margin: 0 0 6px;
}

.calc-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.savings-box {
  background: linear-gradient(135deg, #065f46 0%, #047857 100%);
  color: #fff;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.savings-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.savings-amount {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 6px 0;
}

.savings-sub {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* Tabs */
.tabs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #f1f5f9;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  margin: 2px 4px 2px 0;
  background: #dcfce7;
  color: #166534;
}

.pill.warn {
  background: #fee2e2;
  color: #991b1b;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.map-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  font-size: 0.86rem;
}

/* Pricing */
.pricing {
  padding: 48px 0 64px;
}

.section-center {
  text-align: center;
  margin-bottom: 28px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 850px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
}

.price-card.featured {
  border: 2px solid var(--primary);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.12);
}

.popular-tag {
  position: absolute;
  top: -11px;
  right: 18px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}

.price-tier {
  font-weight: 700;
  color: var(--muted);
}

.price-amount {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 8px 0 14px;
}

.price-amount span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

.price-card ul {
  padding-left: 18px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.price-card li {
  margin-bottom: 6px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
}

.modal-card {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 94%;
  max-width: 520px;
  z-index: 1;
}

.modal-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.checkout-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  background: #f8fafc;
}

.checkout-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.ext-pay-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ext-pay-btn {
  font-size: 0.84rem;
  padding: 9px 10px;
}

.license-row {
  display: flex;
  gap: 8px;
}

.license-input {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
}

.license-msg {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--err-ink);
}

.demo-notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.84rem;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
