:root {
  --fg: #211d1a;
  --fg-muted: #6b6258;
  --bg: #f3efe8;
  --surface: #fffdfb;
  --accent: #c1611b;
  --accent-dark: #a14f14;
  --accent-soft: #f3dfc8;
  --line: #e2dcd0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(33, 29, 26, 0.04), 0 2px 8px rgba(33, 29, 26, 0.05);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  padding: 1.5rem;
  max-width: 900px;
  margin-inline: auto;
}

header { margin-bottom: 0.5rem; }

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-switch {
  display: flex;
  gap: 0.3rem;
}

.feedback-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: underline;
  white-space: nowrap;
}

.feedback-link:hover { color: var(--fg); }

.lang-switch button {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff8f0;
  border-color: var(--accent);
}

.brand-mark { color: var(--fg); flex-shrink: 0; }
.brand-mark-fill { fill: var(--accent); }

header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .sub { color: var(--fg-muted); margin: 0.3rem 0 0; }

h2 { font-size: 1.05rem; letter-spacing: -0.005em; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hint {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin: 0 0 0.75rem;
}

.panel label {
  display: inline-flex;
  flex-direction: column;
  font-size: 0.85rem;
  margin-right: 1.25rem;
  margin-bottom: 0.5rem;
}

.sync-load {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.sync-load label { margin: 0; }

input[type="number"], input[type="text"] {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  margin-top: 0.3rem;
  background: var(--surface);
  color: var(--fg);
}

input[type="number"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 0.75rem; }
table { width: 100%; min-width: 580px; border-collapse: collapse; margin-bottom: 0; }
th, td { text-align: left; padding: 0.4rem 0.35rem; font-size: 0.9rem; }
thead th { color: var(--fg-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; border-bottom: 1px solid var(--line); }
th[title] { cursor: help; text-decoration: underline dotted; text-decoration-color: var(--line); }
tbody tr + tr td { border-top: 1px solid var(--line); }
td input[type="number"] { width: 4.5rem; }
td input[type="text"] { width: 100%; }

.dims-row, .dims-cell {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dims-row { align-items: flex-end; margin-bottom: 0.5rem; flex-wrap: wrap; }
.dims-row label { margin: 0; margin-right: 0; }
.dims-row input[type="number"] { width: 7rem; }
.dims-cell { flex-wrap: nowrap; }

button.swap {
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

button:hover { border-color: var(--fg-muted); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button.primary {
  background: var(--accent);
  color: #fff8f0;
  border: none;
  font-weight: 600;
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1.5rem;
}

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

.sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sheet h3 { margin-top: 0; }

.sheet svg { border: 1px solid var(--line); border-radius: 4px; max-width: 100%; background: var(--bg); }

.part-rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.part-outline { fill: none; stroke: var(--accent); stroke-width: 1; pointer-events: none; }
.part-label { font-size: 11px; fill: var(--fg); pointer-events: none; }
.grain-line { stroke: var(--accent-dark); stroke-width: 0.5; opacity: 0.25; pointer-events: none; }
.grain-line-sheet { opacity: 0.12; }

button.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.error {
  background: #fbe9e4;
  border: 1px solid #e3a98f;
  color: #93401f;
  padding: 0.75rem;
  border-radius: 6px;
}

button.secondary {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  font-weight: 600;
  flex: 1 1 0;
  padding: 0.75rem;
}

button.secondary:hover { background: var(--accent-soft); }

.print-actions { margin-bottom: 1.5rem; }

#printArea { display: none; }

footer.seo {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--fg-muted);
}

footer.seo h2 {
  color: var(--fg);
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

footer.seo h3 {
  color: var(--fg);
  font-size: 0.98rem;
  margin: 1.1rem 0 0.3rem;
}

footer.seo p { margin: 0.2rem 0; line-height: 1.5; }

footer.seo .tips { margin: 0.2rem 0 0; padding-left: 1.2rem; line-height: 1.5; }
footer.seo .tips li { margin-bottom: 0.2rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.6rem;
  margin: 0.75rem 0 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
}

.stat-card .stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent-dark); }
.stat-card .stat-label { font-size: 0.78rem; color: var(--fg-muted); }

.stock-warning {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.print-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.print-actions[hidden] { display: none; }

#printFooter { display: none; }

/* Drucken: twee modi op hetzelfde #printArea/#result - volledig plan
   (print-plan) of alleen etiketten (print-labels), zie app.js. Een
   automatisch opgeslagen projectcode in #printFooter zorgt dat een
   vergeten "Speichern" geen verloren plan betekent (Feedback issue #16). */
@media print {
  header, footer.seo, .panel, #calc, .print-actions { display: none; }
  #result { display: none; }
  #printArea { display: none; }
  body.print-plan #result { display: block; }
  body.print-labels #printArea {
    display: flex;
    flex-direction: column;
    gap: 2mm;
  }
  body.print-plan #printFooter, body.print-labels #printFooter {
    display: block;
    margin-top: 4mm;
    font-size: 8pt;
    color: #555;
    text-align: center;
  }
  .print-label {
    border: 1px dashed #999;
    padding: 2mm;
    break-inside: avoid;
    font-size: 10pt;
  }
  .label-title { font-weight: 600; }
  .label-dims { font-size: 9pt; }
  .label-sheet { font-size: 8pt; color: #555; }
}

#saveLink { word-break: break-all; }

@media (max-width: 640px) {
  body { padding: 1rem; }
  .panel { padding: 0.85rem 1rem; }
  header h1 { font-size: 1.35rem; }
  .panel label { margin-right: 0.6rem; }
  .sync-load { flex-wrap: wrap; }
  td input[type="number"] { width: 4rem; }
  button.primary, button.secondary { padding: 0.65rem; }
}
