/* ============================================================
   FBA Profit Calculator — Amazon-flavored navy + orange
   ============================================================ */

:root {
  --navy-900: #0F1B2D;
  --navy-800: #131A22;
  --navy-700: #1C2937;
  --navy-600: #232F3E;
  --navy-500: #37475A;
  --slate-500: #6B7280;
  --slate-400: #94A3B8;
  --slate-300: #CBD3DD;
  --slate-200: #E5E7EB;
  --slate-100: #F1F3F6;
  --slate-50:  #F7F8FA;

  --orange-500: #FF9900;
  --orange-600: #E88B00;
  --orange-700: #C77100;
  --orange-100: #FFF4E1;

  --green-600: #067D62;
  --green-100: #E5F3EF;
  --red-600:   #C7511F;
  --red-100:   #FBEAE3;
  --amber-600: #B25E09;
  --amber-100: #FFF1D9;

  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 1px rgba(15, 27, 45, .04);
  --shadow-md: 0 4px 12px rgba(15, 27, 45, .07), 0 1px 3px rgba(15, 27, 45, .05);
  --shadow-lg: 0 12px 28px rgba(15, 27, 45, .12), 0 4px 8px rgba(15, 27, 45, .06);

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sans: "Space Grotesk", ui-sans-serif, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--slate-50);
  color: var(--navy-900);
  font-size: 14px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button { font-family: inherit; cursor: pointer; }

/* ───────────── Layout shell ───────────── */
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ───────────── Portal-rendered popovers (escape any stacking context) ───────────── */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 27, 45, 0.5);
  z-index: 99998;
}
.popover-menu {
  position: fixed;
  background-color: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  box-shadow: 0 24px 48px rgba(15, 27, 45, .35), 0 4px 12px rgba(15, 27, 45, .2);
  padding: 14px;
  z-index: 99999;
  color: var(--navy-900);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  forced-color-adjust: none;
  isolation: isolate;
}
.popover-menu .market-menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate-500);
  margin-bottom: 10px;
  background: transparent;
}
@media (max-width: 480px) {
  .popover-menu {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px);
  }
}

/* Legacy menu classes — kept hidden for safety */
.market-backdrop { display: none; }
.market-menu, .tmpl-menu { background-color: #ffffff !important; }

/* ───────────── Top utility strip (legacy) ───────────── */
.utility-bar { display: none; }

/* Header brand-link button */
.hdr-link {
  text-decoration: none;
  background: rgba(255, 153, 0, .08);
  border-color: rgba(255, 153, 0, .35);
  color: var(--orange-500);
}
.hdr-link:hover {
  background: var(--orange-500);
  border-color: var(--orange-500);
  color: var(--navy-900);
}
.hdr-link .hdr-link-ext { opacity: .65; }
.hdr-link:hover .hdr-link-ext { opacity: 1; }

/* ───────────── Header ───────────── */
.app-header {
  background: linear-gradient(135deg, #0A1320 0%, var(--navy-900) 40%, #1C2937 100%);
  color: #fff;
  padding: 28px 32px 0;
  box-shadow: 0 4px 0 var(--orange-500);
  position: relative;
  z-index: 30;
}
.header-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .9;
  overflow: hidden;
}
.header-deco svg {
  position: absolute;
  right: -50px;
  top: 0;
  bottom: 0;
  width: 60%;
  height: 100%;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  row-gap: 14px;
  position: relative;
  z-index: 2;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.brand-mark {
  display: block;
  filter: drop-shadow(0 4px 12px rgba(255, 153, 0, .25));
}
.brand-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.brand-name .accent {
  color: var(--orange-500);
  position: relative;
}
.brand-sub {
  font-size: 12px;
  color: var(--slate-400);
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 6px;
}

.header-spacer { flex: 1; }

/* Header feature strip */
.header-features {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 0 20px;
  margin-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.hdr-feature {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--slate-300);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.hdr-feature b {
  color: #fff;
  font-weight: 700;
}
.hdr-feature-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 153, 0, .14);
  color: var(--orange-500);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hdr-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, .12);
}

