:root {
  color-scheme: light;
  --background: #f1f3ee;
  --background-deep: #e3e7df;
  --surface: #fbfcf9;
  --ink: #0d1114;
  --ink-soft: #565d54;
  --ink-muted: #858c82;
  --border: #d0d5cd;
  --brand-black: #0b0f12;
  --accent: #929b84;
  --accent-dark: #727b68;
  --accent-soft: #e5e9e0;
  --green: #66715e;
  --green-soft: #e2e8de;
  --remainder: #356f55;
  --remainder-soft: #d9eadf;
  --amber: #8b6e48;
  --amber-soft: #f1e9dc;
  --danger: #a34a3d;
  --danger-soft: #f3e4e1;
  --kerf: #c62828;
  --kerf-soft: #fde3e1;
  --radius: 12px;
  --shadow: 0 10px 30px rgb(32 33 29 / 7%);
  --font-sans: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Helvetica Neue", Helvetica, Arial, ui-sans-serif, system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  color: var(--brand-black);
  background: var(--accent);
  box-shadow: 0 2px 12px rgb(45 50 41 / 20%);
}

.site-header-main {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 9px clamp(18px, 3vw, 40px);
}

.brand {
  display: flex;
  min-width: 0;
  flex: 0 0 auto;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 146px;
  height: 45px;
  object-fit: contain;
  filter: none;
}

.header-note {
  color: rgb(11 15 18 / 62%);
  font-size: 0.7rem;
}

