:root {
  --ink: #151515;
  --paper: #f4f5f1;
  --white: #ffffff;
  --line: #c8cbc3;
  --muted: #63665f;
  --yellow: #f4d64e;
  --mint: #b7f1d2;
  --coral: #ff765f;
  --red: #8f261f;
  --shadow: 0 18px 50px rgba(18, 20, 17, .11);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Satoshi, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid #146e58; outline-offset: 3px; }
[hidden] { display: none !important; }
.page-shell { width: 100%; max-width: 100%; overflow-x: hidden; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 99; padding: .8rem 1rem; background: var(--yellow); color: var(--ink); }
.skip-link:focus { top: 1rem; }

.masthead {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  width: min(1440px, calc(100% - 32px)); margin: 16px auto 0;
  padding: 10px 12px 10px 10px; border: 1px solid rgba(21,21,21,.22);
  border-radius: 999px; background: rgba(244,245,241,.88); backdrop-filter: blur(16px);
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; }
.wordmark-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--white); font-size: .72rem; }
.nav-actions { display: flex; align-items: center; gap: 20px; font-size: .82rem; }
.nav-actions a { text-decoration: none; }
.runtime-chip { min-width: 116px; padding: 8px 12px; border-radius: 999px; background: #e0e2dc; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .7rem; text-align: center; }
.runtime-chip.ready { background: var(--mint); }
.runtime-chip.error { background: var(--coral); }

.attention { padding: 100px 24px 130px; }
.title-wrap { width: min(1120px, 100%); margin: 0 auto 64px; text-align: center; }
.kicker, .eyebrow { margin: 0 0 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(2.6rem, 5vw, 5.2rem); line-height: .99; font-weight: 820; }
.inline-image { display: inline-block; width: clamp(90px, 12vw, 160px); height: .62em; margin: 0 .08em; border-radius: 999px; vertical-align: .05em; background: linear-gradient(90deg, rgba(244,214,78,.22), rgba(183,241,210,.26)), url("https://picsum.photos/seed/batch-routing-ledger/320/120") center / cover; filter: grayscale(1) contrast(1.25); }
.lede { max-width: 760px; margin: 28px auto 0; color: #4c4f49; font-size: clamp(1rem, 1.5vw, 1.24rem); line-height: 1.55; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(300px, .72fr); width: min(1440px, 100%); margin: 0 auto; border: 1px solid var(--ink); background: var(--white); box-shadow: var(--shadow); }
.ledger { min-width: 0; padding: 32px; border-right: 1px solid var(--ink); }
.section-head, .panel-title, .dialog-head, .section-heading-wide, .footer-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
h2 { margin: 0; font-size: clamp(1.75rem, 3vw, 3rem); line-height: 1.06; }
h3 { margin: 0; font-size: 1.15rem; }
.tool-row, .ledger-actions, .export-row, .dialog-actions, .feedback-controls, .footer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--ink); border-radius: 2px; text-decoration: none; font-weight: 780; transition: transform .22s ease, background .22s ease; }
.button:hover { transform: translateY(-2px); }
.button-dark { background: var(--ink); color: var(--white); }
.button-light { background: var(--white); color: var(--ink); }
.button-yellow { background: var(--yellow); color: var(--ink); }
.button-outline { background: transparent; color: inherit; border-color: currentColor; }
.button-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.text-button { padding: 4px 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; font-weight: 760; }
.danger-link { color: var(--red); }
.table-note, .disclaimer { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.table-note { margin: 20px 0 14px; }

.workload-list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.workload-row { position: relative; display: grid; grid-template-columns: minmax(150px, 1.5fr) 78px 100px 100px 112px 40px; gap: 10px; align-items: end; padding: 16px; background: var(--white); transition: background .2s ease, transform .2s ease; }
.workload-row:focus-within { background: #fffcdd; z-index: 1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field span { color: var(--muted); font-size: .67rem; font-weight: 750; text-transform: uppercase; }
.field input, .field select, .rules-panel input, .model-row input, textarea { width: 100%; min-width: 0; min-height: 40px; border: 1px solid #afb2aa; border-radius: 0; background: var(--white); color: var(--ink); padding: 8px 9px; }
.name-stack { display: grid; grid-template-columns: 1fr .85fr; gap: 8px; }
.delete-button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #d6aaa5; background: #fff5f3; color: var(--red); font-size: 0; }
.delete-button::before { content: "x"; font-size: 1rem; font-weight: 900; }
.delete-button:hover { background: var(--coral); color: var(--ink); }
.empty-state { display: grid; gap: 6px; padding: 32px; border: 1px dashed #8c8f88; text-align: center; }
.ledger-actions { margin-top: 18px; }
.clear-confirm { display: flex; width: 100%; align-items: center; gap: 10px; padding: 12px; border-left: 4px solid var(--coral); background: #fff0ed; }
.clear-confirm span { margin-right: auto; font-size: .84rem; }

.route-summary { position: relative; padding: 32px; color: var(--white); background: var(--ink); overflow: hidden; }
.route-summary::after { content: ""; position: absolute; right: -20%; bottom: -16%; width: 70%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(244,214,78,.16), transparent 68%); pointer-events: none; }
.summary-topline { display: flex; justify-content: space-between; color: #c7cac4; }
.route-summary h2 { font-size: clamp(1.6rem, 2.3vw, 2.35rem); }
.total { margin: 22px 0 14px; color: var(--yellow); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(3rem, 5vw, 5.4rem); font-weight: 860; line-height: 1; }
.budget-track { height: 7px; background: #3b3b3b; overflow: hidden; }
.budget-track span { display: block; width: 0; height: 100%; background: var(--mint); transition: width .55s cubic-bezier(.2,.8,.2,1), background .25s; }
.budget-copy { margin-top: 9px; color: #d2d4cf; font-size: .8rem; }
.comparison { display: grid; gap: 1px; margin: 28px 0; background: #393939; border: 1px solid #393939; }
.comparison > div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; background: var(--ink); }
.comparison span { color: #aeb1ab; font-size: .78rem; }
.comparison strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.route-status { position: relative; z-index: 1; padding: 14px; border-left: 4px solid var(--mint); background: #242424; line-height: 1.45; }
.route-status.warning { border-left-color: var(--coral); }
.export-row { position: relative; z-index: 1; margin: 22px 0 10px; }

.route-board { padding: 130px 24px 160px; background: #e7e9e3; }
.section-heading-wide { width: min(1320px, 100%); margin: 0 auto 48px; }
.section-heading-wide > p { max-width: 500px; margin: 20px 0 0; color: var(--muted); line-height: 1.55; }
.route-list { display: grid; width: min(1320px, 100%); margin: 0 auto; border-top: 1px solid var(--ink); }
.route-row { display: grid; grid-template-columns: 1.25fr .8fr 1fr; gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--ink); }
.route-name h3 { font-size: 1.6rem; }
.route-name p, .route-metrics p { margin: 8px 0 0; color: var(--muted); }
.selected-model { display: inline-flex; align-items: center; align-self: start; width: fit-content; padding: 8px 11px; background: var(--mint); font-weight: 850; }
.selected-model.blocked { background: var(--coral); }
.route-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.route-metrics > div { padding: 12px; background: var(--paper); }
.route-metrics span { display: block; color: var(--muted); font-size: .67rem; text-transform: uppercase; }
.route-metrics strong { display: block; margin-top: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.rejections { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.rejection { padding: 7px 9px; background: #fff1ee; border-left: 3px solid var(--coral); font-size: .78rem; }

.assumptions-band { display: grid; grid-template-columns: .68fr 1.32fr; gap: clamp(40px, 8vw, 130px); padding: 170px max(24px, calc((100vw - 1320px) / 2)); background: var(--yellow); }
.pin-title { align-self: start; max-width: 430px; }
.pin-title p { line-height: 1.6; }
.library-proof { margin-top: 28px; padding: 14px; border: 1px solid var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; line-height: 1.5; }
.assumption-stack { display: grid; gap: 24px; }
.assumption-panel { padding: 26px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); }
.model-list { display: grid; gap: 1px; margin-top: 20px; background: var(--line); border: 1px solid var(--line); }
.model-row { position: relative; display: grid; grid-template-columns: 1.25fr repeat(4, .72fr) 36px; gap: 8px; padding: 12px; background: var(--white); align-items: end; }
.model-row .field span { font-size: .61rem; }
.model-row button { width: 36px; height: 40px; border: 1px solid #d6aaa5; background: #fff5f3; color: var(--red); }
.rules-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.rules-panel h3 { grid-column: 1 / -1; }
.rules-panel label { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: end; font-size: .78rem; font-weight: 780; }
.rules-panel label span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.rules-panel input { grid-column: 1 / -1; }

.evidence-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(260px, auto)); grid-auto-flow: dense; padding: 170px max(24px, calc((100vw - 1320px) / 2)); background: var(--paper); }
.proof-panel, .accordion-panel, .feedback-panel { border: 1px solid var(--ink); padding: 34px; overflow: hidden; }
.proof-panel { grid-column: span 2; grid-row: span 2; background: var(--ink); color: var(--white); }
.proof-panel code { display: block; margin: 32px 0; padding: 20px; background: #242424; color: var(--mint); line-height: 1.7; white-space: normal; }
.formula-lines { display: grid; gap: 10px; }
.formula-line { padding: 12px 0; border-top: 1px solid #444; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; line-height: 1.5; }
.accordion-panel { grid-column: span 2; background: var(--coral); }
.accordion-trigger { display: flex; width: 100%; justify-content: space-between; border: 0; background: transparent; padding: 0; color: var(--ink); font-size: 1.5rem; font-weight: 850; text-align: left; }
.accordion-content { max-width: 600px; line-height: 1.55; }
.feedback-panel { grid-column: span 2; background: var(--mint); }
.feedback-slides { min-height: 118px; }
.feedback-slides blockquote { display: none; margin: 18px 0; font-size: clamp(1.25rem, 2.4vw, 2.1rem); line-height: 1.18; font-weight: 770; }
.feedback-slides blockquote.active { display: block; }
.icon-button { min-width: 44px; min-height: 40px; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 760; }

.footer-action { align-items: end; padding: 120px max(24px, calc((100vw - 1320px) / 2)); background: var(--ink); color: var(--white); }
.footer-action h2 { max-width: 760px; font-size: clamp(2.5rem, 5vw, 5rem); }

.import-dialog { width: min(760px, calc(100% - 24px)); max-height: 90vh; padding: 0; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); color: var(--ink); }
.import-dialog::backdrop { background: rgba(21,21,21,.72); backdrop-filter: blur(4px); }
.dialog-shell { padding: 28px; }
.dialog-shell p { line-height: 1.5; }
.dialog-shell textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.error-rail { margin: 12px 0; padding: 12px; border-left: 4px solid var(--coral); background: #fff0ed; white-space: pre-line; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(390px, calc(100% - 40px)); padding: 14px 18px; background: var(--ink); color: var(--white); box-shadow: var(--shadow); }
.mobile-state-dock { display: none; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .ledger { border-right: 0; border-bottom: 1px solid var(--ink); }
  .workload-row { grid-template-columns: 1.3fr repeat(4, .75fr) 40px; }
  .route-row { grid-template-columns: 1fr 1fr; }
  .route-metrics, .rejections { grid-column: 1 / -1; }
  .assumptions-band { grid-template-columns: 1fr; }
  .pin-title { max-width: 700px; }
}

@media (max-width: 760px) {
  body { padding-bottom: 68px; }
  .masthead { width: calc(100% - 20px); margin-top: 10px; }
  .nav-actions a { display: none; }
  .wordmark { font-size: .86rem; }
  .attention { padding: 76px 12px 90px; }
  .title-wrap { margin-bottom: 40px; }
  h1 { font-size: clamp(2.25rem, 10.6vw, 3.15rem); }
  .inline-image { display: none; }
  .workspace { border-left: 0; border-right: 0; }
  .ledger, .route-summary { padding: 22px 16px; }
  .section-head, .section-heading-wide, .footer-action { display: grid; }
  .tool-row { width: 100%; }
  .tool-row .button { flex: 1; }
  .workload-list { gap: 12px; border: 0; background: transparent; }
  .workload-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px; border: 1px solid var(--ink); box-shadow: 4px 4px 0 #d5d7d1; }
  .workload-row .field:first-child { grid-column: 1 / -1; }
  .name-stack { grid-template-columns: 1fr; }
  .delete-button { position: absolute; right: 12px; top: 12px; }
  .workload-row .field:first-child { padding-right: 48px; }
  .clear-confirm { display: grid; }
  .route-board { padding: 96px 16px 110px; }
  .route-row { grid-template-columns: 1fr; gap: 18px; }
  .route-metrics { grid-column: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rejections { grid-column: auto; }
  .assumptions-band { padding: 110px 16px; }
  .assumption-panel { padding: 18px; box-shadow: 5px 5px 0 var(--ink); }
  .model-list { gap: 12px; border: 0; background: transparent; }
  .model-row { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
  .model-row .field:first-child { grid-column: 1 / -1; }
  .model-row button { position: absolute; right: 28px; }
  .rules-panel { grid-template-columns: 1fr; }
  .rules-panel h3 { grid-column: auto; }
  .evidence-grid { grid-template-columns: 1fr; grid-template-rows: auto; padding: 110px 16px; }
  .proof-panel, .accordion-panel, .feedback-panel { grid-column: auto; grid-row: auto; padding: 26px 20px; }
  .footer-action { padding: 90px 20px; }
  .footer-actions .button { width: 100%; }
  .mobile-state-dock {
    position: fixed; left: 10px; right: 10px; bottom: 8px; z-index: 70;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    min-height: 54px; padding: 10px 14px; border: 1px solid var(--ink);
    background: var(--mint); color: var(--ink); box-shadow: 5px 5px 0 var(--ink);
    text-decoration: none;
  }
  .mobile-state-dock span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; font-weight: 850; text-transform: uppercase; }
  .mobile-state-dock strong { font-size: 1rem; text-align: right; }
  .mobile-state-dock.blocked, .mobile-state-dock.over-budget { background: var(--coral); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .masthead, .tool-row, .ledger-actions, .export-row, .footer-action, .import-dialog, .feedback-controls { display: none !important; }
  .attention, .route-board, .assumptions-band, .evidence-grid { padding: 24px; }
  .workspace, .assumptions-band { display: block; box-shadow: none; }
  .route-summary { color: var(--ink); background: var(--white); }
  .total { color: var(--ink); }
}