@media (max-width: 1100px) {
  .header-features { flex-wrap: wrap; gap: 12px; }
  .hdr-divider { display: none; }
}
@media (max-width: 720px) {
  .app-header { padding: 20px 18px 0; }
  .brand-name { font-size: 22px; }
  .header-row { flex-wrap: wrap; }
}

/* ASIN lookup */
.header-asin {
  flex: 1;
  max-width: 540px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy-700);
  border-radius: 999px;
  padding: 4px 4px 4px 14px;
  position: relative;
}
.asin-label {
  font-size: 11px;
  color: var(--slate-400);
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
}
.asin-input {
  flex: 1;
  background: transparent;
  border: 0;
  color: #fff;
  outline: none;
  font-size: 13px;
  letter-spacing: .02em;
  padding: 8px 4px;
  min-width: 0;
}
.asin-input::placeholder { color: var(--slate-400); }
/* ───── Header spacer & Templates dropdown ───── */
.header-spacer { flex: 1; }

.tmpl-wrap { position: relative; }
.tmpl-btn { background: rgba(255,153,0,.12); border-color: rgba(255,153,0,.35); color: var(--orange-500); }
.tmpl-btn:hover { background: rgba(255,153,0,.18); border-color: var(--orange-500); }
.tmpl-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: #ffffff !important;
  background-image: none !important;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  box-shadow: 0 24px 48px rgba(15, 27, 45, .25), 0 4px 12px rgba(15, 27, 45, .12);
  padding: 14px;
  width: 360px;
  z-index: 1001;
  color: var(--navy-900);
  opacity: 1;
  isolation: isolate;
  forced-color-adjust: none;
}
.tmpl-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tmpl-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  transition: background .12s;
  cursor: pointer;
}
.tmpl-item:hover { background: var(--slate-100); }
.tmpl-glyph {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 8px;
}
.tmpl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tmpl-label { font-size: 13px; font-weight: 600; color: var(--navy-900); }
.tmpl-meta { font-size: 11.5px; color: var(--slate-500); }

/* Template quick-chips in product section */
.tmpl-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tmpl-chips-label {
  font-size: 11px;
  color: var(--slate-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-right: 2px;
}
.tmpl-chip {
  font-size: 11.5px;
  background: var(--slate-50);
  color: var(--navy-700);
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  padding: 4px 10px;
  transition: all .12s;
  cursor: pointer;
}
.tmpl-chip:hover {
  background: var(--orange-100);
  border-color: var(--orange-500);
  color: var(--orange-700);
}

/* Auto-detect flag on inputs */
.auto-input-wrap {
  position: relative;
}
.auto-flag {
  position: absolute;
  top: -6px;
  right: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--orange-700);
  background: #fff;
  border: 1px solid var(--orange-500);
  padding: 1px 5px;
  border-radius: 3px;
  z-index: 2;
}
.asin-suggestions {
  display: flex;
  gap: 4px;
  margin-right: 4px;
}
.asin-chip {
  font-size: 10.5px;
  background: rgba(255,255,255,.07);
  color: var(--slate-300);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 4px 8px;
  transition: all .15s;
}
.asin-chip:hover { background: var(--orange-500); color: var(--navy-900); border-color: var(--orange-500); }
.asin-error {
  position: absolute;
  top: 110%;
  left: 14px;
  background: var(--red-600);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
}

/* Header tools */
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.hdr-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .15s;
}
.hdr-btn:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); }