.header-note {
  flex: 0 0 auto;
  margin: 0;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.workspace-bar {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 3px 12px rgb(11 15 18 / 5%);
}

.profile-navigation {
  display: flex;
  min-width: 0;
  overflow: hidden;
  align-self: stretch;
  flex: 1 1 auto;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding-top: 9px;
  transform: translateY(9px);
}

.profile-tabs {
  display: flex;
  min-width: 0;
  flex: 0 1 auto;
  align-items: end;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.profile-tabs::-webkit-scrollbar {
  display: none;
}

.profile-tab-item {
  position: relative;
  min-width: 120px;
  max-width: 220px;
  flex: 0 0 auto;
}

.profile-tab {
  position: relative;
  width: 100%;
  min-height: 40px;
  overflow: hidden;
  padding: 0 34px 0 13px;
  border: 1px solid rgb(11 15 18 / 15%);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  color: var(--ink-soft);
  background: rgb(229 233 224 / 68%);
  font-size: 0.74rem;
  font-weight: 650;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tab:not([aria-selected="true"]):hover {
  color: var(--brand-black);
  background: rgb(241 243 238 / 88%);
}

.profile-tab:focus-visible {
  outline: 2px solid var(--brand-black);
  outline-offset: -3px;
}

.profile-tab::after {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  content: "";
  background: var(--border);
  transform: translateY(-50%);
}

.profile-tab[data-calculated="true"]::after {
  background: var(--remainder);
}

.profile-tab[data-pending="true"]::after {
  background: var(--amber);
}

.profile-tab[aria-selected="true"] {
  z-index: 1;
  border-color: rgb(11 15 18 / 18%);
  border-bottom-color: var(--surface);
  color: var(--brand-black);
  background: var(--surface);
  box-shadow: 0 -2px 7px rgb(11 15 18 / 10%);
  font-weight: 750;
}

.profile-tab-close {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: 5px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  place-items: center;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 130ms, color 130ms, background 130ms;
}

.profile-tab-item:hover .profile-tab-close,
.profile-tab-item:focus-within .profile-tab-close,
.profile-tab[aria-selected="true"] + .profile-tab-close {
  opacity: 1;
}

.profile-tab-item:hover .profile-tab::after,
.profile-tab-item:focus-within .profile-tab::after,
.profile-tab[aria-selected="true"]::after {
  opacity: 0;
}

.profile-tab-close:hover,
.profile-tab-close:focus-visible {
  color: var(--kerf);
  background: var(--kerf-soft);
}

.profile-tab-close:focus-visible {
  outline: 2px solid var(--kerf);
  outline-offset: -2px;
}

.profile-tab-close:disabled {
  color: var(--ink-muted);
  background: transparent;
  cursor: not-allowed;
  opacity: 0.35;
}

@media (hover: none) {
  .profile-tab-close {
    opacity: 1;
  }

  .profile-tab-item .profile-tab::after {
    opacity: 0;
  }
}

.button-add-profile {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 8px 8px 0 0;
  color: var(--brand-black);
  background: transparent;
}

.button-add-profile span:first-child {
  margin: 0;
  font-size: 1.2rem;
}

.button-add-profile:hover {
  background: rgb(255 255 255 / 30%);
}

.button-add-profile:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.general-summary {
  border-top: 1px solid var(--border);
}

.general-summary summary {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(16px, 3vw, 40px);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  list-style: none;
}

.general-summary summary::-webkit-details-marker {
  display: none;
}

.general-summary summary:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: -3px;
}

.general-summary summary::before {
  content: "+";
}

.general-summary[open] summary::before {
  content: "−";
}

.general-summary summary > span:first-child {
  margin-right: auto;
}

.summary-status {
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 500;
}

.general-summary-content {
  padding: 0 clamp(16px, 3vw, 40px) 14px;
  overflow-x: auto;
}

.general-summary-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 4px clamp(16px, 3vw, 40px) 8px;
}

.print-help {
  margin-right: auto;
  color: var(--ink-muted);
  font-size: 0.65rem;
  line-height: 1.35;
}

.button-print {
  min-height: 38px;
  padding: 0 14px;
  color: var(--brand-black);
  background: var(--accent);
}

.button-print:hover {
  background: var(--accent-dark);
}

.button-print:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.summary-empty {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 0.74rem;
}

.summary-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.summary-table th,
.summary-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.summary-table th:first-child,
.summary-table td:first-child {
  text-align: left;
}

.summary-table th {
  color: var(--ink-muted);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-table tfoot td {
  border-bottom: 0;
  color: var(--ink);
  font-weight: 700;
}

.print-report {
  display: none;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  background: var(--surface);
  font-size: 0.64rem;
  text-align: center;
}

.save-status {
  color: var(--accent-dark);
}

.clear-storage-button {
  padding: 2px 5px;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.clear-storage-button:hover,
.clear-storage-button:focus-visible {
  color: var(--danger);
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.developer-logo {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  object-fit: contain;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
}

.confirmation-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 22px 70px rgb(11 15 18 / 28%);
}

.confirmation-dialog::backdrop {
  background: rgb(11 15 18 / 48%);
  backdrop-filter: blur(2px);
}

.confirmation-dialog form {
  display: grid;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.confirmation-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  border-radius: 50%;
  place-items: center;
  color: var(--kerf);
  background: var(--kerf-soft);
  font-size: 1.1rem;
  font-weight: 800;
}

.confirmation-dialog h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.confirmation-dialog p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.55;
}

.confirmation-actions {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.button-dialog-cancel,
.button-dialog-confirm {
  min-width: 110px;
  padding: 0 14px;
}

.button-dialog-cancel {
  border: 1px solid var(--border);
  color: var(--ink-soft);
  background: var(--background);
}

.button-dialog-confirm {
  color: white;
  background: var(--kerf);
}

.button-dialog-confirm:hover {
  background: #a91f1f;
}

.app-shell {
  display: grid;
  min-height: calc(100vh - 106px);
  grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
}

.control-panel {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.control-panel form {
  position: sticky;
  top: 68px;
  display: flex;
  max-height: calc(100vh - 68px);
  flex-direction: column;
  overflow: auto;
}

.form-section {
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.cuts-section {
  flex: 1;
}

.submit-section {
  position: sticky;
  bottom: 0;
  background: rgb(255 253 250 / 94%);
  backdrop-filter: blur(8px);
}

.submit-section .live-summary {
  margin: 0 0 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin: 0 0 16px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.67rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-heading .section-title {
  margin-bottom: 0;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 10px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 600;
}

.field small {
  color: var(--ink-muted);
  font-weight: 500;
}

.field-wide {
  grid-column: 1 / -1;
}

.measurement-hint {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 0.66rem;
}

input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  background: var(--background);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  transition: border-color 150ms, box-shadow 150ms, background 150ms;
}

input:focus-visible {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgb(146 155 132 / 22%);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.section-actions {
  display: flex;
  gap: 4px;
}

.button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  transition: color 130ms, border-color 130ms, background 130ms, transform 130ms;
}

.button:focus-visible {
  outline: 3px solid rgb(146 155 132 / 38%);
  outline-offset: 2px;
}

.button:active {
  transform: translateY(1px);
}

.button-quiet {
  min-height: 34px;
  padding: 0 8px;
  color: var(--ink-muted);
  background: transparent;
}

.button-quiet:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.cuts-columns,
.cut-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 40px;
  gap: 7px;
}

.cut-row > label {
  min-width: 0;
}

.cuts-columns {
  margin-top: 16px;
  padding: 0 3px 6px;
  color: var(--ink-muted);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cut-row {
  align-items: center;
  margin-bottom: 7px;
  animation: row-in 160ms ease-out;
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.button-remove {
  padding: 0;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  background: transparent;
  font-size: 1.15rem;
}

.button-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.button-add {
  width: 100%;
  margin-top: 3px;
  border: 1px dashed #bbb9b0;
  color: var(--ink-soft);
  background: transparent;
}

.button-add:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

.button-add:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.live-summary {
  display: grid;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  grid-template-columns: repeat(3, 1fr);
  color: var(--ink-soft);
  background: var(--background);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-align: center;
}

.live-summary span + span {
  border-left: 1px solid var(--border);
}

.live-summary strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 0.75rem;
}

.button-primary {
  width: 100%;
  min-height: 48px;
  color: var(--brand-black);
  background: var(--accent);
  box-shadow: 0 5px 14px rgb(76 84 69 / 20%);
}

.button-primary:hover {
  background: var(--accent-dark);
}

.form-error,
.input-feedback {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 0.76rem;
  line-height: 1.45;
}

.form-error,
.input-feedback[data-level="error"] {
  color: #7f3027;
  background: var(--danger-soft);
}

.input-feedback[data-level="warning"] {
  color: #77582f;
  background: var(--amber-soft);
}

.results-panel {
  min-width: 0;
  padding: clamp(22px, 3.5vw, 46px);
}

.empty-state {
  display: grid;
  min-height: 65vh;
  place-content: center;
  justify-items: center;
  color: var(--ink-muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 78px;
  height: 78px;
  margin-bottom: 18px;
  border: 2px dashed #c5c2b9;
  border-radius: var(--radius);
  place-items: center;
  font-size: 1.8rem;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.empty-state p {
  max-width: 320px;
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.6;
}

.result-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.result-heading h2 {
  overflow-wrap: anywhere;
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
}

.result-meta,
.result-time {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 0.73rem;
}

.result-time {
  flex: 0 0 auto;
  font-family: var(--font-mono);
}

.profile-pill {
  display: inline-block;
  margin-right: 7px;
  padding: 3px 8px;
  border-radius: 5px;
  color: var(--green);
  background: var(--green-soft);
  font-family: var(--font-mono);
  font-size: 0.67rem;
}

.method-pill {
  display: inline-block;
  margin-left: 7px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 700;
}

.method-optimal {
  color: var(--remainder);
  background: var(--remainder-soft);
}

.method-ffd {
  color: var(--amber);
  background: var(--amber-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card,
.efficiency-card,
.bar-card,
.purchase-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  min-width: 0;
  padding: 16px;
}

.stat-label,
.bars-title {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-number {
  overflow-wrap: anywhere;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  font-weight: 700;
  line-height: 1;
}

.stat-number small {
  font-size: 0.75rem;
}

.stat-note {
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 0.67rem;
}

.stat-accent .stat-number { color: var(--accent); }
.stat-green .stat-number { color: var(--green); }
.stat-amber .stat-number { color: var(--amber); }
.stat-kerf .stat-number { color: var(--kerf); }

.kerf-tolerance-note {
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid rgb(139 110 72 / 38%);
  border-radius: 8px;
  color: #6e5536;
  background: var(--amber-soft);
  font-size: 0.72rem;
  line-height: 1.5;
}

.efficiency-card {
  margin: 22px 0;
  padding: 17px 19px;
}

.efficiency-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
}

.efficiency-track {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--background-deep);
}

.efficiency-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  animation: fill-in 550ms ease-out both;
  transform-origin: left;
}

@keyframes fill-in {
  from { transform: scaleX(0); }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 22px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border: 1px solid;
  border-radius: 3px;
}

.legend-kerf {
  border-color: var(--kerf);
  background: repeating-linear-gradient(90deg, var(--kerf) 0 3px, var(--kerf-soft) 3px 5px);
}

.legend-remainder {
  border-color: var(--remainder);
  background: var(--remainder-soft);
}

.bars-title {
  margin: 0 0 12px;
}

.bar-card {
  overflow: hidden;
  margin-bottom: 11px;
}

.bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.bar-name {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.bar-badges,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bar-badges {
  justify-content: flex-end;
}

.badge,
.tag {
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
}

.badge-neutral { color: var(--ink-soft); background: var(--background-deep); }
.badge-quantity {
  border-color: rgb(104 114 95 / 28%);
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 800;
}
.badge-good { color: var(--green); background: var(--green-soft); }
.badge-medium { color: var(--amber); background: var(--amber-soft); }
.badge-high { color: var(--accent); background: var(--accent-soft); }

.bar-body {
  padding: 15px;
}

.visual-bar {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 36px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
}

.segment {
  position: relative;
  display: grid;
  min-width: 1px;
  height: 100%;
  overflow: hidden;
  place-items: center;
  border-right: 1px solid rgb(255 255 255 / 60%);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  white-space: nowrap;
}

.segment-with-kerf::after {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  content: "";
  background: var(--kerf);
}

.segment-remainder {
  border-left: 1px solid rgb(53 111 85 / 35%);
  border-right: 0;
  color: var(--remainder);
  background: repeating-linear-gradient(45deg, var(--remainder-soft), var(--remainder-soft) 5px, #edf4ef 5px, #edf4ef 10px);
}

.tag-remainder {
  border-color: rgb(53 111 85 / 35%);
  color: var(--remainder);
  background: var(--remainder-soft);
  font-size: 0.68rem;
}

.tag-kerf {
  border-color: rgb(198 40 40 / 38%);
  color: var(--kerf);
  background: var(--kerf-soft);
  font-weight: 700;
}

.tag-tolerance {
  border-color: rgb(139 110 72 / 38%);
  color: #6e5536;
  background: var(--amber-soft);
}

.purchase-summary {
  margin-top: 24px;
  padding: 17px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.7;
}

.purchase-summary h3 {
  margin: 0 0 5px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.purchase-summary p {
  margin: 0;
}

.purchase-summary .purchase-tolerance {
  margin-top: 6px;
  color: #6e5536;
  font-weight: 650;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .control-panel form {
    position: static;
    max-height: none;
  }

  .submit-section {
    position: static;
  }
}

@media (max-width: 900px) {
  .site-header-main {
    gap: 12px;
    padding-right: 20px;
    padding-left: 20px;
  }

  .brand img {
    width: 118px;
    height: 38px;
  }

  .header-note {
    display: none;
  }
}

@media (max-width: 650px) {
  .site-header-main {
    min-height: 58px;
    gap: 8px;
    padding: 7px 16px;
  }

  .brand img {
    width: 102px;
    height: 36px;
  }

  .profile-navigation {
    gap: 6px;
    transform: translateY(7px);
  }

  .profile-tab-item {
    min-width: 112px;
    max-width: 180px;
  }

  .button-add-profile {
    width: 42px;
    padding: 0;
  }

  .button-add-profile span:first-child {
    margin: 0;
  }

  .general-summary summary {
    min-height: 42px;
  }

  .general-summary-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .button-print {
    width: 100%;
  }

  .form-section,
  .results-panel {
    padding: 20px 16px;
  }

  .button {
    min-height: 44px;
  }

  body.has-mobile-dock {
    padding-bottom: 180px;
  }

  body.has-mobile-dock .submit-section {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 10px 16px 12px;
    border-top: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 -8px 24px rgb(11 15 18 / 12%);
  }

  body.has-mobile-dock .submit-section .live-summary {
    margin-bottom: 8px;
    padding: 6px 8px;
  }

  body.has-mobile-dock .submit-section .live-summary strong {
    display: inline;
    margin: 0 0 0 4px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .result-time {
    margin: 0;
  }
}

@media (max-width: 390px) {
  .config-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .cuts-columns,
  .cut-row {
    grid-template-columns: minmax(0, 1fr) 78px 40px;
  }

  .confirmation-actions {
    flex-direction: column-reverse;
  }

  .button-dialog-cancel,
  .button-dialog-confirm {
    width: 100%;
  }
}

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

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  :root {
    color-scheme: light;
  }

  html,
  body {
    min-width: 0;
    color: #111;
    background: #fff;
  }

  body {
    padding: 0 !important;
  }

  body > :not(.print-report) {
    display: none !important;
  }

  .print-report {
    display: block;
    font-size: 9pt;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 7mm;
    border-bottom: 2px solid var(--accent-dark);
  }

  .print-header img {
    width: 48mm;
    height: 15mm;
    object-fit: contain;
  }

  .print-header-copy {
    text-align: right;
  }

  .print-header h1 {
    margin: 0 0 2mm;
    font-size: 18pt;
  }

  .print-header p,
  .print-profile-heading p {
    margin: 0;
    color: #596057;
  }

  .print-message {
    margin: 18mm 0;
    padding: 8mm;
    border: 1px solid var(--border);
    border-radius: 3mm;
    color: #596057;
    background: var(--background);
    font-size: 12pt;
    text-align: center;
  }

  .print-section-title {
    margin: 7mm 0 3mm;
    font-size: 10pt;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .print-report .summary-table {
    min-width: 0;
    font-size: 8pt;
  }

  .print-report .summary-table th,
  .print-report .summary-table td {
    padding: 2.2mm 2mm;
  }

  .print-profile {
    break-before: page;
  }

  .print-profile-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12mm;
    margin-bottom: 4mm;
    padding-bottom: 3mm;
    border-bottom: 1px solid var(--border);
  }

  .print-profile-heading h2 {
    margin: 0 0 1.5mm;
    font-size: 15pt;
  }

  .print-profile-totals {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2mm;
  }

  .print-total {
    padding: 1.5mm 2.5mm;
    border: 1px solid var(--border);
    border-radius: 2mm;
    background: var(--background);
    white-space: nowrap;
  }

  .print-report .legend {
    margin-bottom: 3mm;
  }

  .print-report .kerf-tolerance-note {
    margin: 0 0 3mm;
    padding: 2mm 3mm;
    font-size: 8pt;
  }

  .print-pattern-summary {
    margin: -1mm 0 3mm;
    color: #596057;
    font-size: 8pt;
  }

  .print-report .bar-card {
    break-inside: avoid;
    margin-bottom: 2.5mm;
    border-radius: 2mm;
    box-shadow: none;
  }

  .print-report .bar-header {
    padding: 2mm 3mm;
  }

  .print-report .bar-body {
    padding: 2.5mm 3mm;
  }

  .print-report .visual-bar {
    height: 8mm;
    margin-bottom: 2mm;
  }

  .print-report .segment {
    font-size: 6pt;
  }

  .print-report .tag,
  .print-report .badge,
  .print-report .legend-item {
    font-size: 6.5pt;
  }
}
