/* Cut-list calculator (2x4 and 2x6 pages) */

.layout {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  height: calc(100vh - var(--header-h));
  min-height: 560px;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.main {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

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

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.cut-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 52px auto;
  gap: 8px;
  align-items: end;
}

.cut-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 12px;
}

.cut-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 48px 28px;
  gap: 8px;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 6px 6px 10px;
}

.cut-item .cut-label {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cut-item .cut-len {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.mini-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12px;
  text-align: center;
  outline: none;
  font-family: inherit;
}
.mini-input:focus {
  border-color: var(--accent);
}
.mini-input:disabled {
  opacity: 0.5;
}

.settings-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.stock-head,
.stock-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 52px 64px 24px;
  gap: 8px;
  align-items: center;
}

.stock-head {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 10px 6px;
}
.stock-head span {
  text-align: center;
}
.stock-head span:nth-child(2) {
  text-align: left;
}

.stock-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stock-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 6px 7px 10px;
}

.stock-item.unavailable .stock-len {
  opacity: 0.45;
}

.stock-item .stock-len {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}

.stock-item .stock-len small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}

.add-custom-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
  align-items: end;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  margin: auto;
}

.empty-state .icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.empty-state .btn {
  margin-top: 14px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(232, 168, 56, 0.1);
  border: 1px solid rgba(232, 168, 56, 0.4);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
}
.banner span {
  flex: 1;
  min-width: 180px;
}

/* Results */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.results-title {
  font-size: 16px;
  font-weight: 600;
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.chip strong {
  color: var(--text);
}

.chip.chip-accent {
  border-color: rgba(232, 168, 56, 0.5);
}
.chip.chip-accent strong {
  color: var(--accent);
}

.results-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.boards-visual {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.board-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 56px;
  text-align: right;
  flex-shrink: 0;
  line-height: 1.3;
}

.board-bar-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.board-bar {
  height: 36px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  position: relative;
}

.board-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.75);
  white-space: nowrap;
  cursor: default;
  position: relative;
  min-width: 0;
}

.board-segment .seg-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  padding: 0 2px;
}

.board-segment:first-child {
  border-radius: 3px 0 0 3px;
}
.board-segment:last-child {
  border-radius: 0 3px 3px 0;
}

.board-segment:hover {
  filter: brightness(1.1);
}

.board-segment.kerf-seg {
  background: #111;
  min-width: 2px;
  flex-shrink: 0;
}

.board-segment.waste {
  background: repeating-linear-gradient(
    45deg,
    #2a2a2a,
    #2a2a2a 4px,
    #333 4px,
    #333 8px
  );
  font-size: 9px;
  font-weight: 400;
  color: #777;
}

.board-segment-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  display: none;
}

.board-segment:hover .board-segment-tooltip {
  display: block;
}

.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.list-board-header .board-id {
  font-weight: 600;
}
.list-board-header .board-info {
  color: var(--text-muted);
  font-size: 12px;
}

.count-badge {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  margin-right: 6px;
}

.list-board-cuts {
  padding: 8px 0;
}

.list-cut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
}

.list-cut-row:hover {
  background: var(--surface2);
}

.list-cut-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.list-cut-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-cut-len {
  color: var(--accent);
  font-weight: 600;
}

.waste-row {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.waste-row::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    45deg,
    #2a2a2a,
    #2a2a2a 3px,
    #444 3px,
    #444 6px
  );
  display: inline-block;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main {
    overflow: visible;
    padding: 20px 16px;
    min-height: 320px;
  }
  .section {
    padding: 18px 16px;
  }
}

/* ─── Print view ─────────────────────────────────────────────── */
.print-view {
  display: none;
}

@media print {
  @page {
    margin: 0.5in;
  }
  body.has-print-view {
    background: #fff;
    color: #000;
    min-height: 0;
  }
  body.has-print-view > *:not(#printView) {
    display: none !important;
  }
  body.has-print-view .print-view {
    display: block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 11pt;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pv-title {
    font-size: 18pt;
    font-weight: 700;
    margin-bottom: 2pt;
  }
  .pv-meta {
    font-size: 9pt;
    color: #555;
    margin-bottom: 12pt;
  }
  .pv-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6pt 18pt;
    padding: 8pt 10pt;
    border: 1px solid #999;
    margin-bottom: 14pt;
  }
  .pv-summary strong {
    font-size: 12pt;
  }
  .pv-h2 {
    font-size: 12pt;
    font-weight: 700;
    margin: 14pt 0 6pt;
    border-bottom: 1.5px solid #000;
    padding-bottom: 2pt;
  }
  .pv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
  }
  .pv-table th,
  .pv-table td {
    text-align: left;
    padding: 3pt 6pt;
    border-bottom: 1px solid #ccc;
  }
  .pv-table th {
    font-size: 8.5pt;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #444;
  }
  .pv-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .pv-table tfoot td {
    font-weight: 700;
    border-bottom: none;
    border-top: 1.5px solid #000;
  }
  .pv-check {
    display: inline-block;
    width: 10pt;
    height: 10pt;
    border: 1px solid #000;
    vertical-align: middle;
  }
  .pv-swatch {
    display: inline-block;
    width: 10pt;
    height: 10pt;
    border: 1px solid #000;
    vertical-align: middle;
    margin-right: 5pt;
  }
  .pv-board {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 12pt;
  }
  .pv-board-head {
    display: flex;
    justify-content: space-between;
    font-size: 10pt;
    margin-bottom: 3pt;
  }
  .pv-board-head strong {
    font-size: 11pt;
  }
  .pv-bar {
    display: flex;
    height: 34pt;
    border: 1.5px solid #000;
    margin-bottom: 4pt;
  }
  .pv-seg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-right: 1px solid #000;
    font-size: 8pt;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    padding: 0 2pt;
    min-width: 0;
  }
  .pv-seg:last-child {
    border-right: none;
  }
  .pv-seg b {
    font-size: 9pt;
  }
  .pv-seg.pv-waste {
    background: repeating-linear-gradient(45deg, #fff 0 4pt, #ddd 4pt 6pt);
    color: #555;
  }
  .pv-kerf {
    background: #000;
    flex: none;
  }
  .pv-board .pv-table td {
    padding: 2pt 6pt;
  }
  .pv-foot {
    margin-top: 16pt;
    font-size: 8.5pt;
    color: #666;
  }
}
