/*
 * SellerUnitMath — FBA site identity (forest / ground / white / olive).
 * Loaded by the shared shell as /brand.css. Everything is scoped under
 * body[data-site="fba"] so other roots stay untouched. Spacing on a 4px base.
 */

body[data-site="fba"] {
  /* identity */
  --brand-background: #F2F5F0;
  --brand-ink: #153E31;
  --brand-surface: #FFFFFF;
  --brand-deep: #0E2B22;
  --brand-accent: #DBE8BF;
  --brand-border: rgba(21, 62, 49, 0.18);
  --brand-muted: #4C5D52;
  --brand-danger: #A13A2B;
  --brand-font-display: "Chivo", "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --brand-font-ui: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --brand-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* re-point the shared shell palette at the fba identity */
  --ink: #1F3028;
  --muted: #4C5D52;
  --line: rgba(21, 62, 49, 0.18);
  --panel: #F2F5F0;
  --focus: #153E31;
  --danger: #A13A2B;

  background: var(--brand-surface);
  color: #1F3028;
  font-family: var(--brand-font-ui);
  line-height: 1.6;
}

/* Shell chrome ---------------------------------------------------------------- */

body[data-site="fba"] .shell {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

body[data-site="fba"] .skip {
  background: var(--brand-ink);
  color: #fff;
  border: 0;
  border-radius: 0 0 4px 0;
  font-weight: 600;
}

body[data-site="fba"] .site-header {
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
}

body[data-site="fba"] .site-header .brand {
  font: 700 1.125rem/1 var(--brand-font-display);
  color: var(--brand-ink);
  letter-spacing: -0.01em;
  padding: 8px 0;
}

body[data-site="fba"] .site-header .badge {
  color: var(--brand-muted);
  border-color: var(--brand-border);
  background: var(--brand-background);
}

body[data-site="fba"] .site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 4px;
  color: #1F3028;
  font-weight: 600;
  text-decoration: none;
}

body[data-site="fba"] .site-nav a:hover {
  background: var(--brand-background);
  color: var(--brand-ink);
}

body[data-site="fba"]:not(.guide-page) .page-title {
  font: 700 clamp(2rem, 5vw, 2.75rem) / 1.1 var(--brand-font-display);
  letter-spacing: -0.015em;
  color: var(--brand-ink);
  margin: 12px 0 8px;
}

body[data-site="fba"] .page-lead {
  font-size: 1.0625rem;
  color: var(--brand-muted);
  max-width: 60ch;
  margin: 0 0 16px;
}

/* Widget-first rhythm: tight above the fold on root pages only. */
body[data-site="fba"]:not(.guide-page) main.shell {
  padding-block: 12px 48px;
}

body[data-site="fba"] .site-footer {
  background: var(--brand-ink);
  border-top: 0;
  color: rgba(255, 255, 255, 0.85);
  padding: 20px 0 32px;
  font-size: 0.875rem;
}

body[data-site="fba"] .site-footer a {
  color: var(--brand-accent);
}

/* Focus ------------------------------------------------------------------------ */

body[data-site="fba"] :focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Typography ------------------------------------------------------------------- */

body[data-site="fba"] h2 {
  font: 700 clamp(1.375rem, 3vw, 1.75rem) / 1.2 var(--brand-font-display);
  color: var(--brand-ink);
  margin: 0 0 12px;
  scroll-margin-top: 24px;
}

body[data-site="fba"] h3,
body[data-site="fba"] h4 {
  font: 700 1.0625rem/1.3 var(--brand-font-display);
  color: var(--brand-ink);
}

body[data-site="fba"] .doc h3 {
  margin: 20px 0 8px;
}

body[data-site="fba"] a {
  color: var(--brand-ink);
}

body[data-site="fba"] main > section {
  margin-top: 40px;
  scroll-margin-top: 24px;
}

/* Tool: form left, one attached ledger column right ----------------------------- */

body[data-site="fba"] .ledger-tool h2 {
  margin-bottom: 8px;
}

body[data-site="fba"] .profile-line {
  margin: 0 0 8px;
  max-width: 72ch;
  font-size: 1rem;
}