/* Marketplace switcher */
.market-wrap { position: relative; }
.market-btn {
  background: var(--orange-500);
  color: var(--navy-900);
  border: 0;
  border-radius: var(--r-sm);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.005em;
}
.market-btn:hover { background: var(--orange-600); }
.market-code { font-weight: 700; letter-spacing: .04em; }
.market-cur { opacity: .7; font-size: 11px; }
.market-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(15, 27, 45, 0.55);
}
.market-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: #ffffff !important;
  background-image: none !important;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  box-shadow: 0 24px 48px rgba(15, 27, 45, .25), 0 4px 12px rgba(15, 27, 45, .12);
  padding: 14px;
  width: 380px;
  z-index: 1001;
  color: var(--navy-900);
  opacity: 1;
  isolation: isolate;
  forced-color-adjust: none;
}
.market-menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--slate-500);
  margin-bottom: 10px;
}
.market-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.market-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12.5px;
  text-align: left;
  transition: background .12s;
}
.market-item:hover { background: var(--slate-100); }
.market-item.active { background: var(--orange-100); color: var(--navy-900); }
.market-item-code { font-weight: 700; font-size: 11px; color: var(--slate-500); letter-spacing: .04em; }
.market-item.active .market-item-code { color: var(--orange-700); }
.market-item-cur { color: var(--slate-500); font-size: 12px; }

/* ───────────── Scenario bar ───────────── */
.scenario-bar {
  background: var(--navy-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid rgba(0,0,0,.18);
  flex-wrap: wrap;
  gap: 12px;
  z-index: 20;
}
.scenario-tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.scenario-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-sm);
  padding: 7px 10px 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  min-width: 0;
}
.scenario-tab:hover { background: rgba(255,255,255,.1); }
.scenario-tab.active {
  background: #fff;
  color: var(--navy-900);
  border-color: #fff;
  box-shadow: 0 -3px 0 var(--orange-500) inset;
}
.scenario-dot-mark {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.scenario-name {
  font-weight: 500;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scenario-edit {
  font: inherit;
  border: 0;
  background: transparent;
  outline: none;
  color: inherit;
  width: 120px;
  border-bottom: 1px dashed currentColor;
  padding: 0;
}
.scenario-margin {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
}
.scenario-tab.active .scenario-margin { background: var(--slate-100); }
.scenario-margin.good { color: var(--green-600); background: var(--green-100); }
.scenario-margin.warn { color: var(--amber-600); background: var(--amber-100); }
.scenario-margin.bad  { color: var(--red-600); background: var(--red-100); }
.scenario-menu-wrap { position: relative; }
.scenario-menu-btn {
  background: transparent;
  border: 0;
  color: inherit;
  opacity: .5;
  width: 22px; height: 22px;
  border-radius: 4px;
  display: grid; place-items: center;
}
.scenario-menu-btn:hover { opacity: 1; background: rgba(0,0,0,.06); }
.scenario-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  color: var(--navy-900);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 130px;
  z-index: 50;
}
.scenario-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 7px 10px;
  font-size: 12.5px;
  border-radius: 4px;
}
.scenario-menu button:hover { background: var(--slate-100); }
.scenario-menu button.danger { color: var(--red-600); }
.scenario-menu button.danger:hover { background: var(--red-100); }

.scenario-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed rgba(255,255,255,.25);
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.7);
  padding: 6px 11px;
  font-size: 12px;
  transition: all .15s;
}
.scenario-add:hover { color: #fff; border-color: var(--orange-500); }

.scenario-meta {
  font-size: 12px;
  color: var(--slate-400);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.scenario-product {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.scenario-dot { opacity: .4; }

/* ───────────── Main body ───────────── */
.app-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  background: var(--slate-50);
}
@media (min-width: 1280px) {
  .app-body { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
}
.pane-left {
  padding: 20px;
  border-right: 1px solid var(--slate-200);
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.pane-right {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  background: #fff;
}
.app-body {
  flex: 1 1 auto;
  min-height: 0;
}

/* ───────────── Inputs pane ───────────── */
.inputs-pane { display: flex; flex-direction: column; gap: 12px; }

/* Section */
.section {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  overflow: hidden;
}
.section-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  padding: 16px 18px;
  text-align: left;
}
.section.closed .section-head:hover { background: var(--slate-50); }
.section-icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--navy-900);
  color: var(--orange-500);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.section-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--navy-900);
  letter-spacing: -0.01em;
}
.section-kicker {
  font-size: 12px;
  color: var(--slate-500);
  margin-left: 10px;
  font-weight: 500;
}
.section-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  background: var(--orange-100);
  color: var(--orange-700);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}
