:root { font-family: system-ui, sans-serif; color: #172c24; background: #f4f6f1; }
* { box-sizing: border-box; }
body { margin: 0; }
.wrap { max-width: 1360px; margin: auto; padding-inline: clamp(16px, 4vw, 48px); }
header { background: #143d2d; color: #fff; }
.brand { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand strong { font-size: 1.4rem; letter-spacing: .08em; }
.brand span { border-left: 1px solid #83a28b; padding-left: 16px; }
.intro { margin-block: 26px 18px; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.06; max-width: 700px; letter-spacing: -.045em; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 0; }
p { line-height: 1.5; }
.panel { background: white; border: 1px solid #d8e2d8; border-radius: 14px; padding: 18px; }
.setup { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.hint { color: #496153; font-size: .875rem; margin: 8px 0; }
.setup .hint { grid-column: 1 / -1; margin: 0; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; padding-block: 20px 48px; }
.catalog-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.catalog-header h2 { margin: 0; }
.catalog-header input { max-width: 300px; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; max-height: 160px; overflow: auto; padding: 3px; }
.catalog button { cursor: grab; display: grid; justify-items: center; gap: 5px; align-content: center; text-align: center; font-size: .78rem; background: #fff; }
.catalog button img { display: block; width: 100%; max-width: 130px; height: 34px; object-fit: contain; pointer-events: none; }
.catalog button span { pointer-events: none; }
.catalog button[hidden] { display: none; }
.catalog button:active { cursor: grabbing; }
.catalog button[aria-pressed="true"] { outline: 2px solid #19603d; background: #edf7ee; }
.stage-scroll { overflow-x: auto; padding-bottom: 6px; }
#stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); min-width: calc(var(--stage-count, 1) * 160px); margin-top: 12px; border: 1px solid #cfdecf; border-radius: 14px; background: linear-gradient(#e1efe1 0 119px, #efe8d3 119px 151px, #fff 151px); overflow: clip; }
.stage { min-width: 0; padding: 0 7px 10px; border: 0; border-radius: 0; background: transparent; }
.stage + .stage { border-left: 1px solid #cbdacb; }
.stage-tile { display: grid; justify-items: center; width: 100%; min-height: 151px; grid-template-rows: 106px 1fr; align-items: end; background: transparent; border: 0; font-size: .84rem; line-height: 1.2; padding: 4px 3px 8px; }
.stage-tile canvas { display: block; width: 122px; max-width: 100%; height: auto; pointer-events: none; }
.stage-tile span { pointer-events: none; }
.drop-target { outline: 2px dashed #387d51; outline-offset: -3px; background: #eff8ed; }
.drop-target .stage-tile { background: #d5ecd8; }
.stage-add { margin-top: 8px; width: 100%; }
.application { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-top: 8px; padding: 8px; border: 1px solid #d8e2d8; border-radius: 8px; background: #fafcf8; }
.application > label { grid-column: 1 / -1; }
.application > button { font-size: 1rem; min-width: 28px; padding-inline: 6px; }
.application-note { grid-column: 1 / -1; margin: 0; font-size: .75rem; }
.dose-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 3px; }
.dose-arrows { display: grid; gap: 2px; }
.dose-arrows button { min-height: 20px; min-width: 28px; padding: 0 4px; font-size: .75rem; }
label { display: grid; gap: 5px; font-size: .875rem; font-weight: 650; }
input, select, button { font: inherit; border-radius: 8px; min-height: 42px; padding: 8px 10px; }
input, select { width: 100%; color: inherit; border: 1px solid #a8b8ab; background: #fff; }
button { background: #eaf2e9; color: #16422d; border: 1px solid #c4d8c4; font-weight: 650; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
#preset { background: #19603d; color: white; }
[aria-invalid="true"] { border-color: #a32b26; }
:focus-visible { outline: 3px solid #387d51; outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-size: .875rem; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 4px; border-bottom: 1px solid #e1e8de; text-align: right; }
th:first-child { text-align: left; }
td { overflow-wrap: anywhere; }
.stage-output { margin-top: 10px; }
.stage-output summary { font-size: .8rem; cursor: pointer; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: .85rem; }
.chart-legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; }
.legend-applied::before, .chart-applied { background: #8ec875; }
.legend-equivalent::before, .chart-equivalent { background: #19603d; }
.chart-bars { display: grid; gap: 12px; list-style: none; padding: 0; }
.chart-label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: .85rem; }
.chart-track { height: 12px; border-radius: 5px; background: #edf1ec; overflow: hidden; margin-top: 4px; }
.chart-equivalent, .chart-applied { height: 100%; border-radius: 5px; }
.totals details { margin-top: 16px; }
@media (max-width: 720px) {
  .setup { grid-template-columns: 1fr 1fr; }
  #preset { grid-column: 1 / -1; }
}