/* The synthetic-example loader sits outside the form, right after the
   profile line; the #fba-sample id binding with the script is unchanged. */
body[data-site="fba"] .ledger-tool > .actions {
  margin: 4px 0 12px;
}

body[data-site="fba"] .fee-note {
  margin: 0;
  max-width: 68ch;
  font-size: 0.9375rem;
  color: var(--brand-muted);
}

body[data-site="fba"] details.scope-detail {
  margin: 12px 0 0;
  max-width: 72ch;
  font-size: 0.9375rem;
}

body[data-site="fba"] details.scope-detail summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  color: var(--brand-ink);
}

body[data-site="fba"] details.scope-detail ul {
  margin: 8px 0 4px;
  padding-left: 20px;
  color: var(--brand-muted);
}

body[data-site="fba"] details.scope-detail li + li {
  margin-top: 8px;
}

body[data-site="fba"] details.scope-detail strong {
  color: #1F3028;
}

body[data-site="fba"] .calc-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 20px;
}

@media (min-width: 60em) {
  body[data-site="fba"] .calc-grid {
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 56px;
    align-items: start;
  }
}

/* Form -------------------------------------------------------------------------- */

body[data-site="fba"] .fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px 24px;
  margin-bottom: 16px;
}

@media (min-width: 40em) {
  body[data-site="fba"] .fields {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

body[data-site="fba"] .field {
  min-width: 0;
  display: grid;
  gap: 4px;
}

body[data-site="fba"] .field label {
  font-weight: 600;
  font-size: 0.9375rem;
}

body[data-site="fba"] .field input {
  width: 100%;
  max-width: 280px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  background: var(--brand-surface);
  color: #1F3028;
  font: 500 1rem/1.4 var(--brand-font-mono);
  font-variant-numeric: tabular-nums;
}

body[data-site="fba"] .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

body[data-site="fba"] button {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 4px;
  font: 600 1rem/1.2 var(--brand-font-ui);
  cursor: pointer;
}

body[data-site="fba"] .btn-primary {
  background: var(--brand-ink);
  border: 1px solid var(--brand-ink);
  color: #fff;
}

body[data-site="fba"] .btn-primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
}

body[data-site="fba"] .btn-ghost {
  background: transparent;
  border: 1px solid var(--brand-ink);
  color: var(--brand-ink);
}

body[data-site="fba"] .btn-ghost:hover {
  background: var(--brand-background);
}

body[data-site="fba"] button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

body[data-site="fba"] .status {
  margin: 12px 0 0;
  font-size: 0.9375rem;
  color: var(--brand-muted);
  overflow-wrap: anywhere;
}

body[data-site="fba"] .status[data-state="success"] {
  color: #0E5A3C;
  font-weight: 600;
}

body[data-site="fba"] .status[data-state="error"] {
  color: var(--brand-danger);
  font-weight: 600;
}

body[data-site="fba"] #fba-error {
  margin: 8px 0 0;
  padding: 12px 16px;
  background: #FBF1EE;
  border: 1px solid var(--brand-danger);
  border-radius: 4px;
  color: var(--brand-danger);
  font-weight: 600;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

body[data-site="fba"] #fba-error[hidden] {
  display: none;
}

/* Ledger panel ------------------------------------------------------------------ */

body[data-site="fba"] .ledger-panel {
  background: var(--brand-background);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  padding: 20px;
  min-width: 0;
}

body[data-site="fba"] .ledger-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand-ink);
}

body[data-site="fba"] .ledger-head h3 {
  margin: 0;
}

body[data-site="fba"] .ledger-head span {
  font: 500 0.8125rem/1.2 var(--brand-font-mono);
  color: var(--brand-muted);
}

/* Native summary output: engine fills the dd elements, never the page. */
body[data-site="fba"] #fba-summary {
  margin: 8px 0 0;
  min-width: 0;
}

body[data-site="fba"] #fba-summary[hidden] {
  display: none;
}

body[data-site="fba"] #fba-summary .total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding-top: 12px;
  border-top: 2px solid var(--brand-ink);
}