.section-chev {
  color: var(--slate-400);
  font-size: 12px;
  margin-left: auto;
}
.section.open .section-chev,
.section.closed .section-badge + .section-chev {
  margin-left: 8px;
}
.section.open .section-badge + .section-chev { margin-left: 8px; }
.section.open .section-head { border-bottom: 1px solid var(--slate-100); }
.section-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }

/* Product head */
.product-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.product-glyph-wrap {
  width: 88px; height: 88px;
  background: var(--slate-50);
  border: 1px dashed var(--slate-300);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.product-glyph { display: block; }
.product-meta { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Field grids */
.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid.four { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 720px) {
  .field-grid.two, .field-grid.four { grid-template-columns: 1fr 1fr; }
}

/* Field */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field.full { grid-column: 1 / -1; }
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.field-sublabel {
  font-size: 12px;
  font-weight: 500;
  color: var(--navy-900);
  margin-top: 1px;
  margin-bottom: 2px;
  letter-spacing: -0.005em;
}
.field-auto-pill {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--orange-700);
  background: var(--orange-100);
  padding: 1px 5px;
  border-radius: 3px;
}
.field-input-wrap {
  display: flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.field-input-wrap:focus-within {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, .15);
}
.field-prefix, .field-suffix {
  display: grid;
  place-items: center;
  padding: 0 8px;
  font-size: 12px;
  color: var(--slate-500);
  background: var(--slate-50);
  white-space: nowrap;
}
.field-prefix { border-right: 1px solid var(--slate-200); }
.field-suffix { border-left: 1px solid var(--slate-200); }
.num-input, .text-input, .select {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-900);
  min-width: 0;
  width: 100%;
  letter-spacing: -0.005em;
}
.num-input {
  font-family: var(--mono);
  font-weight: 600;
  font-feature-settings: "tnum";
}
.text-input.mono { font-family: var(--mono); letter-spacing: .02em; }
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input { -moz-appearance: textfield; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236B7280' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.field-hint {
  font-size: 11px;
  color: var(--slate-400);
}

/* Slider */
.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--r-sm);
  padding: 10px 14px;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--slate-200);
  border-radius: 999px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--orange-500);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--orange-500);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  cursor: pointer;
}
.slider-readout {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-900);
  min-width: 100px;
  text-align: right;
}

/* Editable slider readout: number input + suffix */
.slider-readout-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-sm);
  padding: 4px 8px 4px 10px;
  min-width: 130px;
  transition: border-color .12s, box-shadow .12s;
}
.slider-readout-edit:focus-within {
  border-color: var(--orange-500);
  box-shadow: 0 0 0 3px rgba(255, 153, 0, .15);
}
.slider-num {
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--navy-900);
  width: 60px;
  text-align: right;
  padding: 4px 0;
  font-feature-settings: "tnum";
}
.slider-num::-webkit-outer-spin-button,
.slider-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.slider-num { -moz-appearance: textfield; }
.slider-suffix {
  font-size: 11px;
  color: var(--slate-500);
  font-weight: 600;
  white-space: nowrap;
}

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

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--navy-900), var(--navy-600));
  color: #fff;
  border-radius: var(--r-lg);
  padding: 28px 30px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--navy-700);
}
.hero::before {
  content: "";
  position: absolute;
  right: -60px; top: -60px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(255, 153, 0, .28), transparent 70%);
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--orange-500);
}
.hero-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate-400);
  font-weight: 700;
  margin-bottom: 10px;
}
.hero-figure { display: flex; align-items: baseline; gap: 12px; margin: 8px 0 22px; }
.hero-amount {
  font-size: 68px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--orange-500);
  line-height: 0.95;
  font-feature-settings: "tnum";
}
.hero-bad .hero-amount { color: var(--red-600); }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 16px;
}
.hero-stat-label {
  font-size: 10.5px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  margin-bottom: 6px;
}
.hero-stat-val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 999px;
}
.pill-good { background: var(--green-100); color: var(--green-600); }
.pill-ok   { background: var(--orange-100); color: var(--orange-700); }
.pill-warn { background: var(--amber-100); color: var(--amber-600); }
.pill-bad  { background: var(--red-100); color: var(--red-600); }
.pill-neutral { background: var(--slate-100); color: var(--slate-500); }

