*{box-sizing:border-box}
.hidden{display:none!important}
html{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#182832;background:#f3f5f6}
body{margin:0}
header{background:#203746;color:white;padding:14px max(14px,calc((100% - 1120px)/2));display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.brand{font-size:1.15rem;font-weight:750;letter-spacing:.22em}
header p{margin:4px 0 0;color:#d9e4e8;font-size:.9rem;flex:1 1 100%}
.admin-btn{background:#fff;color:#203746;border-color:#fff;padding:8px 14px;font-size:.85rem;min-height:36px}
.admin-btn:hover{background:#e8ecef}
.session-actions{display:flex;align-items:center;gap:10px;margin-left:auto}
#currentUserLabel{font-size:.82rem;color:#d9e4e8}
.login-screen{position:fixed;inset:0;z-index:5000;background:#203746;display:flex;align-items:center;justify-content:center;padding:20px}
.login-card{background:#fff;border-radius:16px;padding:28px;width:100%;max-width:380px;box-shadow:0 16px 50px rgba(0,0,0,.3)}
.login-card .brand{color:#203746;text-align:center;margin-bottom:12px}
.login-card h1{margin:0 0 20px;font-size:1.3rem;text-align:center}
.login-card label{display:block;font-weight:600;margin-bottom:12px}
.login-card input{width:100%;padding:10px;border:1px solid #9eafb7;border-radius:8px;font:inherit;margin-top:4px}
#loginMessage{color:#c0392b;min-height:1.4em;font-size:.85rem}
main{max-width:1120px;margin:14px auto;padding:0 12px}
footer{max-width:1120px;margin:16px auto;padding:8px 14px 28px;color:#53656d;font-size:.82rem}

/* Card & Section */
.card{background:#fff;border:1px solid #d7e0e4;border-radius:14px;margin-bottom:14px;box-shadow:0 2px 8px #2037460b;overflow:hidden}
.form-section{padding:0;position:relative}
.section-header{position:relative;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 16px;background:#e8ecef;min-height:48px}
.section-header h1{margin:0;color:#203746;font-size:.98rem;letter-spacing:.18em;text-transform:uppercase;font-weight:800;flex:1}
.section-edit-btn{background:#fff;border:1px solid #176f73;color:#176f73;padding:6px 12px;font-size:.8rem;min-height:32px;border-radius:6px;cursor:pointer;white-space:nowrap}
.section-edit-btn:hover{background:#176f73;color:#fff}
.section-body{padding:16px 18px 20px}

/* Dynamic layout in form */
.section-layout-area{position:relative;min-height:20px;margin:0 18px 16px 18px;border:1px dashed transparent;border-radius:8px;transition:border-color .2s}
.section-layout-area:hover{border-color:#d7e0e4}
.section-layout-area:empty{display:none}
.layout-element{position:absolute;box-sizing:border-box}
.layout-element.hidden{display:none!important}
.layout-element.field{padding:6px}
.layout-element.field label{font-size:.92rem;font-weight:600;display:block;margin-bottom:4px}
.layout-element.field input,.layout-element.field select,.layout-element.field textarea{width:100%;padding:8px 10px;border:1px solid #9eafb7;border-radius:8px;font:inherit;min-height:40px}
.layout-element.field textarea{resize:vertical}
.checkbox-group{padding:8px;background:#fcfdfe;border:1px solid #e4e9eb;border-radius:8px}
.checkbox-group h4{margin:0 0 8px;font-size:.9rem;color:#2c3e50}
.checkbox-group .checks{display:flex;flex-direction:column;gap:6px}
.checkbox-group .checks-horizontal{flex-direction:row;flex-wrap:wrap;gap:12px}
.checkbox-group .checks-horizontal label{flex:0 0 auto}
.checkbox-group label{display:flex;align-items:center;gap:8px;font-size:.9rem;font-weight:500;cursor:pointer}
.checkbox-group input{width:18px;height:18px;margin:0}
.layout-element.image{padding:4px;overflow:hidden}
.layout-element.image img{width:100%;height:100%;object-fit:fill;display:block;border-radius:6px}
.layout-element.image svg{width:100%;height:auto;display:block;border-radius:6px}
.layout-element.text{padding:6px}
.layout-element.text .hint{font-size:.82rem;color:#52636b;margin:0}
.layout-element.heading{padding:6px}
.layout-element.heading h2,.layout-element.heading h3,.layout-element.heading h4{margin:0;color:#203746}
.layout-element.upload{padding:8px}
.layout-element.upload .upload-box{border:2px dashed #77949a;border-radius:10px;padding:12px;text-align:center;color:#135d60;font-weight:600;background:#fff}
.layout-element.upload input{margin-top:8px;border:0;padding:6px}
.layout-element.photo-strip{padding:6px}
.layout-element.photo-strip .previews{display:flex;flex-wrap:wrap;gap:8px}
.layout-element.photo-strip img{width:80px;height:80px;object-fit:cover;border-radius:8px;border:1px solid #cbd5d9}

/* Generic widgets */
.layout-element.label{padding:6px;font-weight:700;color:#203746}
.layout-element.text,.layout-element.number,.layout-element.select,.layout-element.checkbox,.layout-element.checkboxes{padding:6px}
.layout-element .generic-label{display:flex;flex-direction:column;gap:4px;font-size:.88rem;font-weight:600}
.layout-element .generic-label.inline{flex-direction:row;align-items:center;gap:8px}
.layout-element .generic-label input,.layout-element .generic-label select{width:100%;padding:8px 10px;border:1px solid #9eafb7;border-radius:8px;font:inherit}
.layout-element .generic-label .unit{margin-left:4px;color:#52636b;font-weight:500}

/* Static fallback */
.verortung-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr)) 120px 120px;gap:12px;align-items:end;background:#f8fafb;border:1px dashed #c5d1d6;border-radius:8px;padding:12px}
.verortung-row .cb{display:flex;align-items:center;gap:8px;font-weight:600;padding-bottom:4px}

/* Buttons */
button{border:1px solid #176f73;background:#fff;color:#135d60;padding:11px 16px;border-radius:9px;font:inherit;font-weight:700;min-height:44px;cursor:pointer}
button:hover{background:#eff8f7}
button.secondary{border-color:#9eafb7;color:#52636b}
button.secondary:hover{background:#f3f5f6}
.primary{display:block;width:100%;background:#176f73;color:white;margin-top:14px;border-color:#176f73}
.primary:hover{background:#10585b}
.buttons{display:flex;flex-wrap:wrap;gap:10px}
.hint{font-size:.82rem;color:#52636b;margin-top:8px}
#message{min-height:1.4em;font-weight:600}

/* Modal */
.modal{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:14px}
.modal.hidden{display:none!important}
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45)}
.modal-content{position:relative;z-index:1001;background:#fff;border-radius:14px;max-width:960px;width:100%;max-height:90vh;display:flex;flex-direction:column;box-shadow:0 10px 40px rgba(0,0,0,.25)}
.modal-content.wide{max-width:1200px}
.modal-header{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid #d7e0e4}
.modal-header h2{margin:0;font-size:1.15rem}
.modal-close{background:transparent;border:0;font-size:1.6rem;color:#52636b;padding:0 4px;min-height:auto;line-height:1;cursor:pointer}
.modal-tabs{display:flex;gap:6px;padding:10px 18px;border-bottom:1px solid #e4e9eb;background:#f8fafb}
.tab-btn{background:transparent;border:1px solid transparent;color:#52636b;padding:8px 14px;border-radius:8px;font-size:.92rem;min-height:36px;cursor:pointer}
.tab-btn.active{background:#fff;border-color:#d7e0e4;color:#203746;font-weight:700}
.tab-panel{display:none;padding:18px;overflow-y:auto;max-height:calc(90vh - 130px)}
.tab-panel.active{display:block}

/* Admin */
.admin-form{background:#f8fafb;border:1px solid #e4e9eb;border-radius:10px;padding:14px;margin-bottom:18px}
.admin-form h3{font-size:1rem;margin:0 0 12px}
.admin-list{display:flex;flex-direction:column;gap:8px}
.admin-list-item{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border:1px solid #e4e9eb;border-radius:8px;background:#fff}
.admin-list-item .actions{display:flex;gap:8px}
.admin-list-item button{padding:6px 10px;font-size:.8rem;min-height:32px}
.project-checkboxes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:8px 0 14px}
.project-checkboxes label{display:flex;align-items:center;gap:8px;font-weight:500;border:1px solid #e4e9eb;border-radius:6px;padding:6px}
.admin-form fieldset{border:1px solid #d7e0e4;border-radius:8px;margin:10px 0}
.admin-form input,.admin-form select,.admin-form textarea{font:inherit}

/* Layout editor */
.layout-editor-body{display:flex;gap:14px;padding:14px;overflow:hidden;height:calc(90vh - 120px)}
.layout-editor-sidebar{width:240px;display:flex;flex-direction:column;gap:10px;overflow-y:auto;padding-right:6px;flex-shrink:0}
.layout-editor-sidebar h3{font-size:.92rem;margin:0;flex-shrink:0}
.editor-palette{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;min-height:60px}
.palette-item{display:flex;align-items:center;gap:8px;padding:8px;border:1px solid #d7e0e4;border-radius:8px;background:#fff;cursor:grab;font-size:.82rem;font-weight:600;transition:.15s;min-height:42px}
.palette-item:hover{border-color:#176f73;background:#eff8f7}
.palette-item img{width:40px;height:32px;object-fit:contain;border-radius:4px}
.palette-item span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.palette-item.trashed{opacity:.6;text-decoration:line-through}
#editorGallery.editor-palette{grid-template-columns:repeat(2,minmax(0,1fr));max-height:220px;overflow-y:auto;padding-right:4px}
#editorGallery .palette-item{flex-direction:column;align-items:center;justify-content:center;padding:6px;gap:4px}
#editorGallery .palette-item img{width:60px;height:50px;object-fit:cover;border-radius:4px}
#editorGallery .palette-item span{font-size:.72rem;text-align:center;max-width:100%}
.editor-trash{border:2px dashed #c0392b;border-radius:10px;padding:12px;text-align:center;color:#c0392b;font-size:.82rem;font-weight:600;background:#fff;min-height:60px;transition:.15s}
.editor-trash.drag-over{background:#fae5e3}
.layout-editor-canvas-area{flex:1;display:flex;flex-direction:column;gap:10px;min-width:0;position:relative}
.layout-toolbar{display:flex;gap:10px;align-items:center;padding-bottom:8px;border-bottom:1px solid #e4e9eb;flex-wrap:wrap}
.layout-toolbar .hint{margin-left:auto}
.layout-toolbar select{padding:6px 10px;border-radius:6px;border:1px solid #9eafb7;font:inherit}
.layout-toolbar .cb-inline{display:flex;align-items:center;gap:6px;font-size:.82rem;font-weight:500}
.layout-toolbar .cb-inline input{width:18px;height:18px;margin:0}
.canvas-wrapper{flex:1;position:relative;overflow:auto;border:1px solid #d7e0e4;border-radius:10px;background:#f8fafb;min-height:50vh}
.layout-canvas{position:relative;min-width:100%;min-height:100%;background-size:20px 20px;padding-bottom:80px}
.editor-trash-floating{position:absolute;bottom:16px;left:50%;transform:translateX(-50%);width:260px;background:#fff;border:2px dashed #c0392b;color:#c0392b;border-radius:12px;padding:12px 18px;text-align:center;font-size:.88rem;font-weight:700;box-shadow:0 4px 14px rgba(0,0,0,.12);z-index:100;transition:.15s}
.editor-trash-floating.drag-over{background:#fae5e3;border-style:solid}
.upload-btn{border:1px solid #176f73;color:#135d60;background:#fff;padding:7px 12px;border-radius:8px;font-size:.82rem;font-weight:700;cursor:pointer;display:inline-flex;align-items:center;gap:6px}
.upload-btn input{display:none}
.upload-btn:hover{background:#eff8f7}
.layout-canvas.grid-0{background-image:none}
.layout-canvas.grid-10{background-image:linear-gradient(to right,#e4e9eb 1px,transparent 1px),linear-gradient(to bottom,#e4e9eb 1px,transparent 1px);background-size:10px 10px}
.layout-canvas.grid-20{background-image:linear-gradient(to right,#d7e0e4 1px,transparent 1px),linear-gradient(to bottom,#d7e0e4 1px,transparent 1px);background-size:20px 20px}
.layout-canvas.grid-40{background-image:linear-gradient(to right,#c5d1d6 1px,transparent 1px),linear-gradient(to bottom,#c5d1d6 1px,transparent 1px);background-size:40px 40px}
.layout-canvas .canvas-hint{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#77949a;font-size:.9rem;text-align:center;padding:40px;pointer-events:none}

/* Widget properties panel */
.widget-props{position:absolute;right:12px;top:52px;width:260px;max-height:calc(100% - 70px);background:#fff;border:1px solid #d7e0e4;border-radius:10px;box-shadow:0 6px 20px rgba(0,0,0,.12);z-index:1100;display:flex;flex-direction:column;overflow:hidden}
.widget-props.hidden{display:none!important}
.widget-props-header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-bottom:1px solid #e4e9eb;background:#f8fafb}
.widget-props-header span{font-weight:700;font-size:.9rem}
.widget-props-body{padding:12px;overflow-y:auto;font-size:.85rem}
.widget-props-body h4{margin:0 0 10px;color:#203746}
.widget-props-body label.prop-row{display:flex;flex-direction:column;gap:4px;margin-bottom:10px}
.widget-props-body label.prop-row.inline{flex-direction:row;align-items:center;justify-content:space-between;gap:10px}
.widget-props-body label.prop-row span{font-weight:600;color:#52636b}
.widget-props-body input,.widget-props-body select,.widget-props-body textarea{padding:6px 8px;border:1px solid #9eafb7;border-radius:6px;font:inherit}
.widget-props-body textarea{resize:vertical}
.widget-props-body button{margin-top:8px;width:100%}

/* Toolbox */
.editor-palette .toolbox{margin-bottom:10px;padding-bottom:10px;border-bottom:1px dashed #d7e0e4}

/* Editable element on canvas */
.editor-element{position:absolute;border:2px solid #77949a;background:#fff;border-radius:8px;padding:8px;box-shadow:0 2px 6px rgba(0,0,0,.08);cursor:move;overflow:hidden;min-width:60px;min-height:40px;user-select:none;transition:box-shadow .15s,border-color .15s}
.editor-element:hover{border-color:#176f73;box-shadow:0 4px 12px rgba(23,111,115,.15)}
.editor-element.selected{border-color:#e67e22;box-shadow:0 0 0 3px rgba(230,126,34,.2);z-index:100}
.editor-element .el-label{font-size:.75rem;color:#52636b;margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.editor-element .el-content{pointer-events:none}
.editor-element.type-image .el-content,.editor-element.type-svg .el-content{height:calc(100% - 20px)}
.editor-element.type-image .el-content img{width:100%!important;height:100%!important;object-fit:fill;display:block}
.editor-element.type-svg .el-content svg{width:100%!important;height:100%!important;display:block}
.editor-element .el-content input,.editor-element .el-content select,.editor-element .el-content textarea{pointer-events:none;background:#f8fafb;opacity:.8}
.editor-element .resize-handle{position:absolute;right:0;bottom:0;width:14px;height:14px;background:#176f73;cursor:nwse-resize;border-radius:3px 0 3px 0;z-index:10}
.editor-element .resize-handle-right{position:absolute;right:-3px;top:50%;transform:translateY(-50%);width:8px;height:28px;background:#176f73;border-radius:3px;cursor:ew-resize;z-index:10}
.editor-element .resize-handle-bottom{position:absolute;bottom:-3px;left:50%;transform:translateX(-50%);width:28px;height:8px;background:#176f73;border-radius:3px;cursor:ns-resize;z-index:10}
.editor-element:not(.type-image):not(.type-svg) .resize-handle-bottom{display:none}
.editor-element .remove-btn{position:absolute;right:2px;top:2px;width:18px;height:18px;background:#c0392b;color:#fff;border:0;border-radius:3px;font-size:11px;line-height:18px;text-align:center;cursor:pointer;padding:0;display:none;z-index:10}
.editor-element:hover .remove-btn,.editor-element.selected .remove-btn{display:block}

/* Image annotation */
.annotate-body{padding:14px;display:flex;flex-direction:column;gap:10px}
.annotate-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding-bottom:8px;border-bottom:1px solid #e4e9eb}
.annotate-toolbar label{display:flex;align-items:center;gap:6px;font-size:.85rem;font-weight:600}
.annotate-toolbar input[type="color"]{width:40px;height:28px;border:0;padding:0}
.annotate-toolbar input[type="range"]{width:80px}
.annotate-canvas-wrapper{flex:1;overflow:auto;border:1px solid #d7e0e4;border-radius:10px;background:#f8fafb;display:flex;align-items:center;justify-content:center;min-height:300px}
.annotate-canvas-wrapper canvas{max-width:100%;max-height:70vh;background:#fff;cursor:crosshair;box-shadow:0 2px 8px rgba(0,0,0,.1)}

/* Responsive */
@media(max-width:960px){
  .layout-editor-body{flex-direction:column;height:auto;max-height:calc(90vh - 120px)}
  .layout-editor-sidebar{width:100%;flex-direction:row;flex-wrap:wrap}
  .editor-palette{flex-direction:row;flex-wrap:wrap}
  .layout-editor-canvas-area{min-height:50vh}
  .modal-content.wide{max-width:100%}
}
@media(max-width:640px){
  main{margin:10px auto;padding:0 8px}
  .section-body{padding:14px}
  .section-header h1{font-size:.78rem;letter-spacing:.1em}
  .modal-content{max-height:95vh;max-width:100%}
}
