/* Layout optimizer panel */
.optimizer-open-button { color: white; background: var(--blue); border-color: var(--blue); }
.opt-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: stretch; justify-content: center; padding: 14px; background: rgba(24, 34, 53, .38); }
.opt-overlay[hidden] { display: none; }
.opt-dialog { display: flex; flex-direction: column; width: 100%; max-width: 1500px; min-height: 0; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; font-size: 12px; }
.opt-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.opt-header h2 { font-size: 15px; }
.opt-subtitle { color: var(--muted); font-size: 11px; }
.opt-close { border: 0; background: none; font-size: 22px; line-height: 1; color: #43516a; }
.opt-body { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); min-height: 0; flex: 1; }
.opt-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.opt-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.opt-tabs button, .opt-buttons button, .opt-run-controls button, .opt-custom-list button, h4 button { border: 1px solid var(--line); border-radius: 6px; background: white; padding: 4px 9px; font-size: 11px; font-weight: 700; color: #43516a; }
.opt-tabs button.is-active { background: var(--blue-soft); border-color: #b9cdf0; color: var(--blue); }
.opt-panel { overflow-y: auto; padding: 10px 12px 24px; min-height: 0; }
.opt-custom-mode .opt-body { grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.opt-custom-mode .opt-main { display: none; }
.opt-custom-mode .opt-panel { overflow: auto; }
.opt-custom-mode .opt-side { min-width: 0; border-right: 0; }
.opt-panel h3 { margin: 12px 0 6px; font-size: 13px; }
.opt-panel h3:first-child { margin-top: 0; }
.opt-panel h4 { margin: 12px 0 4px; font-size: 12px; }
.opt-panel h4 small { font-weight: 400; color: var(--muted); }
.opt-help { color: var(--muted); margin: 4px 0 8px; line-height: 1.4; }
.opt-warn { color: #a3541c; display: block; }
.opt-bad { color: var(--red); font-weight: 700; }
.opt-ok { color: #2f7d55; margin: 6px 0; }
.opt-buttons { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0; }
.opt-buttons button:disabled, .opt-run-controls button:disabled { opacity: .45; cursor: default; }
button.opt-primary { background: #28364f; color: white; border-color: #28364f; }
.opt-table { width: 100%; border-collapse: collapse; }
.opt-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.opt-table td { padding: 3px 4px; border-bottom: 1px solid #f0f3f7; vertical-align: middle; }
.opt-table small { color: var(--muted); }
.opt-table input[type=number] { width: 64px; }
.opt-compact input[type=number] { width: 58px; }
.opt-num { text-align: right; font-variant-numeric: tabular-nums; }
.opt-panel input, .opt-panel select { font: inherit; font-size: 12px; padding: 3px 5px; border: 1px solid #ccd5e1; border-radius: 5px; background: white; }
.opt-wide { width: 100%; }
.opt-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.opt-field { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.opt-field span { color: #4a5870; font-size: 11px; }
.opt-check { flex-direction: row; align-items: center; gap: 6px; }
.opt-part-icon { display: block; }
.opt-icon-paths polyline { fill: none; stroke: #3f6fba; stroke-width: 1.4; stroke-linecap: round; }
.opt-male { fill: #2667e8; }
.opt-female { fill: white; stroke: var(--orange); stroke-width: .35; }
.opt-room-preview svg, .opt-plan { width: 100%; height: auto; display: block; }
.opt-room-preview { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.opt-custom-list { list-style: none; padding: 0; margin: 0 0 6px; }
.opt-custom-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid #f0f3f7; }
.opt-custom-list li span { flex: 1; }
.opt-form { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.opt-part-check { display: grid; grid-template-columns: 180px 1fr; gap: 10px; align-items: start; margin: 8px 0; }
.opt-part-preview { width: 180px; height: 150px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfe; }
.opt-stl-list .opt-part-preview { width: 120px; height: 96px; flex: none; }
.opt-part-check:has(.opt-has-underlay) { grid-template-columns: 280px 1fr; }
.opt-part-check .opt-has-underlay { width: 280px; height: 220px; }
.opt-stl-list li.opt-stl-item { align-items: flex-start; }
.opt-stl-actions { display: flex; flex-wrap: wrap; gap: 4px; flex: 0 0 auto !important; max-width: 150px; justify-content: flex-end; }
.opt-stl-actions button[disabled] { opacity: .45; cursor: not-allowed; }
.opt-problems { margin: 0; padding-left: 16px; color: var(--red); }
.opt-sliders { display: grid; gap: 2px; }
.opt-slider { display: grid; grid-template-columns: 1fr 140px 32px; align-items: center; gap: 6px; }
.opt-slider output { text-align: right; font-variant-numeric: tabular-nums; }
.opt-start { border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 4px 8px 6px; }
.opt-start label { display: block; margin: 2px 0; }
.opt-tried { list-style: none; padding: 0; margin: 0; }
.opt-tried-item { display: grid; grid-template-columns: 120px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f0f3f7; }
.opt-tried-item input { width: 100%; }
.opt-tried-plan { border: 1px solid var(--line); border-radius: 4px; }
.opt-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.opt-runbar { padding: 10px 14px 6px; border-bottom: 1px solid var(--line); }
.opt-run-controls { display: flex; align-items: center; gap: 6px; }
.opt-run-controls button { padding: 6px 14px; font-size: 12px; }
.opt-mode { color: var(--muted); margin-left: 6px; }
.opt-progress { height: 4px; margin: 8px 0 4px; background: #edf1f6; border-radius: 2px; overflow: hidden; }
.opt-progress div { height: 100%; background: var(--blue); transition: width .3s; }
.opt-status { margin: 0; color: #4a5870; }
.opt-warnings { margin: 4px 0 0; padding-left: 16px; color: #a3541c; }
.opt-gallery { overflow-y: auto; padding: 10px 14px 30px; min-height: 0; }
.opt-empty { max-width: 640px; color: #4a5870; line-height: 1.5; }
.opt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.opt-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: white; cursor: pointer; }
.opt-card.is-selected { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.opt-card-plan { border-bottom: 1px solid var(--line); }
.opt-card-body { padding: 8px 10px 10px; cursor: default; }
.opt-card-body h4 { margin: 0 0 6px; font-size: 13px; }
.opt-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 9px; background: #e7f6ee; color: #2f7d55; font-size: 10px; vertical-align: middle; }
.opt-metrics { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 0 0 6px; }
.opt-metrics dt { color: var(--muted); }
.opt-metrics dd { margin: 0; font-variant-numeric: tabular-nums; }
.opt-usage { margin: 3px 0; line-height: 1.35; }
.opt-card details { margin: 4px 0; }
.opt-card summary { cursor: pointer; color: #4a5870; }
@media (max-width: 900px) {
  .opt-overlay { padding: 0; }
  .opt-body { grid-template-columns: 1fr; overflow-y: auto; }
  .opt-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .opt-panel, .opt-gallery { overflow: visible; }
}
