:root {
  --ink: #18231f;
  --muted: #66736e;
  --line: #dfe6e2;
  --soft: #f4f7f5;
  --paper: #ffffff;
  --green: #176b52;
  --green-dark: #0e4f3c;
  --green-soft: #e7f3ed;
  --gold: #d69a2d;
  --danger: #b63a3a;
  --warning: #9a6814;
  --shadow: 0 16px 45px rgba(24, 52, 42, .08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: #edf2ef;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 0 0, #f8faf9 0, transparent 34%), #edf2ef; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 64px;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: rgba(255, 255, 255, .93);
  border-bottom: 1px solid rgba(207, 219, 213, .8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-actions { display: flex; align-items: center; gap: 14px; }
.source-badge { font-size: 12px; color: var(--green); background: var(--green-soft); padding: 8px 11px; border-radius: 999px; display: flex; align-items: center; gap: 7px; font-weight: 700; }
.source-badge span { width: 7px; height: 7px; border-radius: 50%; background: #2f9b72; box-shadow: 0 0 0 4px rgba(47,155,114,.12); }
.button { border: 0; padding: 10px 15px; border-radius: 10px; font-weight: 700; font-size: 13px; }
.button.primary { color: white; background: var(--green); box-shadow: 0 6px 14px rgba(23,107,82,.18); }
.button.primary:hover { background: var(--green-dark); }
.button.ghost { color: var(--ink); background: var(--soft); }

.workspace { max-width: 1480px; margin: 28px auto 64px; padding: 0 28px; display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 24px; align-items: start; }
.form-column { display: grid; gap: 18px; min-width: 0; }
.card, .result-card, .audit-card { background: var(--paper); border: 1px solid rgba(211, 222, 217, .88); border-radius: 18px; box-shadow: var(--shadow); }
.section-card { padding: 26px; }
.intro-card { min-height: 152px; padding: 28px 30px; color: white; display: flex; align-items: center; justify-content: space-between; gap: 30px; overflow: hidden; background: linear-gradient(122deg, #124c3b 0%, #176b52 66%, #238564 100%); position: relative; }
.intro-card::after { content: ""; position: absolute; width: 270px; height: 270px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; right: -95px; top: -120px; box-shadow: 0 0 0 42px rgba(255,255,255,.04), 0 0 0 84px rgba(255,255,255,.025); }
.intro-card > * { position: relative; z-index: 1; }
.intro-card h2 { font-size: 25px; margin: 6px 0 8px; letter-spacing: .01em; }
.intro-card p { margin: 0; color: rgba(255,255,255,.73); font-size: 13px; }
.eyebrow { margin: 0; font-size: 10px !important; letter-spacing: .18em; font-weight: 800; text-transform: uppercase; color: #8dd0b6 !important; }
.formula-chip { min-width: 270px; padding: 15px 17px; border: 1px solid rgba(255,255,255,.15); border-radius: 13px; background: rgba(255,255,255,.08); backdrop-filter: blur(6px); }
.formula-chip span { display: block; font-size: 10px; color: #9ed9c2; margin-bottom: 6px; }
.formula-chip strong { font-size: 13px; }

.section-heading { display: flex; gap: 13px; align-items: center; margin-bottom: 22px; }
.section-heading .step { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 800; }
.section-heading h3 { font-size: 17px; margin: 0 0 4px; }
.section-heading p { font-size: 12px; color: var(--muted); margin: 0; }
.process-heading .selected-count { margin-left: auto; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 7px 10px; font-size: 11px; font-weight: 800; white-space: nowrap; }

.field-grid { display: grid; gap: 15px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.material-row, .optional-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid #edf1ef; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span { color: #45504c; font-size: 12px; font-weight: 700; }
.field > span b { color: var(--danger); }
.field small { color: #8a9591; font-size: 10px; margin-top: -3px; }
.field input, .field select { width: 100%; height: 43px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fbfcfb; padding: 0 12px; outline: none; transition: .16s ease; }
.field input:focus, .field select:focus, .compact-input input:focus { border-color: #58a286; box-shadow: 0 0 0 3px rgba(39,131,97,.1); background: white; }
.input-unit { display: flex; position: relative; }
.input-unit input { padding-right: 56px; }
.input-unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #8b9692; font-size: 11px; font-style: normal; pointer-events: none; }
.danger-text { color: var(--danger) !important; font-weight: 700; }

.cut-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice-card { min-height: 76px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; position: relative; display: flex; flex-direction: column; justify-content: center; gap: 5px; color: var(--muted); font-size: 11px; transition: .16s ease; }
.choice-card input { position: absolute; opacity: 0; }
.choice-card:has(input:checked) { border-color: var(--green); background: #f3faf7; box-shadow: inset 0 0 0 1px var(--green); }
.choice-card:has(input:checked)::after { content: "✓"; position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: white; font-size: 11px; }
.choice-title { color: var(--ink); font-size: 13px; font-weight: 800; }
.detail-fields { margin-top: 16px; }
.switch-field { min-height: 64px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; flex-direction: row; align-items: center; justify-content: space-between; background: #fbfcfb; }
.switch-field span { display: flex; flex-direction: column; gap: 6px; }
.switch-field small { margin: 0; }
.switch { width: 38px !important; height: 22px !important; accent-color: var(--green); }

.process-groups { display: grid; gap: 10px; }
.process-group { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.process-group summary { list-style: none; cursor: pointer; min-height: 48px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; background: #fafcfb; font-size: 13px; font-weight: 800; }
.process-group summary::-webkit-details-marker { display: none; }
.process-group summary::before { content: "+"; color: var(--green); margin-right: 10px; }
.process-group[open] summary::before { content: "−"; }
.process-group summary span { margin-right: auto; }
.process-group summary small { color: #92a09b; font-weight: 500; }
.process-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; border-top: 1px solid #edf1ef; }
.process-card { border: 1px solid #e4eae7; border-radius: 10px; background: white; overflow: hidden; }
.process-main { min-height: 70px; padding: 12px; display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.process-main > input { position: absolute; opacity: 0; }
.check-ui { flex: 0 0 auto; width: 18px; height: 18px; border: 1.5px solid #b9c6c0; border-radius: 5px; margin-top: 1px; display: grid; place-items: center; }
.process-main input:checked + .check-ui { background: var(--green); border-color: var(--green); }
.process-main input:checked + .check-ui::after { content: "✓"; color: white; font-size: 11px; font-weight: 900; }
.process-main strong { display: block; font-size: 12px; margin-bottom: 5px; }
.process-main small { display: block; color: #85918c; font-size: 10px; line-height: 1.45; }
.process-card:has(.process-check:checked) { border-color: #75b39b; box-shadow: inset 0 0 0 1px rgba(23,107,82,.16); }
.process-card:has(.process-check:not(:checked)) .process-config { display: none; }
.process-config { padding: 10px 12px 12px 39px; border-top: 1px dashed #e4eae7; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; background: #f8fbf9; }
.process-config > label { color: #68746f; font-size: 10px; display: grid; gap: 5px; }
.process-config label em { margin-left: 5px; color: var(--gold); font-style: normal; }
.compact-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: white; }
.compact-input input, .process-config > label > input { min-width: 0; width: 100%; height: 32px; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: white; font-size: 11px; }
.compact-input input { border: 0; }
.compact-input b { color: #8c9793; padding-right: 7px; font-size: 9px; white-space: nowrap; }
.process-config .inline-check { display: flex; flex-direction: row; align-items: center; gap: 5px; }
.process-config .inline-check input { width: 14px; height: 14px; accent-color: var(--green); }
.minimum-toggle { margin-top: 18px; padding: 15px; border-radius: 11px; background: var(--green-soft); display: flex; gap: 11px; align-items: center; cursor: pointer; }
.minimum-toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.minimum-toggle span { display: flex; flex-direction: column; gap: 4px; }
.minimum-toggle strong { font-size: 12px; }
.minimum-toggle small { color: #5e796e; font-size: 10px; }

.result-column { position: sticky; top: 102px; display: grid; gap: 14px; }
.result-card { overflow: hidden; }
.result-head { padding: 23px 23px 18px; display: flex; justify-content: space-between; align-items: flex-start; }
.result-head h2 { font-size: 21px; margin: 5px 0 0; }
.status { font-size: 10px; font-weight: 800; padding: 7px 10px; border-radius: 999px; }
.status.valid { color: var(--green); background: var(--green-soft); }
.status.caution { color: var(--warning); background: #fff2d9; }
.status.invalid { color: var(--danger); background: #fde9e9; }
.message { margin: 0 20px 12px; padding: 11px 13px; border-radius: 9px; font-size: 10px; line-height: 1.45; }
.message strong { display: block; margin-bottom: 4px; }
.message p { margin: 2px 0; }
.message.error { color: #8d2828; background: #fff0f0; border: 1px solid #f6d0d0; }
.message.warning { color: #7c5614; background: #fff8e9; border: 1px solid #efdfb7; }
.area-summary { margin: 0 20px 17px; padding: 13px; display: grid; grid-template-columns: 1.35fr 1fr 1fr; border-radius: 11px; background: #f4f7f5; gap: 8px; }
.area-summary div { min-width: 0; }
.area-summary span { display: block; color: #7f8b86; font-size: 9px; margin-bottom: 5px; }
.area-summary strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-items { max-height: 365px; overflow-y: auto; border-top: 1px solid #edf1ef; }
.line-item { padding: 13px 21px; border-bottom: 1px solid #edf1ef; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.line-item > div:first-child { min-width: 0; }
.line-item strong { display: block; font-size: 12px; margin: 3px 0; }
.line-item small { display: block; color: #8a9691; font-size: 9px; line-height: 1.35; }
.line-group { display: inline-block; color: var(--green); background: var(--green-soft); border-radius: 4px; padding: 2px 5px; font-size: 8px; font-weight: 700; }
.line-money { flex: 0 0 auto; text-align: right; }
.line-money strong { font-variant-numeric: tabular-nums; }
.line-money small { color: var(--gold); }
.empty-state { padding: 35px 20px; text-align: center; color: var(--muted); font-size: 11px; }
.totals { padding: 18px 22px 12px; background: #fbfcfb; }
.totals > div { display: flex; justify-content: space-between; align-items: center; min-height: 29px; color: #64706b; font-size: 11px; }
.totals > div strong { color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
.totals .zero { opacity: .55; }
.totals .grand-total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 16px; min-height: 48px; color: var(--ink); font-size: 14px; font-weight: 800; }
.totals .grand-total strong { color: var(--green); font-size: 28px; letter-spacing: -.02em; }
.totals .unit-total strong { color: var(--green); }
.result-note { margin: 0; padding: 0 22px 20px; color: #8c9692; background: #fbfcfb; font-size: 9px; line-height: 1.5; }
.audit-card { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; }
.audit-icon { flex: 0 0 auto; width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); font-weight: 900; }
.audit-card strong { font-size: 11px; }
.audit-card p { color: var(--muted); font-size: 9px; margin: 4px 0 0; line-height: 1.45; }

[hidden] { display: none !important; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 360px; padding: 0 18px; }
  .process-list { grid-template-columns: 1fr; }
  .intro-card { align-items: flex-start; }
  .formula-chip { min-width: 220px; }
}

@media (max-width: 840px) {
  .topbar { min-height: 60px; padding: 10px 16px; }
  .source-badge, .button.ghost { display: none; }
  .workspace { display: block; margin-top: 16px; padding: 0 12px; }
  .result-column { position: static; margin-top: 18px; }
  .intro-card { display: block; }
  .formula-chip { margin-top: 20px; }
  .field-grid.three, .field-grid.two, .cut-options { grid-template-columns: 1fr; }
  .process-list { grid-template-columns: 1fr; }
  .area-summary { grid-template-columns: 1fr 1fr; }
  .area-summary div:first-child { grid-column: 1 / -1; }
}

@media print {
  body { background: white; }
  .topbar, .form-column, .audit-card { display: none !important; }
  .workspace { display: block; margin: 0; padding: 0; max-width: none; }
  .result-column { position: static; }
  .result-card { box-shadow: none; border: 0; }
  .line-items { max-height: none; overflow: visible; }
}
