:root {
  color-scheme: light;
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: #182a40;
  background: #edf1f6;
  --ink: #182a40;
  --muted: #4e6075;
  --navy: #142e55;
  --navy-hover: #214478;
  --cobalt: #275ba2;
  --line: #d3deeb;
  --soft: #f3f6fb;
  --white: #fff;
  --teal: #096e66;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 1280px; margin: auto; padding: clamp(.75rem, 3vw, 2.25rem); }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 1.15rem; padding: clamp(.85rem, 2vw, 1.3rem) clamp(1rem, 2.5vw, 1.8rem); background: var(--white); color: var(--navy); border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: .65rem; }
.hero-title { min-width: 0; }
.brand { display: inline-block; color: var(--navy); font-size: .78rem; letter-spacing: .14em; font-weight: 800; text-underline-offset: .25em; }
.hero h1 { font-size: clamp(1.65rem, 3.6vw, 2.3rem); letter-spacing: -.035em; line-height: 1.2; margin: .45rem 0 .3rem; }
.hero p { color: var(--muted); font-size: .94rem; max-width: 63ch; margin: .35rem 0 0; }
.hero-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: .55rem; flex-shrink: 0; }
.hero-actions .primary { width: auto; margin-top: 0; }
p { line-height: 1.62; overflow-wrap: anywhere; }
.progress { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); list-style: none; padding: 0; margin: 1rem 0; gap: .55rem; }
.progress li { display: flex; min-width: 0; }
.progress button { display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 54px; color: #fff; background: var(--navy); border-color: var(--navy); padding: .5rem .65rem; font-size: .88rem; text-align: left; }
.progress button:hover:not(:disabled) { background: var(--navy-hover); border-color: var(--navy-hover); }
.progress button:disabled { background: #273f61; border-color: #273f61; color: #e0e8f4; opacity: 1; }
.progress button[aria-current="step"] { background: #204b81; border-color: #204b81; box-shadow: inset 0 -3px 0 #bcd8ff; }
.step-index { display: grid; place-items: center; flex: 0 0 1.5rem; height: 1.5rem; background: #ffffff27; color: #fff; font-size: .76rem; border-radius: .25rem; font-variant-numeric: tabular-nums; }
.progress [aria-current="step"] .step-index { background: #dbeaff; color: var(--navy); }
.step-label { min-width: 0; word-break: keep-all; overflow-wrap: normal; }
#capacity-form, .results { display: grid; gap: 1rem; align-items: start; }
#capacity-form { grid-template-columns: minmax(0, 1fr) minmax(15rem, 18.5rem); }
#capacity-form > [data-stage] { grid-column: 1; grid-row: 1; min-height: 19rem; }
#capacity-form > .navigation { grid-column: 1; grid-row: 2; }
#capacity-error { grid-column: 1; grid-row: 3; margin: 0; }
#capacity-error:empty { display: none; }
.results { grid-template-columns: minmax(0, 1fr); }
section, .workspace-summary { min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: .65rem; padding: clamp(1rem, 2.5vw, 1.65rem); }
h2 { color: var(--navy); font-size: clamp(1.2rem, 2.2vw, 1.65rem); line-height: 1.35; letter-spacing: -.02em; margin: 0 0 .8rem; }
h3 { color: var(--navy); font-size: 1.02rem; line-height: 1.4; margin: 1.4rem 0 .5rem; }
.hint { color: var(--muted); font-size: .9rem; }
.workspace-summary { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 1rem; padding: 1.15rem; }
.workspace-summary h2 { font-size: 1.1rem; margin-bottom: .8rem; }
.workspace-summary h3 { margin: 1.15rem 0 .5rem; }
.workspace-progress { display: grid; gap: .35rem; }
.workspace-progress p { color: var(--muted); font-size: .84rem; margin: 0; }
progress#workspace-progress { color: var(--teal); accent-color: var(--teal); width: 100%; height: .5rem; }
#workspace-facts { margin: .75rem 0 0; }
#workspace-facts div { display: grid; grid-template-columns: minmax(4rem, 1fr) minmax(0, 1.75fr); gap: .5rem; border-bottom: 1px solid var(--line); padding: .5rem 0; }
#workspace-facts dt { color: var(--muted); overflow-wrap: anywhere; }
#workspace-facts dd { color: var(--ink); font-size: .86rem; margin: 0; overflow-wrap: anywhere; }
.workspace-flow { display: grid; gap: .35rem; max-height: min(20rem, 35vh); overflow: auto; color: var(--ink); padding: 0 .25rem 0 1.35rem; margin: .5rem 0 0; font-size: .88rem; }
.workspace-flow li { overflow-wrap: anywhere; padding: .2rem 0; }
.workspace-flow small { display: block; color: var(--muted); }
.flow-stage-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .75rem 1rem; }
.station { min-width: 0; border: 1px solid var(--line); border-radius: .5rem; margin: .85rem 0; padding: .9rem; }
.station-summary { color: var(--muted); margin: .55rem 0 0; font-variant-numeric: tabular-nums; }
.process-flow { border-left: 2px solid #adc0d8; padding-left: 1rem; margin-bottom: 1rem; }
.flow-endpoint { color: var(--navy); font-size: .83rem; font-weight: 700; display: block; }
legend { font-weight: 700; color: var(--navy); padding: 0 .25rem; }
.station-fields, .conditions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
.dimensions, .production-details { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; }
.industry-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.dimensions, .conditions, .production-details { margin-top: .85rem; }
.group-selector { border: 0; min-width: 0; padding: 0; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.process-groups, .solution-buttons, .catalog-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .65rem; }
.process-groups label { display: flex; gap: .65rem; align-items: center; min-height: 52px; padding: .55rem .75rem; border: 1px solid #b5c6da; border-radius: .45rem; cursor: pointer; }
.process-groups label:hover { background: var(--soft); }
.process-groups label:has(:checked) { background: #ecf3fd; border-color: var(--cobalt); }
.process-groups input { width: 1.1rem; height: 1.1rem; flex-shrink: 0; accent-color: var(--cobalt); }
.process-groups small { display: block; color: var(--teal); font-size: .8rem; font-weight: 600; }
.solution-options button, .catalog-results button { text-align: left; padding: .75rem .85rem; overflow-wrap: anywhere; }
.solution-options button small, .catalog-results button small { display: block; margin-top: .2rem; color: var(--muted); font-size: .8rem; font-weight: 400; }
.solution-order { line-height: 1.65; color: var(--navy); }
.solution-order:empty { display: none; }
.catalog-picker, .station-details { background: var(--soft); border: 1px solid var(--line); border-radius: .5rem; margin-top: .7rem; padding: .85rem; }
.catalog-picker h3 { margin-top: 0; }
.catalog-results { max-height: 22rem; overflow: auto; padding: .3rem; }
.station-details summary { cursor: pointer; color: var(--navy); font-size: .9rem; font-weight: 700; padding: .5rem .15rem; min-height: 44px; }
.station-details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: .7rem; }
.station-details > label { margin-top: .65rem; }
.manual-cost { margin: .85rem 0; padding: .75rem; border: 1px solid var(--line); border-radius: .45rem; background: var(--white); }
.manual-cost input { max-width: 22rem; }
.manual-cost p { margin-bottom: 0; }
label { display: block; color: var(--ink); font-size: .88rem; font-weight: 600; word-break: keep-all; }
select, input, textarea, button { font: inherit; }
select, input:not([type="checkbox"]), textarea { color: var(--ink); background: var(--white); width: 100%; min-height: 44px; margin-top: .4rem; padding: .55rem .65rem; border-radius: .4rem; border: 1px solid #8599b0; }
select:disabled, input:disabled, textarea:disabled { color: var(--muted); background: #eef2f7; }
::placeholder { color: #65768a; opacity: 1; }
textarea { resize: vertical; }
button { cursor: pointer; min-height: 44px; padding: .52rem .83rem; border-radius: .4rem; border: 1px solid #9caec5; background: var(--white); color: var(--navy); font-weight: 700; }
button:hover:not(:disabled) { background: var(--soft); border-color: var(--cobalt); }
button:disabled { opacity: .58; cursor: default; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.primary { width: 100%; background: var(--navy); color: var(--white); border-color: var(--navy); margin-top: .8rem; }
.primary:hover:not(:disabled) { background: var(--navy-hover); border-color: var(--navy-hover); }
.primary:disabled { background: #40597a; opacity: 1; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.navigation { justify-content: flex-end; padding: .7rem .8rem; background: var(--white); border: 1px solid var(--line); border-radius: .5rem; }
.navigation .primary { width: auto; margin-top: 0; min-width: 7rem; }
.station-actions { margin-top: .65rem; }
.error { color: #a12814; font-weight: 600; margin-bottom: 0; }
.error:empty, #review-status:empty { margin: 0; }
#review-status { font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .65rem; }
.metrics:empty { display: none; }
.metrics div { background: var(--soft); border-radius: .45rem; padding: .7rem; }
dt { font-size: .84rem; }
dd { margin: .25rem 0 0; font-size: 1.16rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-summary { display: grid; grid-template-columns: minmax(15rem, 4fr) minmax(0, 6fr); gap: .85rem; margin-top: .85rem; }
.result-summary h3, .result-section-heading h3, .result-breakdown h3:first-child { margin: 0; }
.result-cost-summary, .result-production-summary { min-width: 0; border-radius: .65rem; padding: clamp(.95rem, 2.5vw, 1.4rem); }
.result-cost-summary { display: flex; flex-direction: column; align-items: flex-start; color: var(--white); background: var(--navy); }
.result-cost-summary h3 { color: #d8e7ff; }
.result-cost-summary p { margin: .5rem 0; }
.result-cost-summary #budget-status, .result-cost-summary #result-cost-basis { color: #d8e7ff; font-size: .88rem; }
.result-cost-summary #budget-status { margin-bottom: .85rem; }
.result-cost-summary button { color: #162f59; background: #fff; border-color: #d7e5fb; margin-top: auto; }
.result-cost-summary button:focus-visible { outline-color: #bfdaff; }
.budget-mode { background: #e4edff; color: #1e3b65; padding: .25rem .55rem; border-radius: .25rem; font-size: .8rem; font-weight: 700; }
.budget-total { font-size: clamp(1.3rem, 2.25vw, 1.95rem); font-weight: 800; line-height: 1.35; font-variant-numeric: tabular-nums; overflow-wrap: normal; }
.money-amount { white-space: nowrap; }
.budget-total-prefix { display: block; color: #d8e7ff; font-size: .85rem; font-weight: 700; margin-bottom: .3rem; }
.result-production-summary { background: #f4f7fc; border: 1px solid #d4e0ef; }
.result-production-summary .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: .65rem 0; }
.result-production-summary .metrics div { color: #122d56; background: #fff; border: 1px solid #dee6f2; }
.result-production-summary dt { overflow-wrap: normal; word-break: keep-all; }
.result-production-summary dd { white-space: nowrap; font-size: 1.12rem; }
.result-production-summary p { margin: .55rem 0 0; font-size: .88rem; }
#target-status { color: #193d6a; font-weight: 700; }
.result-flow-section, .result-breakdown { margin-top: 1rem; border-color: #d4e0ef; }
.result-section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.result-section-heading button, .result-flow-card button { color: #183c6d; border-color: #a9bdd9; }
.result-flow-legend { display: flex; gap: .7rem 1.1rem; flex-wrap: wrap; list-style: none; padding: 0; margin: .65rem 0 .25rem; }
.result-flow-legend li { display: inline-flex; gap: .4rem; align-items: center; color: #34495f; font-size: .81rem; }
.result-flow-legend span { width: 1rem; height: .24rem; border-radius: .15rem; background: #527aab; }
.result-flow-legend .legend-bottleneck span { background: #194785; }
.result-flow-legend .legend-branch span { background: #a86316; }
#result-flow-check { min-height: 1.35em; margin: .4rem 0 .6rem; }
.result-flow-cards { display: flex; align-items: stretch; gap: 1.55rem; overflow-x: auto; list-style: none; margin: 0; padding: .2rem .2rem .7rem; }
.result-flow-cards:empty { display: none; }
.result-flow-card { position: relative; flex: 0 0 clamp(12rem, 23vw, 15rem); display: flex; flex-direction: column; gap: .45rem; min-width: 0; padding: .85rem; background: #f4f7fc; color: #173052; border: 1px solid #b7cae1; border-radius: .55rem; overflow-wrap: anywhere; }
.result-flow-card:only-child { flex: 1 1 auto; }
.result-flow-card:not(:last-child)::before { content: ""; position: absolute; width: .85rem; height: 2px; top: 50%; left: calc(100% + .2rem); background: #527aab; }
.result-flow-card:not(:last-child)::after { content: ""; position: absolute; width: .43rem; height: .43rem; top: calc(50% - .15rem); left: calc(100% + .68rem); border-top: 2px solid #527aab; border-right: 2px solid #527aab; transform: rotate(45deg); }
.result-flow-card.is-bottleneck { border: 2px solid #194785; background: #ebf2ff; }
.result-flow-card.has-branch .flow-card-route { border-left-color: #a86316; background: #fff5e6; color: #663d13; }
.result-flow-card h4, .result-flow-card p { margin: 0; }
.result-flow-card p { font-size: .84rem; }
.flow-card-status { align-self: flex-start; display: inline-flex; color: #193d6a; background: #e4edff; font-size: .75rem; font-weight: 700; border-radius: .25rem; padding: .14rem .4rem; }
.flow-card-status.bottleneck-badge { background: #194785; color: #fff; }
.flow-card-status.branch-badge { background: #ffeed4; color: #663d13; }
.flow-card-route { border-left: 3px solid #527aab; background: #fff; padding: .35rem .5rem; }
.flow-card-price { font-variant-numeric: tabular-nums; font-weight: 700; }
.result-flow-card button { margin-top: auto; align-self: flex-start; font-size: .82rem; }
#review-panel { width: min(100%, 44rem); }
#result-inputs span { display: block; }
#budget-details table, #result-process-details table { width: 100%; border-collapse: collapse; font-size: .9rem; }
#budget-details th, #budget-details td, #result-process-details th, #result-process-details td { text-align: left; border-bottom: 1px solid var(--line); padding: .65rem .55rem; overflow-wrap: anywhere; }
#budget-details td { font-variant-numeric: tabular-nums; text-align: right; }
#budget-details thead th, #result-process-details thead th { background: #ecf1f8; color: var(--navy); }
#budget-details tbody tr:nth-child(even), #result-process-details tbody tr:nth-child(even) { background: #f7f9fc; }
#result-process-details { overflow-x: auto; padding: .2rem; }
#result-process-details caption { text-align: left; font-weight: 700; margin: .5rem 0; }
#result-process-details small { display: block; color: var(--muted); line-height: 1.45; font-size: .8rem; margin-top: .3rem; }
.budget-sources { line-height: 1.6; overflow-wrap: anywhere; padding-inline-start: 1.35rem; }
.budget-sources li { margin: .35rem 0; }
.budget-sources a { color: #214f85; text-underline-offset: .18em; }
.source-scope { display: block; color: var(--muted); font-size: .88rem; }
.source-print-url { display: none; }
.print-brand { display: none; }
.consent { display: grid; grid-template-columns: auto 1fr; gap: .5rem; margin-top: .75rem; line-height: 1.55; align-items: start; }
.consent input { width: 1.15rem; height: 1.15rem; margin: .15rem .15rem 0; accent-color: var(--cobalt); }
[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .result-production-summary .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  #capacity-form { grid-template-columns: minmax(0, 1fr); }
  #capacity-form > [data-stage] { min-height: auto; }
  #capacity-form > .workspace-summary { grid-column: 1; grid-row: 4; position: static; top: auto; }
  .progress { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-summary { grid-template-columns: minmax(12rem, 1fr) minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .result-summary { grid-template-columns: minmax(0, 1fr); }
  .result-section-heading { align-items: flex-start; flex-wrap: wrap; }
  .result-flow-cards { flex-direction: column; overflow: visible; }
  .result-flow-card { flex: 0 0 auto; }
  .result-flow-card:not(:last-child)::before { width: 2px; height: .85rem; top: calc(100% + .2rem); left: 1.2rem; }
  .result-flow-card:not(:last-child)::after { top: calc(100% + .68rem); left: calc(1.2rem - .15rem); transform: rotate(135deg); }
}

@media (max-width: 570px) {
  .hero { flex-direction: column; align-items: start; }
  .hero-actions { justify-content: flex-start; }
  .progress button { gap: .35rem; min-height: 50px; padding: .45rem; font-size: .8rem; }
  .dimensions, .production-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .progress { gap: .4rem; }
  .progress button { flex-direction: column; justify-content: center; text-align: center; min-height: 60px; }
  .step-index { flex: none; width: 1.4rem; height: 1.4rem; }
  .station-fields, .conditions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .station-fields label:first-child { grid-column: span 2; }
  .industry-fields { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 365px) {
  .result-production-summary .metrics { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  :root { background: #fff; }
  main { max-width: none; margin: 0; padding: 0; }
  .hero, #progress, #capacity-form, #review-panel, .result-actions, #export-error, #show-cost-details, #edit-flow, .result-flow-card button { display: none !important; }
  .results { display: block; }
  #result { border: 0; padding: 0; }
  .print-brand { display: block; margin-bottom: .4rem; font-weight: 700; }
  .source-print-url { display: block; font-size: .8rem; overflow-wrap: anywhere; }
  .result-cost-summary { background: #fff; color: #173052; border: 1px solid #b7cae1; }
  .result-cost-summary h3, .result-cost-summary #budget-status, .result-cost-summary #result-cost-basis, .budget-total-prefix { color: #173052; }
  .result-production-summary .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-mode { border: 1px solid #b7cae1; }
  .result-flow-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; overflow: visible; }
  .result-flow-card:not(:last-child)::before, .result-flow-card:not(:last-child)::after { content: none; }
  #result-process-details { overflow: visible; }
  th, td, li, .metrics { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}