/* Card */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-md);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--slate-100);
  background: linear-gradient(180deg, #fff, var(--slate-50));
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy-900);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.card-right, .card-sub { font-size: 11.5px; color: var(--slate-500); font-weight: 500; }
.card-body { padding: 18px; }
.card-body.bare { padding: 0; }

.result-grid { display: grid; gap: 12px; }
.result-grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 920px) {
  .result-grid.two { grid-template-columns: 1fr; }
}

/* Waterfall */
.waterfall { display: flex; flex-direction: column; gap: 6px; }
.wf-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  align-items: center;
  gap: 14px;
  padding: 5px 0;
}
.wf-label { font-size: 13px; color: var(--slate-500); font-weight: 500; }
.wf-bar-wrap {
  height: 24px;
  background: var(--slate-100);
  border-radius: 4px;
  overflow: hidden;
}
.wf-bar { height: 100%; border-radius: 4px; transition: width .25s; }
.wf-revenue .wf-bar { background: var(--navy-700); }
.wf-fee .wf-bar { background: var(--slate-400); }
.wf-marketing .wf-bar { background: var(--green-600); opacity: .85; }
.wf-cogs .wf-bar { background: var(--navy-900); }
.wf-profit .wf-bar { background: var(--orange-500); }
.wf-loss .wf-bar { background: var(--red-600); }
.wf-value {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-feature-settings: "tnum";
}
.wf-revenue .wf-label,
.wf-final .wf-label {
  color: var(--navy-900);
  font-weight: 700;
}
.wf-final {
  border-top: 2px solid var(--slate-200);
  margin-top: 6px;
  padding-top: 10px;
}
.wf-final .wf-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--orange-700);
  letter-spacing: -0.02em;
}
.wf-loss .wf-value { color: var(--red-600); }

/* Break-even card */
.be-card { display: flex; flex-direction: column; gap: 16px; }
.be-headline { display: flex; align-items: baseline; gap: 12px; }
.be-num {
  font-size: 44px;
  font-weight: 800;
  color: var(--navy-900);
  letter-spacing: -0.04em;
  line-height: 0.95;
}
.be-label {
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.4;
  font-weight: 500;
}
.be-bar {
  position: relative;
  background: var(--slate-100);
  border-radius: 4px;
  height: 8px;
}
.be-bar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--orange-500), var(--orange-600));
  border-radius: 4px;
  transition: width .25s;
}
.be-bar-labels {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding-top: 4px;
  font-size: 10.5px;
  color: var(--slate-500);
}
.be-meta { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.be-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.be-meta-row span:first-child { color: var(--slate-500); }
.be-meta-row span:last-child { color: var(--navy-900); font-weight: 500; }

/* Donut */
.donut-wrap {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
}
.donut-num {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  fill: var(--navy-900);
}
.donut-sub {
  font-size: 6.5px;
  fill: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 700;
}
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.donut-leg-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.donut-dot { width: 9px; height: 9px; border-radius: 2px; display: block; }
.donut-leg-label { color: var(--slate-500); }
.donut-leg-val { color: var(--navy-900); font-weight: 500; }

/* Projection */
.proj-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.proj-stat {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}
.proj-stat.primary {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.proj-stat.primary::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--orange-500);
}
.proj-stat-label {
  font-size: 10px;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  margin-bottom: 6px;
}
.proj-stat.primary .proj-stat-label { color: var(--orange-500); }
.proj-stat-val {
  font-size: 19px;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: -0.02em;
}
.proj-stat.primary .proj-stat-val { color: #fff; }

.projection { display: flex; flex-direction: column; }
.proj-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  height: 90px;
  align-items: end;
}
.proj-col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.proj-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  position: relative;
}
.proj-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  transition: height .25s;
  position: relative;
  cursor: default;
}
.proj-bar.pos { background: var(--orange-500); }
.proj-bar.pos:hover { background: var(--orange-600); }
.proj-bar.neg { background: var(--red-600); }
.proj-tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--navy-900);
  color: #fff;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.proj-bar:hover .proj-tip { opacity: 1; }
