:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --profit: #16a34a;
  --loss: #dc2626;
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px;
  /* breakdown segment colors */
  --c-cogs: #0ea5e9;
  --c-platformFee: #8b5cf6;
  --c-fulfillment: #f59e0b;
  --c-returnFreight: #ef4444;
  --c-adSpend: #ec4899;
  --c-netProfit: #16a34a;
  --c-netLoss: #dc2626;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* Topbar */
.topbar {
  background: linear-gradient(120deg, #052e16, #166534 60%, #15803d);
  color: #fff;
  padding: 14px 0;
  box-shadow: var(--shadow);
}
.topbar-inner { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,.16); font-weight: 700; font-size: 16px;
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: rgba(255,255,255,.78); font-size: 13.5px; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  gap: 18px;
  padding-top: 22px;
  padding-bottom: 22px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.results { position: sticky; top: 16px; }
@media (max-width: 860px) {
  .results { position: static; }
}

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; margin: 0; color: var(--ink); font-weight: 700; }

.ghost-btn {
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  transition: .15s;
}
.ghost-btn:hover { border-color: var(--brand); color: var(--brand); }

/* Presets + fields */
.presets { margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; background: #fff; color: var(--ink); cursor: pointer;
}
.select:focus { outline: 2px solid rgba(22,163,74,.35); border-color: var(--brand); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
@media (max-width: 460px) { .field-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; }
.field .lbl { font-size: 12.5px; color: var(--ink); font-weight: 600; margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.field .lbl .info { color: var(--muted); cursor: help; font-weight: 400; font-size: 12px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input {
  width: 100%; padding: 9px 30px 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; color: var(--ink); background: #fff;
  font-variant-numeric: tabular-nums;
}
.input-wrap input:focus { outline: 2px solid rgba(22,163,74,.30); border-color: var(--brand); }
.input-wrap .unit { position: absolute; right: 11px; color: var(--muted); font-size: 12.5px; pointer-events: none; }

/* Toggle */
.toggle-row { display: flex; align-items: center; gap: 11px; margin-top: 16px; padding: 11px 13px; background: #f8fafc; border: 1px solid var(--line); border-radius: 11px; }
.toggle-text { font-size: 13px; color: var(--ink); }
.toggle-text small { display: block; color: var(--muted); font-size: 11.5px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 24px; transition: .2s; cursor: pointer; }
.switch-slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-slider { background: var(--brand); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* Scenarios */
.scenarios { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.scenario-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.scenario-btn {
  text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; cursor: pointer; font-size: 12.5px; color: var(--ink); transition: .15s; flex: 1 1 calc(50% - 8px); min-width: 140px;
}
.scenario-btn:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.scenario-btn .sc-name { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; }
.scenario-btn .sc-tag { font-size: 11px; font-weight: 600; color: var(--muted); }
.scenario-btn .sc-desc { color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.35; }

/* Verdict */
.verdict { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid transparent; }
.verdict-icon { font-size: 30px; line-height: 1; }
.verdict-title { font-size: 17px; font-weight: 800; }
.verdict-sub { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.verdict-profit { background: #ecfdf5; border-color: #a7f3d0; color: var(--profit); }
.verdict-loss { background: #fef2f2; border-color: #fecaca; color: var(--loss); }
.verdict-breakeven { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.verdict-profit .verdict-sub, .verdict-loss .verdict-sub, .verdict-breakeven .verdict-sub { color: var(--muted); }

/* Metrics */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.metric { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.metric-hero { grid-column: 1 / -1; background: linear-gradient(135deg, #f0fdf4, #ffffff); }
.metric-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.metric-label small { font-size: 10.5px; font-weight: 500; }
.metric-value { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.metric-hero .metric-value { font-size: 32px; }
.metric-foot { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.val-profit { color: var(--profit); }
.val-loss { color: var(--loss); }

/* Blocks */
.block { margin-bottom: 18px; }
.block-title { font-size: 13.5px; font-weight: 700; margin: 0 0 10px; display: flex; align-items: baseline; gap: 8px; }
.block-title small { font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* Breakdown bar */
.breakdown-bar { display: flex; width: 100%; height: 26px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); background: #f1f5f9; }
.breakdown-bar .seg { height: 100%; min-width: 2px; transition: width .25s ease; }
.breakdown-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
@media (max-width: 460px) { .breakdown-list { grid-template-columns: 1fr; } }
.breakdown-list li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.breakdown-list .dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.breakdown-list .bk-label { color: var(--muted); flex: 1; }
.breakdown-list .bk-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Break-even */
.be-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 460px) { .be-grid { grid-template-columns: 1fr; } }
.be-card { background: #f8fafc; border: 1px solid var(--line); border-radius: 11px; padding: 12px; text-align: center; }
.be-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.be-value { font-size: 19px; font-weight: 800; margin-top: 5px; font-variant-numeric: tabular-nums; }
.be-foot { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Actions */
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.primary-btn { background: var(--brand); color: #fff; border: none; border-radius: 10px; padding: 10px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: .15s; }
.primary-btn:hover { background: var(--brand-dark); }
.copy-hint { font-size: 12.5px; color: var(--brand); }

/* Footer */
.site-foot { padding: 22px 18px 40px; color: var(--muted); }
.site-foot p { margin: 0 0 8px; font-size: 13px; }
.foot-note { font-size: 12px; line-height: 1.6; }
