:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: #e0f2fe;
  --green: #059669;
  --green-soft: #d1fae5;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --rose: #e11d48;
  --rose-soft: #ffe4e6;
  --violet: #7c3aed;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --max-w: 1040px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-alt: #1e293b;
  --border: #1f2937;
  --border-strong: #334155;
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-soft: rgba(56, 189, 248, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.15);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.15);
  --violet: #a78bfa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.25);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
  font-size: 1.02rem;
  color: var(--text);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

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

.nav-links a {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 550;
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-links a.active {
  color: var(--primary);
  font-weight: 650;
}

.theme-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Breadcrumbs & Hero */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-soft);
  margin: 18px 0 6px;
  flex-wrap: wrap;
}

.hero {
  padding: 18px 0 16px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 68ch;
  font-size: 1rem;
}

.meta-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.meta-pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Calculator Workspace */
.calc-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
  margin: 12px 0 28px;
}

@media (max-width: 820px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

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

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

/* Mode tabs & preset chips */
.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 14px;
  width: 100%;
}

.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.preset-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.field small {
  font-size: 0.76rem;
  color: var(--text-soft);
}

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

.input-prefix,
.input-suffix {
  position: absolute;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
  pointer-events: none;
}

.input-prefix {
  left: 11px;
}

.input-suffix {
  right: 11px;
}

input[type="number"],
select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 550;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input.has-prefix {
  padding-left: 26px;
}

input.has-suffix {
  padding-right: 30px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.86rem;
  font-weight: 550;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Output Panel */
.kpi-hero {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.kpi-value {
  font-size: clamp(1.9rem, 3.6vw, 2.45rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 2px 0;
  color: var(--green);
}

.kpi-value.negative {
  color: var(--rose);
}

.kpi-sub {
  font-size: 0.87rem;
  color: var(--text-muted);
}

/* Stacked distribution bar */
.bar-wrap {
  margin: 14px 0 16px;
}

.stacked-bar {
  display: flex;
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

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

.bar-net { background: var(--green); }
.bar-platform { background: var(--primary); }
.bar-processing { background: var(--amber); }
.bar-extra { background: var(--rose); }

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 4px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.9rem;
}

.breakdown-row.total {
  border-top: 1px dashed var(--border-strong);
  padding-top: 8px;
  margin-top: 4px;
  font-weight: 700;
}

.breakdown-row .val {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.val-fee { color: var(--rose); }
.val-net { color: var(--green); }

.callout {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  background: var(--primary-soft);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
}

.callout.good {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 30%, transparent);
}

.callout.warn {
  background: var(--amber-soft);
  border-color: color-mix(in srgb, var(--amber) 35%, transparent);
}

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--primary);
}

/* Hub platform cards & comparison table */
.hub-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
  margin: 16px 0 28px;
}

.platform-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.14s, border-color 0.14s;
  text-decoration: none;
  color: var(--text);
}

.platform-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  text-decoration: none;
}

.platform-card h2 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tag {
  font-size: 0.73rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--text-muted);
}

.platform-card p {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.platform-rate {
  font-size: 0.83rem;
  font-weight: 650;
  color: var(--primary);
}

/* Content / Formula / FAQ sections */
.content-section {
  margin: 26px 0;
}

.content-section h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
  letter-spacing: -0.015em;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-alt);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-soft);
}

tr:last-child td {
  border-bottom: 0;
}

.faq-list {
  display: grid;
  gap: 10px;
}

details.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

details.faq-item summary {
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

details.faq-item summary::after {
  content: "+";
  color: var(--text-soft);
  font-weight: 700;
}

details.faq-item[open] summary::after {
  content: "−";
}

details.faq-item p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Footer */
.site-footer {
  margin-top: 44px;
  border-top: 1px solid var(--border);
  padding: 24px 0 36px;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
