* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
body { display: flex; height: 100vh; overflow: hidden; background: #eef1f5; color: #222; }

/* Login-Overlay */
#login-overlay { position: fixed; inset: 0; background: rgba(25, 30, 38, 0.9); backdrop-filter: blur(4px); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.login-box { background: #fff; width: 380px; padding: 30px; border-radius: 8px; box-shadow: 0 12px 35px rgba(0,0,0,0.3); display: flex; flex-direction: column; gap: 14px; }
.login-box h2 { font-size: 20px; color: #222; text-align: center; }
.login-box p { font-size: 13px; color: #666; text-align: center; margin-bottom: 4px; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 5px; font-size: 14px; }
.login-box button { background: #b86b35; color: #fff; border: none; padding: 11px; border-radius: 5px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: #9e5929; }
#login-error { color: #c0392b; font-size: 12.5px; text-align: center; min-height: 16px; }

/* Hauptlayout */
#viewport { flex: 1; position: relative; height: 100%; }
#view-indicator { position: absolute; top: 62px; left: 16px; background: rgba(255,255,255,0.92); padding: 8px 14px; border-radius: 4px; font-size: 13px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,0.1); cursor: pointer; }
#role-badge { position: absolute; bottom: 16px; left: 16px; background: rgba(44,62,80,0.92); color: #fff; padding: 6px 12px; border-radius: 4px; font-size: 12px; display: flex; align-items: center; gap: 10px; }
#logout-btn { background: transparent; color: #f39c12; border: 1px solid #f39c12; padding: 2px 8px; border-radius: 3px; font-size: 11px; cursor: pointer; }

#sidebar { width: 475px; background: #fff; border-left: 1px solid #dcdcdc; display: flex; flex-direction: column; height: 100%; box-shadow: -3px 0 12px rgba(0,0,0,0.06); }
#sidebar-header { padding: 14px 18px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#sidebar-header h1 { font-size: 17px; font-weight: 700; color: #222; }
.header-actions { display: flex; gap: 6px; }
.btn-top { background: #2c3e50; color: #fff; border: none; padding: 6px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-top:hover { background: #1a252f; }

#sidebar-content { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.section { border-bottom: 1px solid #efefef; padding-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: #888; font-weight: 700; }
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.form-row label { font-size: 13px; color: #333; flex: 1; }
.form-row input[type="number"], .form-row input[type="text"], .form-row select { width: 155px; padding: 5px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; background: #fafafa; }
.form-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: #b86b35; cursor: pointer; }

.col-box { background: #f7f7f7; padding: 7px 9px; border-radius: 4px; border: 1px solid #e2e2e2; display: flex; flex-direction: column; gap: 5px; }
.col-box input[type="number"] { width: 78px !important; }
.col-box select { width: 110px !important; padding: 2px 4px; }

.info-badge { background: #f7f7f7; padding: 7px 10px; border-radius: 4px; font-size: 12px; color: #555; display: flex; justify-content: space-between; }
details.tech-accordion { background: #fafafa; border: 1px solid #e4e4e4; border-radius: 5px; padding: 8px 10px; }
details.tech-accordion summary { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #555; cursor: pointer; user-select: none; }
details.tech-accordion .acc-body { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

#sidebar-footer { padding: 14px 18px; border-top: 1px solid #e0e0e0; background: #fafafa; display: flex; flex-direction: column; gap: 6px; }
.price-info { display: flex; justify-content: space-between; font-size: 12.5px; color: #555; }
.price-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; border-top: 1px dashed #ccc; margin-top: 2px; }
.price-total span { font-size: 13px; font-weight: 600; }
.price-total strong { font-size: 21px; color: #b86b35; }
.btn-primary { width: 100%; background: #b86b35; color: #fff; border: none; padding: 11px; border-radius: 5px; font-size: 13.5px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.btn-primary:hover { background: #9e5929; }
.btn-secondary { width: 100%; background: #2c3e50; color: #fff; border: none; padding: 9px; border-radius: 5px; font-size: 13px; font-weight: 600; cursor: pointer; }

/* Admin Modal */
#admin-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1500; align-items: center; justify-content: center; }
.modal-box { background: #fff; width: 960px; max-width: 96vw; max-height: 92vh; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.modal-header { padding: 14px 20px; background: #2c3e50; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-body h3 { font-size: 14px; color: #b86b35; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th, .admin-table td { border: 1px solid #e0e0e0; padding: 6px 8px; text-align: left; }
.admin-table th { background: #f5f5f5; }
.admin-table input, .admin-table select { width: 100%; padding: 4px 6px; border: 1px solid #ccc; border-radius: 3px; font-size: 12.5px; }
.modal-footer { padding: 12px 20px; background: #f5f5f5; border-top: 1px solid #ddd; display: flex; justify-content: space-between; }

/* Backend-Fenster: Inhalt scrollbar, Kopf und Speichern-Leiste bleiben sichtbar */
.modal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-scroll h3 { font-size: 14px; color: #b86b35; border-bottom: 1px solid #eee; padding-bottom: 5px; margin-top: 8px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; }
.admin-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.admin-grid input { padding: 5px 7px; border: 1px solid #ccc; border-radius: 3px; }
.modal-header, .modal-footer { flex-shrink: 0; }
#codes-modal .modal-box { overflow-y: auto; padding-bottom: 16px; }
#codes-modal .modal-box > :not(.modal-header) { margin-left: 20px; margin-right: 20px; }
#codes-modal .modal-box > .modal-header + * { margin-top: 14px; }

/* Seitenleiste: Kopf, scrollbarer Inhalt, feste Preisleiste */
.sidebar-header { padding: 14px 18px 12px; border-bottom: 1px solid #eee; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; flex-shrink: 0; }
.sidebar-header h1 { font-size: 18px; font-weight: 700; color: #222; }
.scroll-area { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.summary-footer { padding: 12px 18px 14px; border-top: 1px solid #e0e0e0; background: #fafafa; display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.stat-row { display: flex; justify-content: space-between; font-size: 12.5px; color: #555; }
.price-row { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; border-top: 1px dashed #ccc; margin-top: 2px; }
.price-row #price-label { font-size: 13px; font-weight: 600; }
.price-row #total-price { font-size: 21px; font-weight: 700; color: #b86b35; }

/* Einklappbare Blöcke */
.section { border: 1px solid #e6e6e6; border-radius: 6px; padding: 0 12px 12px; gap: 8px; }
.section > h2 { margin: 0 -12px; padding: 10px 12px; font-size: 13px; letter-spacing: 0.4px; color: #2c3e50; background: #f6f7f9; border-radius: 6px 6px 0 0; cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.section > h2:hover { background: #eef0f3; }
.section > h2::after { content: '▾'; font-size: 16px; color: #b86b35; transition: transform 0.15s; }
.section.collapsed { padding-bottom: 0; }
.section.collapsed > h2 { border-radius: 6px; }
.section.collapsed > h2::after { transform: rotate(-90deg); }
.section.collapsed > :not(h2) { display: none !important; }
.form-row input[type="number"], .form-row input[type="text"], .form-row select { flex-shrink: 0; max-width: 55%; }

.col-clear { font-size: 11.5px; color: #b86b35; font-weight: 600; padding: 1px 0 3px; }

/* Werkzeugleiste in der 3D-Ansicht */
/* Bedienleiste über dem 3D-Bild (04.12.2026): feste Leiste, 3D-Bild beginnt darunter; Symbole per CSS-Maske */
#view-toolbar { position: absolute; top: 0; left: 0; right: 0; height: 46px; display: flex; align-items: center; gap: 4px; padding: 0 12px; background: #fff; border-bottom: 1px solid #dcdcdc; z-index: 5; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: thin; }
#viewport > canvas { position: absolute; top: 46px; left: 0; }
#view-toolbar .view-btn { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; box-shadow: none; padding: 6px 10px; border-color: transparent; background: transparent; }
#view-toolbar .view-btn:hover { background: #f4ede7; border-color: #e4cdb9; }
#view-toolbar .view-btn.active { background: #b86b35; color: #fff; border-color: #b86b35; }
#view-toolbar .view-btn[data-ic]::before { content: ''; width: 17px; height: 17px; flex: 0 0 17px; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.vt-sep { width: 1px; height: 24px; background: #e0e0e0; margin: 0 6px; flex: 0 0 auto; }
.view-btn:disabled { opacity: .4; cursor: default; }
#view-toolbar .view-btn:disabled:hover { background: transparent; border-color: transparent; }
#view-toolbar .view-btn[data-ic="photo"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M3 8h4l2-3h6l2 3h4v11H3z%22/%3E%3Ccircle cx=%2212%22 cy=%2213%22 r=%223.5%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="cad"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M12 3l8 4.5v9L12 21l-8-4.5v-9z%22/%3E%3Cpath d=%22M12 12l8-4.5M12 12v9M12 12L4 7.5%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="dimout"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M3 12h18M3 8v8M21 8v8M7 9l-4 3 4 3M17 9l4 3-4 3%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="dimin"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Crect x=%223%22 y=%224%22 width=%2218%22 height=%2216%22 rx=%221%22/%3E%3Cpath d=%22M7 12h10M9 10l-2 2 2 2M15 10l2 2-2 2%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="door"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Crect x=%225%22 y=%223%22 width=%2214%22 height=%2218%22 rx=%221%22/%3E%3Cpath d=%22M15 11v2%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="open"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M4 3h9v18H4z%22/%3E%3Cpath d=%22M13 3l7 2.5v13L13 21%22/%3E%3Cpath d=%22M16 11v2%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="glass"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Crect x=%225%22 y=%223%22 width=%2214%22 height=%2218%22 rx=%221%22 stroke-dasharray=%223 2.5%22/%3E%3Cpath d=%22M9 9l4-4M9 14l7-7%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="front"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Crect x=%225%22 y=%223%22 width=%2214%22 height=%2218%22 rx=%221%22/%3E%3Cpath d=%22M12 3v18%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="iso"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Cpath d=%22M4 7l8-4 8 4v10l-8 4-8-4z%22/%3E%3Cpath d=%22M4 7l8 4 8-4M12 11v10%22/%3E%3C/svg%3E"); }
#view-toolbar .view-btn[data-ic="cam"] { --ic: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22black%22 stroke-width=%221.8%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22%3E%3Crect x=%223%22 y=%225%22 width=%2218%22 height=%2214%22 rx=%221.5%22/%3E%3Cpath d=%22M3 16l5-5 4 4 3-3 6 6%22/%3E%3Ccircle cx=%2216%22 cy=%229%22 r=%221.5%22/%3E%3C/svg%3E"); }
.view-btn { background: #fff; color: #333; border: 1px solid #ccc; padding: 8px 12px; border-radius: 4px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.view-btn:hover { border-color: #b86b35; }
.view-btn.active { background: #b86b35; color: #fff; border-color: #b86b35; }

/* Gespeicherte Planungen */
#current-config { flex: 0 0 100%; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; display: none; align-items: center; justify-content: space-between; gap: 8px; background: #fbf3ec; border: 1px solid #ecd5c2; color: #8a4f22; border-radius: 4px; padding: 5px 8px; font-size: 12px; font-weight: 600; }
#current-config span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#current-config button { background: none; border: 1px solid #c99a75; color: #8a4f22; border-radius: 3px; padding: 2px 7px; font-size: 11px; cursor: pointer; flex-shrink: 0; }
#codes-modal .modal-box { width: 900px; }
#codes-modal .btn-del { background: #fff; color: #c0392b; border: 1px solid #e3b4ae; margin-left: 4px; }
#codes-modal .btn-del:hover { background: #fdf0ee; }
#codes-modal.dealer-view th:nth-child(4), #codes-modal.dealer-view td:nth-child(4) { display: none; }

.sidebar-header { min-width: 0; overflow: hidden; }

/* Alle Dialogfenster (Planungen, Backend) mittig als Overlay */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1500; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop .modal-box { max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }
#codes-modal .modal-box > table { width: calc(100% - 40px); }

/* ===== Backend: Reiter ===== */
#admin-modal .modal-box { height: min(860px, calc(100vh - 32px)); }
.admin-tabs { display: flex; gap: 2px; padding: 10px 20px 0; background: #f5f5f5; border-bottom: 1px solid #ddd; flex-shrink: 0; flex-wrap: wrap; }
.admin-tab { background: transparent; border: 1px solid transparent; border-bottom: none; padding: 9px 16px; font-size: 13px; font-weight: 600; color: #555; cursor: pointer; border-radius: 6px 6px 0 0; margin-bottom: -1px; }
.admin-tab:hover { color: #b86b35; background: #fff8f2; }
.admin-tab.active { background: #fff; color: #b86b35; border-color: #ddd; border-bottom: 1px solid #fff; }
.admin-panel { display: none; flex-direction: column; gap: 10px; }
.admin-panel.active { display: flex; }
.admin-panel > h3:first-child { margin-top: 0; }