.proj-lab {
  font-size: 10px;
  color: var(--slate-500);
  font-weight: 500;
}
.proj-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--slate-500);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--slate-100);
}

/* Calendar */
.calendar { }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  font-size: 10px;
  font-weight: 700;
  color: var(--slate-400);
  text-transform: uppercase;
  text-align: center;
  padding: 4px 0;
  letter-spacing: .06em;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform .12s;
  min-height: 50px;
}
.cal-cell:hover { transform: scale(1.04); box-shadow: var(--shadow-sm); }
.cal-day { font-size: 10px; color: var(--slate-500); font-weight: 600; }
.cal-val { font-size: 11px; font-weight: 600; }
.calendar-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--slate-100);
  font-size: 12px;
  color: var(--slate-500);
}
.calendar-foot span:last-child { color: var(--navy-900); font-weight: 600; }

/* Compare table */
.cmp-product-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--navy-900);
  color: #fff;
  padding: 12px 16px;
  margin: -16px -16px 14px;
  border-radius: 0;
}
.cmp-product-banner svg { flex-shrink: 0; }
.cmp-product-text { flex: 1; min-width: 0; }
.cmp-product-label {
  font-size: 10.5px;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.cmp-product-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.cmp-product-meta {
  font-size: 11px;
  color: var(--orange-500);
  font-weight: 500;
  background: rgba(255,153,0,.12);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.compare-wrap { overflow-x: auto; }
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.compare-table th, .compare-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--slate-100);
}
.compare-table thead th {
  background: var(--slate-50);
  border-bottom: 2px solid var(--navy-900);
  font-weight: 700;
  color: var(--navy-900);
  vertical-align: top;
  font-size: 13px;
}
.cmp-th {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cmp-dot { width: 8px; height: 8px; border-radius: 50%; }
.cmp-sub {
  font-size: 10.5px;
  color: var(--slate-400);
  font-weight: 400;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.compare-table tbody th {
  font-weight: 500;
  color: var(--slate-500);
  width: 160px;
}
.compare-table td {
  color: var(--navy-900);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.compare-table tr.strong td,
.compare-table tr.strong th {
  background: rgba(255, 153, 0, .04);
  font-weight: 600;
}
.compare-table td.best {
  color: var(--orange-700);
  font-weight: 700;
  background: var(--orange-100);
  position: relative;
}
.compare-table td.best::before {
  content: "★";
  font-size: 9px;
  margin-right: 4px;
  color: var(--orange-500);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-900);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease-out;
  z-index: 200;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Scrollbar polish */
.pane-left::-webkit-scrollbar,
.pane-right::-webkit-scrollbar { width: 10px; }
.pane-left::-webkit-scrollbar-thumb,
.pane-right::-webkit-scrollbar-thumb {
  background: var(--slate-200);
  border-radius: 999px;
  border: 2px solid var(--slate-50);
}
.pane-right::-webkit-scrollbar-thumb { border-color: #fff; }
.pane-left::-webkit-scrollbar-thumb:hover,
.pane-right::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

/* Responsive */

/* Tablet (≤980px): stack panes */
@media (max-width: 980px) {
  .app { height: auto; overflow: visible; }
  .app-body { grid-template-columns: 1fr; }
  .pane-left, .pane-right { max-height: none; overflow-y: visible; }
  .pane-left { border-right: 0; border-bottom: 1px solid var(--slate-200); }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .proj-stats { grid-template-columns: repeat(2, 1fr); }
  .result-grid.two { grid-template-columns: 1fr; }
}

/* Small tablet / large phone (≤760px) */
@media (max-width: 760px) {
  .hdr-link { font-size: 11px; }
  .hdr-link .hdr-link-ext { display: none; }
  .app-header { padding: 18px 16px 0; }
  .header-deco { opacity: .25; }
  .header-deco svg { right: -120px; }

  .brand { gap: 12px; flex: 1 1 auto; min-width: 0; }
  .brand-mark { width: 48px !important; height: 48px !important; flex-shrink: 0; }
  .brand-text { min-width: 0; flex: 1; }
  .brand-name { font-size: 22px; }
  .brand-sub {
    font-size: 10px;
    letter-spacing: .08em;
    white-space: normal;
    overflow-wrap: break-word;
  }

  /* Header row stacks naturally; spacer + tools land on a new line */
  .header-spacer { display: none; }
  .header-row { gap: 12px; row-gap: 14px; }
  .header-tools {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 6px;
    overflow-x: visible;
  }
  .hdr-btn,
  .hdr-link,
  .market-btn {
    padding: 8px 12px;
    font-size: 12px;
    flex: 0 1 auto;
    white-space: nowrap;
  }
  .tmpl-wrap, .market-wrap { flex: 0 1 auto; }

  .header-features {
    padding: 14px 0 16px;
    margin-top: 14px;
    gap: 10px 16px;
    flex-wrap: wrap;
  }
  .hdr-feature { font-size: 11.5px; }
  .hdr-feature-icon { width: 24px; height: 24px; }
  .hdr-divider { display: none; }

  /* Scenario bar */
  .scenario-bar { padding: 0 16px; }
  .scenario-meta { display: none; }
  .scenario-name { max-width: 100px; font-size: 12px; }

  /* Pane padding */
  .pane-left, .pane-right { padding: 14px; }
  .results-pane, .inputs-pane { gap: 12px; }

  /* Hero */
  .hero { padding: 22px 20px; }
  .hero-amount { font-size: 48px; }
  .hero-stat-val { font-size: 17px; }
  .hero-stat-label { font-size: 9.5px; letter-spacing: .08em; }

  /* Cards */
  .card-head { padding: 12px 14px; }
  .card-title { font-size: 10.5px; letter-spacing: .1em; }
  .card-body { padding: 14px; }

  /* Sections */
  .section-head { padding: 14px 14px; gap: 10px; }
  .section-icon { width: 28px; height: 28px; }
  .section-title { font-size: 14px; }
  .section-kicker { display: none; }
  .section-body { padding: 12px 14px 14px; gap: 12px; }

  /* Fields */
  .field-grid.two { grid-template-columns: 1fr; }
  .field-grid.four { grid-template-columns: 1fr 1fr; }
  .num-input, .text-input, .select { font-size: 16px; padding: 10px 12px; } /* 16px prevents iOS zoom */

  /* Product head: stack glyph above text */
  .product-head { flex-direction: row; align-items: stretch; }
  .product-glyph-wrap { width: 64px; height: 64px; }

  /* Template chips: wrap nicely */
  .tmpl-chips { gap: 5px; }
  .tmpl-chip { font-size: 11px; padding: 4px 9px; }

  /* Waterfall: tighter row layout */
  .wf-row { grid-template-columns: 100px 1fr 76px; gap: 10px; }
  .wf-label { font-size: 12px; }
  .wf-value { font-size: 12px; }
  .wf-final .wf-value { font-size: 15px; }

  /* Projection */
  .proj-stat { padding: 10px 12px; }
  .proj-stat-val { font-size: 16px; }
  .proj-bars { height: 70px; gap: 4px; }

  /* Calendar */
  .cal-cell { min-height: 42px; padding: 4px 5px; }
  .cal-day { font-size: 9.5px; }
  .cal-val { font-size: 9.5px; }

  /* Break-even */
  .be-num { font-size: 38px; }

  /* Donut: stack legend below */
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-legend { width: 100%; }

  /* Compare table: horizontal scroll */
  .cmp-product-banner { padding: 10px 12px; margin: -14px -14px 12px; gap: 10px; }
  .cmp-product-meta { font-size: 10px; padding: 3px 8px; }
  .compare-table { font-size: 12px; min-width: 480px; }
  .compare-table th, .compare-table td { padding: 8px 10px; }
  .compare-table tbody th { width: 120px; }

  /* Market menu */
  .market-menu { width: calc(100vw - 32px); right: -8px; }
  .market-menu-grid { grid-template-columns: 1fr; }
  .tmpl-menu { width: calc(100vw - 32px); right: -8px; }
}

/* Phone (≤480px) */
@media (max-width: 480px) {
  .header-deco { display: none; }
  .brand-name { font-size: 19px; }
  .brand-sub { font-size: 9.5px; letter-spacing: .06em; }
  .brand-mark { width: 42px !important; height: 42px !important; }

  .header-features { gap: 8px 12px; }
  .hdr-feature { font-size: 11px; gap: 7px; }
  .hdr-feature-icon { width: 22px; height: 22px; }

  /* Header buttons: compact, allow wrap */
  .hdr-btn,
  .hdr-link,
  .market-btn { padding: 7px 10px; font-size: 11.5px; gap: 5px; }
  .header-tools { gap: 5px; }

  .hero { padding: 20px 18px; }
  .hero-eyebrow { font-size: 10px; letter-spacing: .1em; }
  .hero-amount { font-size: 42px; }
  .hero-figure { margin: 6px 0 16px; }
  .hero-stats { gap: 12px; padding-top: 12px; }

  .be-num { font-size: 32px; }

  /* Field grid: dimensions stay 2-col but tighter */
  .field-grid.four { gap: 8px; }
  .field-input-wrap .num-input { padding: 9px 10px; }

  /* Slider */
  .slider-row { padding: 10px 12px; gap: 10px; }

  /* Scenario tab — compact */
  .scenario-tabs { gap: 3px; padding: 6px 0; }
  .scenario-tab { padding: 6px 6px 6px 9px; font-size: 12px; gap: 6px; }
  .scenario-margin { font-size: 10px; padding: 2px 5px; }

  /* Cards/sections */
  .card-body { padding: 12px; }
  .section-body { padding: 10px 12px 12px; }
  .pane-left, .pane-right { padding: 12px; }

  .product-head { gap: 10px; }
  .product-glyph-wrap { width: 56px; height: 56px; }
  .product-glyph-wrap svg { width: 44px; height: 44px; }

  /* Calendar cells smaller */
  .calendar-grid { gap: 3px; }
  .cal-cell { min-height: 38px; padding: 3px 4px; border-radius: 4px; }
  .cal-day { font-size: 9px; }
  .cal-val { font-size: 9px; }

  /* Waterfall: thinner label */
  .wf-row { grid-template-columns: 86px 1fr 64px; gap: 8px; }
  .wf-label { font-size: 11px; }
  .wf-value { font-size: 11.5px; }
  .wf-final .wf-value { font-size: 14px; }
  .wf-bar-wrap { height: 18px; }

  .toast { bottom: 14px; font-size: 12px; padding: 9px 16px; }
}
