.wc-app { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 4px 0 48px; }
.wc-kicker, .wc-filter-title span, .wc-form-heading span {
  margin: 0; color: var(--accent-strong); letter-spacing: .12em; font-size: .64rem; font-weight: 900;
}
.wc-hero { padding: 18px 0 14px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: end; }
.wc-hero h1 { margin: 4px 0 0; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.04em; line-height: 1.08; }

.wc-workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.wc-categories { padding: 14px 12px; background: var(--surface-2); border-right: 1px solid var(--line); min-width: 0; }
.wc-filter-title { display: grid; gap: 2px; margin-bottom: 10px; }
.wc-filter-title strong { font-size: .82rem; }
.wc-category-list { display: grid; gap: 4px; max-height: min(70vh, 640px); overflow: auto; }
.wc-category-list button {
  width: 100%; min-height: 34px; padding: 6px 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
  align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: .74rem; font-weight: 700;
}
.wc-category-list button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; text-align: left; }
.wc-category-list button small { justify-self: end; color: var(--muted); font-size: .64rem; font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.wc-category-list button.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.wc-main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, .72fr); align-items: start; }
.wc-form-panel { min-width: 0; padding: 16px 16px 12px; }
.wc-form-heading { display: flex; justify-content: space-between; gap: 10px; align-items: start; margin-bottom: 12px; }
.wc-form-heading h2 { margin: 3px 0 0; font-size: 1.15rem; letter-spacing: -.03em; }
.wc-section-link {
  min-height: 34px; padding: 0 10px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-strong); font-size: .74rem; font-weight: 800;
  text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.wc-section-link:hover { background: var(--accent); color: #fff; }
.wc-form, .wc-stack { display: grid; gap: 10px; min-width: 0; }
.wc-form label, .wc-stack label, .wc-fields label {
  display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .68rem; font-weight: 800;
}
.wc-form label span, .wc-fields label span { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.wc-form label small, .wc-fields label small { font-weight: 600; color: #8a93a2; }
.wc-form input, .wc-form select {
  width: 100%; min-width: 0; min-height: 38px; height: 38px; padding: 0 8px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: .84rem; box-sizing: border-box;
}
.wc-form select[size] { height: auto; min-height: 148px; padding: 4px; background: var(--surface); }
.wc-form select[size] option { padding: 4px 6px; }
.wc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.wc-common {
  display: grid;
  grid-template-columns: minmax(110px, 1.1fr) 72px minmax(210px, 1.9fr) minmax(110px, 1fr);
  gap: 10px;
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.wc-common:has(#customDensityLabel[hidden]) {
  grid-template-columns: minmax(110px, 1.1fr) 72px minmax(240px, 2fr);
}
.wc-common:has(#lengthLabel[hidden]):has(#customDensityLabel[hidden]) {
  grid-template-columns: 72px minmax(240px, 1fr);
}
.wc-common:has(#lengthLabel[hidden]):not(:has(#customDensityLabel[hidden])) {
  grid-template-columns: 72px minmax(210px, 1.9fr) minmax(110px, 1fr);
}
.wc-pieces { max-width: 72px; }
.wc-remark { margin-top: 1px; }
.wc-grid-2 { display: grid; gap: 10px; }
@media (min-width: 640px) { .wc-grid-2 { grid-template-columns: 1fr 1fr; } }
.wc-results { margin-top: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wc-results div { padding: 10px; border-radius: 10px; background: var(--accent-soft); min-width: 0; }
.wc-results span { display: block; color: var(--muted); font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; }
.wc-results strong { display: block; margin-top: 4px; font-size: 1.02rem; letter-spacing: -.03em; overflow-wrap: anywhere; }
.wc-status { margin: 8px 0 0; color: #b4233c; font-size: .76rem; }
.wc-status.is-success { color: #16805a; }
.wc-result-actions { margin-top: 10px; display: flex; justify-content: flex-end; }

.wc-button {
  min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: .76rem; font-weight: 800; cursor: pointer;
}
.wc-button:disabled { opacity: .48; cursor: not-allowed; }
.wc-button-primary { color: #fff; background: linear-gradient(135deg, var(--accent), #7957ef); box-shadow: 0 7px 18px rgba(68,92,210,.2); }
.wc-button-secondary { color: var(--text); background: var(--surface-2); border-color: var(--line); }

.wc-visual-panel { min-width: 0; padding: 16px; background: var(--surface-2); border-left: 1px solid var(--line); }
.section-visual {
  margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 10px; align-items: center;
  width: 100%; border-radius: 14px; background: linear-gradient(145deg, var(--inverse-surface), var(--inverse-surface-2));
  overflow: hidden;
}
.section-visual svg { width: 100%; height: 225px; display: block; }
.dimension-legend { padding: 14px 10px 14px 0; display: grid; gap: 9px; }
.dimension-item { display: grid; gap: 2px; }
.dimension-item span { color: #8fb2b1; font-size: 8px; text-transform: uppercase; }
.dimension-item strong { color: #fff; font-size: 11px; }

.wc-takeoff {
  margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow); min-width: 0;
}
.wc-takeoff-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.wc-takeoff-header h2 { margin: 3px 0 0; font-size: 1.25rem; letter-spacing: -.03em; }
.wc-takeoff-header p:not(.wc-kicker) { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.wc-takeoff-side { display: grid; justify-items: end; gap: 10px; }
.wc-report-logo { width: 168px; height: 40px; display: grid; place-items: center; background: transparent; }
.wc-report-logo img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: right center; }
.wc-takeoff-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.wc-takeoff-meta { margin-top: 14px; display: grid; grid-template-columns: minmax(150px, .7fr) minmax(220px, 1.5fr); gap: 10px; }
.wc-takeoff-meta label { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; font-weight: 800; }
.wc-takeoff-meta input {
  width: 100%; min-height: 38px; padding: 0 9px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .82rem;
}
.wc-takeoff-empty { margin: 14px 0 0; padding: 20px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: .78rem; }
.wc-takeoff-table-wrap { margin-top: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.wc-takeoff-table { width: 100%; border-collapse: collapse; min-width: 1160px; font-size: .72rem; }
.wc-takeoff-table th, .wc-takeoff-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.wc-takeoff-table thead th { color: var(--muted); background: var(--surface-2); font-size: .62rem; letter-spacing: .04em; text-transform: uppercase; }
.wc-takeoff-table tbody td:nth-child(1), .wc-takeoff-table tbody td:nth-child(4), .wc-takeoff-table tbody td:nth-child(5),
.wc-takeoff-table tbody td:nth-child(6), .wc-takeoff-table tbody td:nth-child(7) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.wc-takeoff-table tfoot th { border: 0; background: var(--accent-soft); color: var(--text); }
.wc-takeoff-table tfoot th:first-child { text-align: right; }
.wc-editable-cell { min-width: 88px; }
.wc-row-edit { display: inline-grid; grid-template-columns: minmax(58px, 76px) auto; align-items: center; gap: 5px; }
.wc-row-edit-quantity { grid-template-columns: minmax(48px, 62px); }
.wc-row-edit small { color: var(--muted); font-size: .66rem; font-weight: 800; }
.wc-remarks-cell { min-width: 170px; }
.wc-row-input {
  width: 100%; height: 30px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-2); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; text-align: right;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.wc-row-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.wc-row-input[aria-invalid="true"] { border-color: #b4233c; box-shadow: 0 0 0 3px color-mix(in srgb, #b4233c 12%, transparent); }
.wc-row-remarks { min-width: 150px; text-align: left; padding: 0 8px; }
.wc-row-actions { display: flex; align-items: center; gap: 4px; min-width: 92px; }
.wc-row-action {
  width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--muted); cursor: pointer; transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}
.wc-row-action:hover:not(:disabled), .wc-row-action:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.wc-row-action:disabled { opacity: .35; cursor: not-allowed; }
.wc-row-remove { color: #b4233c; }
.wc-row-remove:hover:not(:disabled), .wc-row-remove:focus-visible { color: #b4233c; border-color: #b4233c; background: color-mix(in srgb, #b4233c 10%, var(--surface)); }
.wc-print-only { display: none; }
.wc-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

[hidden] { display: none !important; }

@media (max-width: 960px) {
  .wc-workspace { grid-template-columns: 1fr; }
  .wc-categories { border-right: 0; border-bottom: 1px solid var(--line); }
  .wc-category-list { max-height: none; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 820px) {
  .wc-main { grid-template-columns: 1fr; }
  .wc-visual-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .wc-common, .wc-common:has(#customDensityLabel[hidden]), .wc-common:has(#lengthLabel[hidden]),
  .wc-common:has(#lengthLabel[hidden]):has(#customDensityLabel[hidden]) { grid-template-columns: 1fr; }
  .wc-pieces { max-width: none; }
  .wc-takeoff-header { display: grid; }
  .wc-takeoff-side { justify-items: start; }
  .wc-report-logo img { object-position: left center; }
  .wc-takeoff-actions { justify-content: start; }
  .wc-takeoff-meta { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wc-results { grid-template-columns: 1fr; }
  .wc-form-heading { flex-direction: column; }
  .section-visual { grid-template-columns: 1fr; }
  .dimension-legend { padding: 0 14px 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@page { size: A4 portrait; margin: 11mm; }
@media print {
  body { background: #fff !important; color: #111 !important; }
  .global-header, .wc-hero, .wc-workspace, .site-footer, .stru-ad-rail, .donation-popup, .wc-takeoff-actions, .wc-screen-only, .wc-screen-edit { display: none !important; }
  .wc-print-only { display: inline !important; }
  .wc-app { width: 100%; margin: 0; padding: 0; }
  .wc-takeoff { margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
  .wc-takeoff-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4mm; margin-bottom: 4mm; }
  .wc-takeoff-side { display: block; justify-self: end; }
  .wc-report-logo { width: 40mm; height: 10mm; }
  .wc-report-logo img { object-position: right center; }
  .wc-takeoff-header h2 { color: #111; font-size: 17pt; }
  .wc-takeoff-header p:not(.wc-kicker) { display: none; }
  .wc-kicker { color: #245fd4 !important; }
  .wc-takeoff-meta { margin: 0 0 4mm; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); gap: 3mm; }
  .wc-takeoff-meta.wc-print-single { grid-template-columns: 1fr; }
  .wc-takeoff-meta.wc-print-all-empty, .wc-takeoff-meta label.wc-print-omit { display: none !important; }
  .wc-takeoff-meta label { color: #333; }
  .wc-takeoff-meta input { min-height: 7mm; border: 1px solid #aaa; border-radius: 0; background: #fff; color: #111; }
  .wc-takeoff-table-wrap { margin: 0; overflow: visible; border: 1px solid #888; border-radius: 0; }
  .wc-takeoff-table { min-width: 0; table-layout: fixed; font-size: 6.8pt; color: #111; }
  .wc-takeoff-table th, .wc-takeoff-table td { padding: 1.7mm 1.1mm; border-color: #aaa; overflow-wrap: anywhere; }
  .wc-takeoff-table :is(th, td):nth-child(1) { width: 5%; }
  .wc-takeoff-table :is(th, td):nth-child(2) { width: 18%; }
  .wc-takeoff-table :is(th, td):nth-child(3) { width: 18%; }
  .wc-takeoff-table :is(th, td):nth-child(4) { width: 9%; }
  .wc-takeoff-table :is(th, td):nth-child(5) { width: 6%; }
  .wc-takeoff-table :is(th, td):nth-child(6) { width: 12%; }
  .wc-takeoff-table :is(th, td):nth-child(7) { width: 13%; }
  .wc-takeoff-table :is(th, td):nth-child(8) { width: 19%; }
  .wc-takeoff-table thead th { background: #e9eef8 !important; color: #222; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .wc-takeoff-table tfoot th { background: #eef3ff !important; color: #111; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
