:root {
  --bg: #0b1020;
  --surface: #121a30;
  --surface-2: #182340;
  --border: rgba(148, 163, 184, 0.16);
  --text: #eef2ff;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top right, #162348 0%, var(--bg) 52%);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.brand-name {
  display: block;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-tag {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab, .nav-link-ext {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.nav-tab:hover, .nav-link-ext:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #fff;
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: rgba(148, 163, 184, 0.4); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: rgba(148, 163, 184, 0.45); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* Hero */
.hero {
  padding: 36px 0 24px;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 24px;
  align-items: center;
}

.pill-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.pill-badge.subtle {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.hero h1 {
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero-sub {
  color: var(--muted);
  font-size: 15px;
  max-width: 660px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
}

.stat-val {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.stat-lbl {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

/* Workspace */
.main-workspace {
  padding-bottom: 60px;
}

.tool-panel { display: none; }
.tool-panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel-header h2 { font-size: 22px; margin-bottom: 4px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* Calculator Layout */
.calc-grid {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 20px;
  align-items: start;
}

.fx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

.fx-pill input {
  width: 60px;
  background: transparent;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  outline: none;
}

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: #cbd5e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field input[type="number"],
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #fff;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
}

.field-hint { font-size: 11.5px; color: var(--accent); font-weight: 600; }

.slider-group { margin: 12px 0; }
.slider-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.slider-val { font-weight: 700; color: #93c5fd; }
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.sub-heading { font-size: 13px; color: #93c5fd; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.toggle-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

/* Results */
.results-col { display: flex; flex-direction: column; gap: 16px; }

.winner-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.18));
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.winner-label { font-size: 11.5px; font-weight: 700; color: #6ee7b7; text-transform: uppercase; letter-spacing: 0.05em; }
.winner-banner h3 { font-size: 22px; margin-top: 2px; }

.winner-metrics { display: flex; gap: 24px; flex-wrap: wrap; }
.wm-val { display: block; font-size: 21px; font-weight: 800; color: #fff; }
.wm-lbl { display: block; font-size: 11.5px; color: #cbd5e1; }

.platform-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.p-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.15s;
}

.p-card.best { border-color: rgba(16, 185, 129, 0.65); }
.p-card.loss { border-color: rgba(239, 68, 68, 0.55); }

.p-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.p-name { font-weight: 700; font-size: 15px; }
.p-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}
.p-badge.neg { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

.p-profit { font-size: 24px; font-weight: 800; margin-bottom: 2px; }
.p-profit.pos { color: #34d399; }
.p-profit.neg { color: #f87171; }
.p-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  margin-bottom: 10px;
}

.bar-seg-cogs { background: #60a5fa; }
.bar-seg-fee { background: #f59e0b; }
.bar-seg-ads { background: #a78bfa; }
.bar-seg-profit { background: #10b981; }

.p-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; font-weight: 600; color: #cbd5e1; }
.data-table th { color: var(--muted); font-size: 12px; background: rgba(255, 255, 255, 0.02); }
.data-table tr.row-highlight td { font-weight: 700; color: #fff; background: rgba(59, 130, 246, 0.08); }

/* Image Studio */
.drop-zone {
  margin-top: 16px;
  border: 2px dashed rgba(59, 130, 246, 0.45);
  border-radius: var(--radius);
  background: rgba(59, 130, 246, 0.05);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.16s;
}
.drop-zone.dragover { background: rgba(59, 130, 246, 0.14); border-color: var(--primary); }
.drop-icon { font-size: 34px; margin-bottom: 8px; }
.drop-zone h3 { margin-bottom: 6px; }
.drop-zone p { margin-bottom: 16px; }

.image-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.img-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.img-preview {
  height: 180px;
  background: repeating-conic-gradient(#1e293b 0% 25%, #0f172a 0% 50%) 50% / 16px 16px;
  display: grid;
  place-items: center;
  padding: 8px;
}
.img-preview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.img-meta { padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.img-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-sizes { color: #6ee7b7; }

/* Listing Auditor */
.listing-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.char-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: #93c5fd; }
.char-badge.over { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.score-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.score-big { font-size: 42px; font-weight: 800; line-height: 1; color: var(--accent); margin-top: 4px; }
.badge-stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.audit-block { margin-bottom: 16px; }
.audit-block h4 { font-size: 13.5px; margin-bottom: 8px; color: #e2e8f0; }
.kw-chip {
  display: inline-block;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 7px;
  margin: 3px 5px 3px 0;
  font-weight: 600;
}
.kw-ok { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.kw-miss { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.kw-warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

/* ROAS */
.roas-top-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.roas-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: center; }
.rkpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.rkpi-lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rkpi-val { display: block; font-size: 22px; font-weight: 800; color: #fff; }
.heatmap-table td.hm-good { background: rgba(16, 185, 129, 0.22); color: #a7f3d0; font-weight: 700; }
.heatmap-table td.hm-mid { background: rgba(245, 158, 11, 0.18); color: #fde68a; }
.heatmap-table td.hm-bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

/* Affiliate Section */
.affiliate-section { margin-top: 42px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.disclosure { font-size: 12px; color: var(--muted); }
.affiliate-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.aff-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.15s, border-color 0.15s;
}
.aff-card:hover { transform: translateY(-2px); border-color: rgba(59, 130, 246, 0.5); }
.aff-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.aff-name { font-weight: 800; font-size: 16px; }
.aff-badge { font-size: 11px; padding: 3px 7px; border-radius: 6px; background: rgba(59, 130, 246, 0.16); color: #93c5fd; font-weight: 600; }
.aff-desc { font-size: 12.5px; color: var(--muted); }

/* FAQ & Footer */
.faq-section { margin-top: 32px; }
.faq-section h2 { margin-bottom: 16px; font-size: 20px; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.faq-item h4 { font-size: 14.5px; margin-bottom: 6px; color: #e2e8f0; }
.faq-item p { font-size: 13px; color: var(--muted); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  font-size: 13px;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; }
.footer-links a:hover { color: #fff; }

/* Responsive */
@media (max-width: 980px) {
  .hero-inner, .calc-grid, .listing-grid, .roas-top-grid { grid-template-columns: 1fr; }
  .affiliate-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .platform-cards-grid, .affiliate-grid, .faq-grid, .hero-stats, .form-row-2, .form-row-3, .form-row-4 {
    grid-template-columns: 1fr;
  }
}
