/* Webseiten-Baukasten – Verwaltung */
:root {
  --bg: #f3f4f2; --surface: #fff; --surface-2: #f0f1ee; --ink: #1d2420; --muted: #67736c; --line: #dde1dc;
  --accent: #2d5a43; --accent-soft: #e3eee7; --danger: #b3261e; --danger-soft: #fbe9e7; --warn: #8a5a00; --warn-soft: #fff4d6;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .88em; word-break: break-all; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
ul.plain { list-style: none; padding: 0; }

/* Login */
body.bare { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { background: var(--surface); width: 100%; max-width: 380px; padding: 28px; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.login-brand strong { display: block; font-size: 1.1rem; }
.login-brand span { color: var(--muted); font-size: .85rem; }
.login-box h1 { font-size: 1.15rem; margin-bottom: 16px; }
.login-form { display: grid; gap: 10px; }
.login-form input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }

/* Kopfleiste */
.topbar { position: sticky; top: 0; z-index: 50; background: #1d2a23; color: #fff; display: flex; align-items: center; gap: 20px; padding: 0 16px; min-height: 52px; flex-wrap: wrap; }
.tb-brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 600; }
.tb-brand em { font-style: normal; font-weight: 400; opacity: .7; }
.tb-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.tb-nav a { color: #d6e3da; text-decoration: none; padding: 14px 12px; border-bottom: 3px solid transparent; }
.tb-nav a:hover { color: #fff; }
.tb-nav a.active { color: #fff; border-color: #8cc9a5; }
.tb-right { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.tb-right a, .tb-right .linklike { color: #d6e3da; font-size: .9rem; }
.linklike { background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.btn.logout { background: #c9573a; border-color: #c9573a; color: #fff; }
.btn.logout:hover { filter: brightness(1.1); }
.badge { background: #e0a43a; color: #1d2a23; border-radius: 99px; padding: 0 7px; font-size: .78rem; font-weight: 700; }

.admin-main { max-width: 1320px; margin: 0 auto; padding: 20px 16px 80px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head.sticky { position: sticky; top: 52px; z-index: 40; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); }
.head-actions { display: flex; gap: 8px; align-items: center; }
.dirty-hint { color: var(--warn); font-size: .85rem; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; font: 600 .92rem var(--sans); padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9c2bc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #efc7c3; background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; padding: 2px 7px; font-size: 1rem; color: var(--muted); }
.icon:hover { border-color: var(--line); color: var(--ink); background: var(--surface); }
.icon.del:hover { color: var(--danger); }

/* Meldungen */
.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 1.2em; }
.alert.ok { background: var(--accent-soft); border-color: #a9cdb6; }
.alert.err { background: var(--danger-soft); border-color: #efc7c3; color: #6f1a14; }
.alert.info { background: #e9f0fb; border-color: #c4d5f0; }
.tag { display: inline-block; font-size: .72rem; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 1px 8px; font-weight: 600; vertical-align: middle; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* Listen */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; background: var(--surface); }
table.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
table.list .actions { white-space: nowrap; text-align: right; }
table.list .actions form { display: inline; }
.handle { cursor: grab; color: var(--muted); font-size: 1.1rem; width: 28px; user-select: none; }
tr.dragging { opacity: .4; }
tr.drop-before td { box-shadow: inset 0 3px 0 var(--accent); }
.pill { border: 0; border-radius: 99px; padding: 2px 10px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--warn-soft); color: var(--warn); }

/* Karten + Formulare */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card.help { background: var(--surface-2); }
.form-narrow { max-width: 760px; }
.field { margin: 0 0 14px; border: 0; padding: 0; }
.field > label, .field legend { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
input[type=text], input:not([type]), input[type=email], input[type=url], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: .92rem; }
.check input { margin-top: 3px; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { background: var(--surface-2); border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; padding: 8px 10px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.input-prefix input { border-radius: 0 8px 8px 0; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.type-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; display: grid; gap: 2px; position: relative; }
.type-card input { position: absolute; opacity: 0; }
.type-card span { font-size: .82rem; color: var(--muted); }
.type-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-grid h2 { margin-top: 18px; }
.settings-grid h2:first-of-type { margin-top: 0; }

/* Bearbeiten */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; margin-top: 14px; }
.edit-side { position: sticky; top: 130px; max-height: calc(100vh - 140px); overflow: auto; }
@media (max-width: 1000px) {
  .edit-grid, .settings-grid { grid-template-columns: 1fr; }
  .edit-side { position: static; max-height: none; }
  .page-head.sticky { top: 0; }
}
.tox-tinymce { border-radius: 8px !important; }

/* Typ-Editoren */
.te-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.te-toolbar .spacer { flex: 1; }
.te-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.te-row:first-child { border-top: 0; }
.te-row textarea { min-height: 62px; }
.te-btns { display: flex; flex-direction: column; gap: 2px; }
.te-btns.h { flex-direction: row; }
.te-empty { color: var(--muted); padding: 16px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }

.grid-table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 8px; }
.grid-table { border-collapse: collapse; width: 100%; }
.grid-table th, .grid-table td { border-bottom: 1px solid var(--line); padding: 2px; }
.grid-table th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.grid-table input { border: 1px solid transparent; border-radius: 4px; padding: 5px 7px; }
.grid-table input:hover { border-color: var(--line); }
.grid-table th input { font-weight: 600; }
.grid-table .rownum { color: var(--muted); font-size: .75rem; text-align: right; padding: 0 6px; width: 34px; }
.chart-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 14px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.chart-opts .field { margin: 0; }

.items { display: grid; gap: 12px; }
.item-card { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; }
.item-card .thumb { width: 150px; height: 112px; background: var(--surface-2) center/cover no-repeat; border-radius: 6px; border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; cursor: pointer; text-align: center; }
.item-card .thumb.has { border-style: solid; }
.item-card .fields { display: grid; gap: 8px; }
.item-card .fields .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 700px) { .item-card { grid-template-columns: 1fr; } .item-card .thumb { width: 100%; height: 160px; } .te-row { grid-template-columns: 1fr; } }

.media-field { display: grid; gap: 8px; }
.media-field .preview { height: 120px; background-position: center 50%; border-radius: 8px; border: 1px dashed var(--line); background: var(--surface-2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; cursor: pointer; }
.media-field .row { display: flex; gap: 6px; }

/* Markierungs-Editor */
.mk-editor .stage { position: relative; border-radius: 8px; overflow: hidden; background: var(--surface-2); user-select: none; touch-action: none; }
.mk-editor .stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.mk-editor svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mk-editor svg .s { fill: rgba(255, 214, 102, .25); stroke: #ffcf4d; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: move; }
.mk-editor svg .s.sel { fill: rgba(45, 90, 67, .35); stroke: #fff; stroke-width: 3; }
.mk-editor svg .draft { fill: rgba(255,255,255,.15); stroke: #fff; stroke-dasharray: 6 4; stroke-width: 2; vector-effect: non-scaling-stroke; }
.mk-editor svg .vtx { fill: #fff; stroke: #1d2a23; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.mk-editor svg text { fill: #fff; font: 600 13px var(--sans); paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 3px; pointer-events: none; }
.mk-editor.mode-point .stage, .mk-editor.mode-poly .stage { cursor: crosshair; }
.mk-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mk-modes button { border: 0; background: #fff; padding: 7px 12px; font: inherit; font-size: .88rem; cursor: pointer; border-right: 1px solid var(--line); }
.mk-modes button:last-child { border-right: 0; }
.mk-modes button.on { background: var(--accent); color: #fff; }
.mk-list { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; max-height: 360px; overflow: auto; }
.mk-item { display: grid; grid-template-columns: 22px 1fr 64px auto; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; border: 1px solid transparent; }
.mk-item.sel { border-color: var(--accent); background: var(--accent-soft); }
.mk-item .kind { color: var(--muted); font-size: .8rem; text-align: center; }
.mk-item input { padding: 4px 6px; }

/* Medien */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.media-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.media-card img, .media-card .file-icon { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: flex; align-items: center; justify-content: center; background: var(--surface-2); font-weight: 700; color: var(--muted); text-decoration: none; }
.media-card figcaption { padding: 8px 10px; display: grid; gap: 2px; font-size: .85rem; }
.media-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card .row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.media-card .row form { display: inline; }
.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.upload-progress { margin-top: 10px; font-size: .9rem; }

/* Auswahl-Dialog */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(15, 22, 18, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 1000px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box header, .modal-box footer { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-box header h2 { margin: 0 auto 0 0; }
.modal-box footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: space-between; }
.modal-body { padding: 12px 16px; overflow: auto; }
.media-grid.picker { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.media-grid.picker button { border: 2px solid transparent; border-radius: 8px; padding: 0; background: var(--surface-2); cursor: pointer; overflow: hidden; text-align: left; font: inherit; }
.media-grid.picker button img, .media-grid.picker button .file-icon { width: 100%; aspect-ratio: 1; object-fit: cover; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.media-grid.picker button span { display: block; font-size: .72rem; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-grid.picker button.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Nachrichten */
.messages { display: grid; gap: 8px; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.msg.unread { border-left: 4px solid #e0a43a; }
.msg-head { display: grid; grid-template-columns: 180px 1fr auto; gap: 12px; padding: 10px 14px; color: var(--ink); text-decoration: none; }
.msg-head span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head time { color: var(--muted); font-size: .85rem; }
.msg.unread .msg-head strong::after { content: " •"; color: #e0a43a; }
.msg-body { padding: 0 14px 14px; }
.msg-text { background: var(--surface-2); padding: 12px; border-radius: 8px; margin-bottom: 10px; white-space: normal; }
@media (max-width: 700px) { .msg-head { grid-template-columns: 1fr; gap: 0; } .tb-right { margin-left: 0; } }

/* Logo-Ersatz (Anfangsbuchstabe) */
.logo-letter { display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; }

/* Menü-Verwaltung */
.menu-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.menu-table td { padding: 8px 10px; }
.menu-table select, .menu-table input:not([type=checkbox]) { min-width: 140px; padding: 6px 8px; }
.menu-table tr.is-child td:nth-child(2) { padding-left: 34px; }
.menu-table tr.is-child { background: #fafbf9; }
.menu-table tr.is-off .strong { text-decoration: line-through; color: var(--muted); }
.menu-preview { position: sticky; top: 70px; }
.mp-tree { list-style: none; padding: 0; margin: 4px 0 14px; }
.mp-tree > li { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-weight: 600; }
.mp-tree ul { list-style: none; padding: 4px 0 0 14px; margin: 4px 0 0; border-left: 2px solid var(--line); font-weight: 400; }
.mp-tree ul li { padding: 2px 6px; }
.mp-tree.flat > li { font-weight: 400; }
.mp-tree .off { text-decoration: line-through; color: var(--muted); }
@media (max-width: 1000px) { .menu-grid { grid-template-columns: 1fr; } .menu-preview { position: static; } }

/* Design-Seite */
.design-grid { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 14px; }
.design-controls details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.design-controls details > summary::-webkit-details-marker { display: none; }
.design-controls details > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.design-controls details[open] > summary::before { transform: rotate(90deg); }
.design-controls details > summary h2 { margin: 0; }
.design-controls details[open] > summary { margin-bottom: 12px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; }
.df { margin-bottom: 10px; }
.checks { display: grid; gap: 2px; margin: 4px 0 8px; }
.num-unit { display: flex; align-items: stretch; }
.num-unit input { width: 100%; min-width: 0; border-radius: 8px 0 0 8px; }
.num-unit span { background: var(--surface-2); border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; padding: 7px 8px; color: var(--muted); font-size: .85rem; }
.size-table td, .size-table th { padding: 6px 8px; }
.size-table .num-unit { width: 100px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 12px; margin-bottom: 8px; }
.color-field { display: grid; grid-template-columns: 38px 86px 1fr; gap: 6px; align-items: center; font-size: .86rem; }
.color-field input[type=color] { width: 38px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.color-field input[type=text] { padding: 5px 6px; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.scheme h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 6px; }
.scheme-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 4px; }
.scheme-tabs > button[data-scheme] { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; }
.scheme-tabs > button[data-scheme].on { background: var(--accent); color: #fff; border-color: var(--accent); }
.preset-btn .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.design-media .dm-preview { height: 70px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f3f3f3 0 25%, #fff 0 50%) 0 0 / 16px 16px; margin-bottom: 6px; }
.design-media .dm-preview img { max-height: 60px; max-width: 90%; }
.design-media .row { display: flex; gap: 6px; flex-wrap: wrap; }
.design-preview { position: sticky; top: 130px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.dp-bar { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dp-bar select { flex: 1; padding: 6px 8px; }
.dp-devices button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.dp-devices button.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.dp-frame-wrap { height: calc(100vh - 200px); overflow: auto; background: #d9dcd8; display: flex; justify-content: center; }
#design-frame { width: 100%; height: 100%; border: 0; background: #fff; transition: width .2s; }
.design-io { margin-top: 16px; max-width: 560px; }
.design-io .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 1100px) { .design-grid { grid-template-columns: 1fr; } .design-preview { position: static; } .dp-frame-wrap { height: 70vh; } }