body[data-site="fba"] #fba-summary dt {
  font: 700 1rem/1.3 var(--brand-font-display);
  color: var(--brand-ink);
}

body[data-site="fba"] #fba-summary dd {
  margin: 0;
  font: 500 2rem/1.1 var(--brand-font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
  overflow-wrap: anywhere;
  text-align: right;
}

body[data-site="fba"] #fba-summary .ratio-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--brand-border);
}

body[data-site="fba"] #fba-summary .ratio-row dt {
  font: 600 0.875rem/1.4 var(--brand-font-ui);
  color: var(--brand-muted);
}

body[data-site="fba"] #fba-summary .ratio-row dd {
  font: 500 0.9375rem/1.4 var(--brand-font-mono);
  font-variant-numeric: tabular-nums;
  color: #1F3028;
}

body[data-site="fba"] .ledger-panel .definition {
  margin: 12px 0 16px;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--brand-muted);
}

body[data-site="fba"] .ledger-panel .actions {
  gap: 8px;
}

body[data-site="fba"] .ledger-panel .actions button {
  padding: 8px 14px;
  font-size: 0.9375rem;
}

body[data-site="fba"] #fba-copy-note {
  margin: 8px 0 0;
  min-height: 1em;
  font-size: 0.8125rem;
  color: var(--brand-muted);
  overflow-wrap: anywhere;
}

body[data-site="fba"] .ledger-panel h4 {
  margin: 16px 0 8px;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-site="fba"] #fba-output {
  margin: 0;
  padding: 12px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: 4px;
  font: 0.8125rem/1.5 var(--brand-font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 24rem;
  min-width: 0;
}

/* Examples, teasers, docs -------------------------------------------------------- */

body[data-site="fba"] .examples p {
  max-width: 68ch;
}

body[data-site="fba"] .table-scroll {
  overflow-x: auto;
}

body[data-site="fba"] .doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

body[data-site="fba"] .doc table th {
  padding: 8px 16px 8px 0;
  border-bottom: 2px solid var(--brand-ink);
  text-align: left;
  font: 600 0.8125rem/1.4 var(--brand-font-ui);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-muted);
  vertical-align: bottom;
}

body[data-site="fba"] .doc table td {
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--brand-border);
  vertical-align: top;
}

body[data-site="fba"] .doc table tbody th {
  border-bottom: 1px solid var(--brand-border);
  text-transform: none;
  letter-spacing: 0;
  font: 600 0.9375rem/1.5 var(--brand-font-ui);
  color: #1F3028;
  white-space: nowrap;
}

body[data-site="fba"] .doc table td:nth-child(2) {
  font: 500 0.9375rem/1.5 var(--brand-font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body[data-site="fba"] .teasers {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 760px;
}

body[data-site="fba"] .teasers li {
  padding: 16px 0;
  border-top: 1px solid var(--brand-border);
}

body[data-site="fba"] .teasers li:last-child {
  border-bottom: 1px solid var(--brand-border);
}

body[data-site="fba"] .teasers a {
  font: 700 1.0625rem/1.3 var(--brand-font-display);
  color: var(--brand-ink);
  text-decoration: none;
}

body[data-site="fba"] .teasers a:hover {
  text-decoration: underline;
}

body[data-site="fba"] .teasers p {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  color: var(--brand-muted);
  max-width: 62ch;
}

body[data-site="fba"] .all-guides {
  margin: 16px 0 0;
  font-size: 0.9375rem;
}

body[data-site="fba"] .doc {
  max-width: 46rem;
}

body[data-site="fba"] .doc p,
body[data-site="fba"] .doc li {
  overflow-wrap: anywhere;
}

/* Small screens: first input stays in the first screen, result stacks below. */
@media (max-width: 39.9375em) {
  body[data-site="fba"] .page-title {
    margin-top: 12px;
  }

  body[data-site="fba"] main > section {
    margin-top: 32px;
  }

  body[data-site="fba"] .ledger-panel {
    padding: 16px;
  }

  body[data-site="fba"] #fba-summary dd {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-site="fba"] *,
  body[data-site="fba"] *::before,
  body[data-site="fba"] *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
