:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;

  --brand: #0f766e;
  --brand-hover: #0d625b;
  --brand-soft: #f0fdfa;
  --brand-border: #99f6e4;

  --accent: #2563eb;
  --accent-soft: #eff6ff;

  --profit: #059669;
  --profit-bg: #ecfdf5;
  --profit-border: #a7f3d0;

  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --fee-platform: #ea580c;
  --fee-tax: #7c3aed;
  --fee-ads: #0284c7;
  --fee-cogs: #64748b;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, 0.16);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select {
  font-family: inherit;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f766e 0%, #059669 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.pill-year {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}

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

.nav-links a {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-secondary);
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.nav-cta {
  background: var(--ink) !important;
  color: #fff !important;
  padding: 8px 14px !important;
}

.nav-cta:hover {
  background: #1e293b !important;
}

/* Hero */
.hero {
  padding: 28px 0 20px;
}

.hero-card {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-md);
}

.hero-text {
  max-width: 720px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #99f6e4;
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.94rem;
}

.hero-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 118px;
}

.hero-stat strong {
  display: block;
  font-size: 1.08rem;
  color: #fff;
}

.hero-stat span {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.78);
}

/* Mode tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.mode-tab {
  border: none;
  background: transparent;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.mode-tab:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.mode-tab.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.28);
}

/* Main Grid */
.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.15fr);
  gap: 20px;
  align-items: start;
}

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

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 1.02rem;
  font-weight: 800;
}

/* Platform pills */
.platform-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.platform-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.platform-btn:hover {
  border-color: var(--border-strong);
}

.platform-btn.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

/* Form controls */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.field label small {
  color: var(--ink-muted);
  font-weight: 500;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input,
.field select {
  width: 100%;
  height: 42px;
  padding: 8px 46px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field select {
  padding-right: 12px;
  cursor: pointer;
}

.input-wrap input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.input-unit {
  position: absolute;
  right: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-muted);
  pointer-events: none;
}

.section-divider {
  margin: 18px 0 14px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-divider span {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip-toggle {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink-secondary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-toggle.active {
  background: #ffedd5;
  border-color: #fdba74;
  color: #c2410c;
}

/* Switch */
.tax-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 6px;
}

.tax-box strong {
  display: block;
  font-size: 0.86rem;
  color: #5b21b6;
}

.tax-box p {
  margin: 3px 0 0;
  font-size: 0.77rem;
  color: #6d28d9;
  line-height: 1.4;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background: #7c3aed;
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* Reverse target toggle */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--ink-secondary);
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Result status banner */
.status-banner {
  border-radius: var(--radius-md);
  padding: 18px 20px;
  border: 1.5px solid var(--profit-border);
  background: var(--profit-bg);
  margin-bottom: 16px;
  transition: all 0.2s;
}

.status-banner.status-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.status-banner.status-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.status-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.status-pill {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
}

.status-good .status-pill { color: var(--profit); }
.status-warn .status-pill { color: var(--warn); }
.status-danger .status-pill { color: var(--danger); }

.big-profit {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.status-good .big-profit { color: #047857; }
.status-warn .big-profit { color: #b45309; }
.status-danger .big-profit { color: #b91c1c; }

.status-sub {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--ink-secondary);
  font-weight: 500;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.kpi-item {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.kpi-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.kpi-note {
  font-size: 0.73rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Stacked bar breakdown */
.bar-section {
  margin-bottom: 16px;
}

.bar-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.stacked-bar {
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #e2e8f0;
  margin-bottom: 10px;
}

.bar-seg {
  height: 100%;
  transition: width 0.25s ease;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.76rem;
  color: var(--ink-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* Breakdown Table */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.breakdown-table tr {
  border-bottom: 1px solid var(--border);
}

.breakdown-table td {
  padding: 8px 4px;
}

.breakdown-table td:last-child {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.breakdown-table tr.row-total td {
  padding-top: 11px;
  font-weight: 800;
  font-size: 0.92rem;
  border-bottom: none;
}

.neg { color: var(--danger); }
.pos { color: var(--profit); }

/* Action buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-dark {
  background: var(--ink);
  color: #fff;
}

.btn-dark:hover {
  background: #1e293b;
}

.btn-outline {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-outline:hover {
  background: var(--surface-soft);
}

/* Compare / Reverse highlight cards */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.scenario-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.scenario-card.featured {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.scenario-card small {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.scenario-card strong {
  display: block;
  font-size: 1.06rem;
  margin: 4px 0 2px;
  color: var(--ink);
}

.scenario-card span {
  font-size: 0.75rem;
  color: var(--profit);
  font-weight: 700;
}

/* Range input */
.range-wrap {
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.range-wrap input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
  margin: 8px 0 4px;
}

.savings-box {
  background: linear-gradient(135deg, #065f46 0%, #0f766e 100%);
  color: #fff;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

.savings-box small {
  color: #a7f3d0;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
}

.savings-big {
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  font-weight: 800;
  margin: 4px 0;
}

.savings-box p {
  margin: 0 0 14px;
  font-size: 0.87rem;
  color: rgba(255, 255, 255, 0.9);
}

/* Saved SKU table */
.section-block {
  margin-top: 26px;
}

.table-scroll {
  overflow-x: auto;
}

.sku-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sku-table th,
.sku-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sku-table th {
  background: var(--surface-soft);
  color: var(--ink-secondary);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.badge-profit {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.76rem;
}

.badge-good { background: var(--profit-bg); color: var(--profit); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-loss { background: var(--danger-bg); color: var(--danger); }

/* Promo cards (Excel Pro & Studio) */
.promo-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  margin-top: 26px;
}

.promo-pro {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdfa 100%);
  border: 2px solid var(--brand);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
}

.promo-studio {
  background: #0f172a;
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.promo-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.tag-teal { background: var(--brand); color: #fff; }
.tag-amber { background: #f59e0b; color: #0f172a; }

.promo-pro h2,
.promo-studio h2 {
  margin: 0 0 8px;
  font-size: 1.32rem;
  line-height: 1.3;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 18px;
}

.check-list li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 8px;
  font-size: 0.89rem;
}

.check-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 800;
  color: var(--profit);
}

.promo-studio .check-list li::before {
  color: #34d399;
}

.price-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.price-now {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--brand);
}

.price-old {
  font-size: 0.95rem;
  color: var(--ink-muted);
  text-decoration: line-through;
}

/* FAQ */
.faq-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.faq-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
}

.faq-item h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--ink);
}

.faq-item p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-secondary);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
}

.qr-frame {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  margin: 14px 0;
}

.qr-frame img {
  max-width: 240px;
  width: 100%;
  border-radius: 10px;
  background: #fff;
}

.bank-info {
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.86rem;
  margin-bottom: 14px;
}

.bank-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.config-alert {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-size: 0.8rem;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s;
  z-index: 120;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

footer {
  margin-top: 38px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .calc-grid,
  .promo-grid,
  .faq-grid {
    grid-template-columns: 1fr;
  }
  .nav-links a:not(.nav-cta) {
    display: none;
  }
}

@media (max-width: 600px) {
  .mode-tabs {
    grid-template-columns: 1fr;
  }
  .form-grid-2,
  .scenario-grid {
    grid-template-columns: 1fr;
  }
  .hero-card {
    padding: 20px 18px;
  }
  .card {
    padding: 16px;
  }
}
