* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --card: #f5f5f5;
  --text: #1a1a1a;
  --muted: #717171;
  --primary: #1a1a1a;
  --primary-hover: #333;
  --danger: #c0392b;
  --border: #e0e0e0;
  --accent: #1a1a1a;
  --radius: 4px;
}
body {
  margin: 0;
  font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 860px; margin: 0 auto; padding: 48px 24px; }

header { margin-bottom: 40px; }
header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}
.header-row { display: flex; justify-content: space-between; align-items: center; }

.collapsible-header {
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; user-select: none; padding: 0 0 12px;
}
.collapsible-header h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.toggle-icon { font-size: 10px; color: var(--muted); transition: transform 0.2s; }
.collapsible-content { overflow: hidden; animation: fadeIn 0.25s ease; }
.collapsible-header .toggle-icon.open { transform: rotate(90deg); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 0 16px;
  animation: slideUp 0.3s ease;
}
.static-value {
  font-size: 14px; color: var(--text); padding: 8px 0;
}
.panel > h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted); margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.card h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.cards-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
input, select {
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
button {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover { background: var(--card); transform: translateY(-1px); }
button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
button.primary:hover { background: var(--primary-hover); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #fdf2f2; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.between h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--muted); margin: 0;
}
.muted { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.units-list { display: flex; flex-direction: column; gap: 12px; }
.unit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  animation: slideUp 0.3s ease;
  transition: box-shadow 0.2s ease;
}
.unit-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.unit-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.unit-header strong { font-size: 14px; font-weight: 600; }
.unit-header .actions { display: flex; gap: 4px; }
.unit-header .actions button {
  padding: 4px 8px; font-size: 12px; border: 1px solid var(--border);
  background: #fff; border-radius: var(--radius);
}
.unit-body { padding: 16px; }
.unit-visual {
  display: flex; justify-content: center; align-items: center;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.unit-visual svg { max-width: 200px; height: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; margin-bottom: 8px; }
.row.dims { grid-template-columns: repeat(4, 1fr); gap: 8px; color: var(--muted); font-size: 13px; }
.hidden { display: none; }

.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.data th {
  text-align: left; padding: 8px 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--muted);
  border-bottom: 2px solid var(--text);
}
.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data thead th { position: sticky; top: 0; background: #fff; }
.data tbody tr { transition: background 0.15s ease; }
.data tbody tr:hover { background: var(--card); }

footer {
  text-align: center; padding: 32px 0 16px;
  color: var(--muted); font-size: 12px;
}
footer p { margin-bottom: 4px; }
.powered-by { font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase; }
.powered-by a { color: var(--text); text-decoration: none; font-weight: 600; }
.powered-by a:hover { text-decoration: underline; }

.summary { display: block; }
.mini-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.mini-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.mini-card p { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.mini-card p strong { color: var(--text); }

.part-block { margin-top: 20px; }
.part-block h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  max-width: 360px;
  width: 90%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: dialogIn 0.2s ease;
}
dialog::backdrop { background: rgba(0,0,0,0.15); animation: fadeIn 0.2s ease; }
dialog h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
dialog menu { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding: 0; list-style: none; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dialogIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* Print Styles for PDF export */
@media print {
  body { background: #fff; color: #000; }
  .panel { border: 1px solid #ddd; background: #fff; }
  .card, .mini-card { background: #f9f9f9; border-color: #ddd; }
  button, dialog { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .row.dims { color: #333; }
  .data th { border-bottom-color: #000; color: #000; }
  .data td { border-color: #ccc; color: #000; }
  .data thead th { background: #fff; }
  .collapsible-content { display: block !important; }
  .collapsible-header { pointer-events: none; }
  footer { display: block; }

  /* When exporting only the grouped cutting list */
  body.print-cutting-only header,
  body.print-cutting-only footer,
  body.print-cutting-only dialog { display: none !important; }
  body.print-cutting-only .panel { display: none !important; }
  body.print-cutting-only .panel:has(#cuttingListOnlySection) { display: block !important; border: none; }
  body.print-cutting-only #cuttingListOnlySection { display: block !important; }
  body.print-cutting-only #exportCuttingListPdfBtn { display: none !important; }
}
