/* Zeltplan – Gestaltung */
@font-face { font-family: Barlow; src: url(fonts/Barlow-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Barlow; src: url(fonts/Barlow-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Barlow; src: url(fonts/Barlow-SemiBold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(fonts/BarlowCondensed-SemiBold.woff2) format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --ink: #1f2a30;
  --ink-2: #2c3a41;
  --paper: #f3f5f3;
  --panel: #ffffff;
  --line: #dde2df;
  --line-2: #c9d0cc;
  --muted: #5b676d;
  --red: #b3261e;
  --red-dk: #8e1d17;
  --blue: #1f6fb2;
  --green: #1d8a4e;
  --amber: #b07800;
  --focus: 0 0 0 3px rgba(31, 111, 178, 0.35);
  --cond: 'Barlow Condensed', Barlow, 'Arial Narrow', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.4 Barlow, 'Segoe UI', system-ui, sans-serif; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
code { font-size: 0.9em; background: #eef1ef; padding: 1px 4px; border-radius: 3px; }

/* ---------- Bausteine ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 4px; background: var(--red); color: #fff; padding: 8px 14px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--red-dk); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.ghost:hover { background: #eef1ef; }
.btn.danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px #e3b5b2; }
.btn.danger:hover { background: #fbecea; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.alert { background: #fbecea; color: var(--red-dk); padding: 9px 12px; border-radius: 4px; }
.ok, .okline { background: #e7f4ec; color: #0f5a31; padding: 8px 12px; border-radius: 4px; }
.lnk { background: none; border: 0; padding: 0; color: var(--blue); text-align: left; font-weight: 500; }
.lnk:hover { text-decoration: underline; }

.fld { display: block; margin: 0 0 10px; }
.fld > span:first-child { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.fld input, .fld select, .fld textarea, .form input, .form select { width: 100%; border: 1px solid var(--line-2); border-radius: 4px; padding: 6px 8px; background: #fff; min-height: 34px; }
.fld textarea { resize: vertical; }
.fld input[readonly] { background: #f6f7f6; }
.fld input[type=range] { padding: 0; border: 0; min-height: 24px; accent-color: var(--red); }
.numwrap { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 4px; background: #fff; }
.numwrap:focus-within { box-shadow: var(--focus); }
.numwrap input { border: 0 !important; min-width: 0; box-shadow: none !important; }
.numwrap i { font-style: normal; color: var(--muted); padding: 0 8px 0 2px; font-size: 13px; }
.chk { display: flex; align-items: center; gap: 7px; margin: 6px 0 10px; }
.chk input { width: 16px; height: 16px; accent-color: var(--red); }
.chk.lift { margin-top: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13.5px; margin: 8px 0 12px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }
.kv.hl { background: #f6f3ea; padding: 8px 10px; border-radius: 4px; }
.kv b.ok { color: var(--green); }
.kv b.no { color: var(--red); }
ul.warn { margin: 6px 0 10px; padding: 0; list-style: none; }
ul.warn li { position: relative; padding: 3px 0 3px 18px; font-size: 13px; color: #7a3d00; }
ul.warn li::before { content: ''; position: absolute; left: 2px; top: 8px; width: 9px; height: 9px; background: #e8a400; transform: rotate(45deg); }
.warnhead { font-weight: 600; font-size: 13px; margin: 8px 0 0; }

/* ---------- Seiten (Login, Installation, Verwaltung) ---------- */
body.page { display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px; background: var(--paper) linear-gradient(#e7ebe8 1px, transparent 1px) 0 0 / 100% 24px; }
.page-card { width: 100%; max-width: 460px; background: #fff; padding: 28px 30px 30px; border-top: 5px solid var(--red); box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(31, 42, 48, 0.08); }
.page-card.wide { max-width: 1180px; }
.page-card h1 { font: 600 30px/1.1 var(--cond); margin: 6px 0 14px; }
.page-card h2 { font: 600 21px/1.2 var(--cond); margin: 28px 0 10px; }
.brandline { display: flex; align-items: center; gap: 9px; font: 600 17px var(--cond); letter-spacing: 0.02em; }
.brandmark { width: 24px; height: 24px; flex: none; background: var(--red) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 18 12 6l9 12z' fill='none' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M12 6v12' stroke='%23fff' stroke-width='1.6'/%3E%3C/svg%3E") center / 20px no-repeat; border-radius: 3px; }
.form fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px 4px; margin: 0 0 14px; }
.form legend { font-weight: 600; padding: 0 4px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.form label input, .form label select { margin-top: 3px; color: var(--ink); }
.form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.form.inline label { flex: 1 1 160px; margin: 0; }
.form-reset { margin-top: 8px; }
.backlink a { color: var(--blue); text-decoration: none; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tbl input, .tbl select { border: 1px solid var(--line-2); border-radius: 4px; padding: 5px 7px; min-height: 30px; width: 100%; min-width: 90px; }
.tbl input.wide { min-width: 260px; }
.tbl input.num { min-width: 56px; width: 64px; }
.tbl input[type=checkbox] { min-width: 0; width: 16px; min-height: 0; }
.tbl.small { font-size: 13px; }
.tbl tr.cur td { background: #fbf6e8; }
.tbl td.act { white-space: nowrap; text-align: right; }
.tbl td.act .btn { margin-left: 4px; }

/* ---------- App-Gerüst ---------- */
body.app { display: grid; grid-template-columns: 216px 1fr 316px; grid-template-rows: 52px 1fr; grid-template-areas: 'top top top' 'pal stage insp'; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 10px 0 8px; background: var(--ink); color: #fff; padding-top: env(safe-area-inset-top, 0px); }
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-left { flex: 1 1 auto; }
.brandbtn { display: flex; align-items: center; gap: 8px; background: none; border: 0; color: #fff; font: 600 17px var(--cond); padding: 6px 8px; border-radius: 4px; }
.brandbtn:hover { background: rgba(255, 255, 255, 0.08); }
.plan-title { display: flex; gap: 6px; min-width: 0; flex: 1 1 auto; max-width: 560px; }
.plan-title input { background: transparent; border: 1px solid transparent; color: #fff; padding: 5px 8px; border-radius: 4px; min-width: 0; }
.plan-title input:hover { border-color: rgba(255, 255, 255, 0.18); }
.plan-title input:focus { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); }
#planTitle { font-weight: 600; flex: 1.3 1 0; }
#planEvent { color: #c6d0d4; flex: 1 1 0; }
.plan-title input::placeholder { color: #8d9aa0; }
.modes { display: flex; background: rgba(255, 255, 255, 0.08); border-radius: 5px; padding: 3px; }
.modes button { border: 0; background: transparent; color: #d4dcdf; padding: 5px 14px; border-radius: 3px; font-weight: 600; font-size: 14px; }
.modes button.active { background: #fff; color: var(--ink); }
.modes button:disabled { opacity: 0.35; cursor: default; }
.icobtn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: #fff; border-radius: 4px; }
.icobtn svg { width: 20px; height: 20px; fill: currentColor; }
.icobtn:hover { background: rgba(255, 255, 255, 0.1); }
.icobtn:disabled { opacity: 0.3; cursor: default; }
.savestate { font-size: 12.5px; color: #aab6bb; min-width: 112px; text-align: right; }
.savestate.err { color: #ffb4ad; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 40px; z-index: 50; background: #fff; color: var(--ink); min-width: 250px; padding: 6px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22); }
.menu-pop button, .menu-pop a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; color: inherit; text-decoration: none; font-size: 14.5px; }
.menu-pop button:hover, .menu-pop a:hover { background: #f0f3f1; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

/* ---------- Palette ---------- */
.palette { grid-area: pal; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 8px 40px; }
.pal-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.pal-tools button { border: 1px solid var(--line-2); background: #fff; border-radius: 4px; padding: 6px 4px; font-size: 13px; font-weight: 600; }
.pal-tools button.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pal-wizard, .pal-back { width: 100%; margin: 0 0 10px; border: 0; border-radius: 4px; padding: 9px; font-weight: 600; background: var(--red); color: #fff; }
.pal-back { background: var(--ink); }
.pal-wizard:hover { background: var(--red-dk); }
.pal-sec { border-top: 1px solid var(--line); }
.pal-head { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 0; background: none; padding: 9px 4px 7px; font: 600 15px var(--cond); letter-spacing: 0.02em; text-align: left; color: var(--ink); }
.pal-head::after { content: ''; width: 7px; height: 7px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
.pal-sec.open .pal-head::after { transform: rotate(45deg); }
.pal-head.static::after { display: none; }
.pal-items { display: none; padding: 0 0 8px; }
.pal-sec.open .pal-items, .pal-head.static + .pal-items { display: block; }
.pal-items button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 5px 6px; border-radius: 4px; text-align: left; font-size: 13.5px; line-height: 1.2; }
.pal-items button svg { width: 24px; height: 16px; flex: none; }
.pal-items button:hover { background: #f0f3f1; }
.pal-items button.active { background: #fde9e7; box-shadow: inset 3px 0 0 var(--red); }
.pal-note { font-size: 13.5px; color: var(--muted); padding: 6px; }
body.readonly .pal-items button[data-kind] { opacity: 0.45; }

/* ---------- Bühne ---------- */
.stagewrap { grid-area: stage; position: relative; overflow: hidden; background: #fbfcfb; touch-action: none; }
#stage, #map { position: absolute; inset: 0; }
#stage { cursor: default; }
body.tool-place #stage, body.tool-line #stage { cursor: crosshair; }
body.tool-hand #stage { cursor: grab; }
.hint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 6px 12px; border-radius: 4px; font-size: 13px; pointer-events: none; z-index: 5; max-width: calc(100% - 20px); text-align: center; }
.hint b { color: #ffd38a; font-weight: 600; }
.zoomctl { position: absolute; right: 12px; bottom: 40px; display: flex; background: #fff; border-radius: 5px; box-shadow: 0 1px 0 var(--line-2), 0 4px 14px rgba(31, 42, 48, 0.12); z-index: 4; }
.zoomctl button { border: 0; background: none; padding: 7px 11px; font-weight: 600; font-size: 15px; }
.zoomctl button:hover { background: #f0f3f1; }
.zoomctl button + button { border-left: 1px solid var(--line); }
.statusbar { position: absolute; left: 0; right: 0; bottom: 0; height: 28px; display: flex; gap: 18px; align-items: center; padding: 0 12px; background: rgba(255, 255, 255, 0.92); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; z-index: 4; }
#stScale { display: inline-flex; align-items: center; gap: 6px; }
.scalebar { display: inline-block; height: 6px; border: 1.5px solid var(--ink); border-top: 0; }

/* ---------- Inspektor ---------- */
.inspector { grid-area: insp; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; border: 0; background: none; padding: 11px 4px 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2.5px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--red); }
.tabpane { overflow-y: auto; padding: 14px 14px 40px; flex: 1 1 auto; min-height: 0; }
.tabpane h3 { font: 600 20px/1.15 var(--cond); margin: 0 0 12px; }
.tabpane h4 { font: 600 15px var(--cond); margin: 16px 0 6px; letter-spacing: 0.02em; }
.tabpane section + section { border-top: 1px solid var(--line); margin-top: 6px; }
.standbox { border: 1px solid #ecd9a8; background: #fffaf0; border-radius: 5px; padding: 4px 12px 12px; margin: 10px 0; }
.eqlist { list-style: none; margin: 0 0 12px; padding: 0; }
.eqlist li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 5px 0; font-size: 13.5px; }
.eqlist li span { color: var(--muted); }
.eqlist button { background: none; border: 0; padding: 0; text-align: left; color: var(--blue); }
.layers { list-style: none; padding: 0; margin: 0 0 12px; }
.layers li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); padding: 3px 0; }
.layers li .chk { flex: 1; margin: 4px 0; }
.layers .cnt { font-size: 12px; color: var(--muted); min-width: 24px; text-align: right; }
.lockbtn { width: 28px; height: 28px; border: 0; background: none; color: #9aa6ad; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.lockbtn svg { width: 15px; height: 15px; fill: currentColor; }
.lockbtn.on { color: var(--red); }
.statcard { border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 4px; padding: 6px 10px; margin: 8px 0; }
.statcard.bad { border-left-color: var(--red); background: #fdf5f4; }
.statcard.warnc { border-left-color: #e8a400; }
.statcard .kv { margin: 6px 0 2px; }
.sc-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.sc-head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; border-left: 1px dashed var(--line-2); margin-left: 4px; }
.tn { display: flex; justify-content: space-between; gap: 6px; font-size: 13.5px; padding: 3px 0; }
.tn span { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
details.keys { margin-top: 18px; font-size: 13px; }
details.keys summary { cursor: pointer; color: var(--muted); }
details.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0 0; }
details.keys dt { font-weight: 600; }
details.keys dd { margin: 0; color: var(--muted); }
.callout { background: #f6f3ea; border-radius: 5px; padding: 4px 12px 12px; margin: 10px 0; }
.searchrow { display: flex; gap: 6px; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 6px 2px; font-size: 13px; }
.results button:hover { background: #f0f3f1; }

/* ---------- Dialoge ---------- */
.modal { position: fixed; inset: 0; background: rgba(31, 42, 48, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 7vh 14px; z-index: 100; overflow-y: auto; }
.modal-box { background: #fff; width: 100%; max-width: 480px; border-radius: 6px; padding: 18px 22px 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); border-top: 4px solid var(--red); }
.modal-box.wide { max-width: 760px; }
.modal-box h2 { font: 600 24px/1.15 var(--cond); margin: 0 0 12px; }
.mhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.xbtn { border: 0; background: none; font-size: 26px; line-height: 1; padding: 0 4px; color: var(--muted); }
.wiz fieldset { border: 0; border-top: 1px solid var(--line); padding: 10px 0 0; margin: 0 0 6px; }
.wiz legend { font: 600 15px var(--cond); padding: 0 6px 0 0; letter-spacing: 0.02em; }
.tbl.plans td:first-child { font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 5px; z-index: 200; max-width: min(560px, calc(100% - 24px)); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); font-size: 14px; }
.toast.err { background: var(--red-dk); }

/* ---------- Karte ---------- */
#map { background: #dfe4e1; }
#map.measuring { cursor: crosshair; }
.leaflet-container { font-family: Barlow, sans-serif; }
.zp-mlabel { background: none; border: 0; }
.zp-mlabel span { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font: 600 12px/1 var(--cond); color: var(--ink); background: rgba(255, 255, 255, 0.82); padding: 2px 4px; border-radius: 2px; }
.zp-mlabel.big span { font-size: 15px; }
.zp-mlabel.dim span { background: #ffd400; }
.zl-hide .zp-mlabel:not(.big), .zl-none .zp-mlabel, .zl-none .zp-hrot, .zl-none .zp-hmove { display: none; }
.zl-small .zp-mlabel:not(.big) span { font-size: 10px; }
.zp-hmove span, .zp-hrot span { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 50%; background: #fff; border: 2px solid var(--blue); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); color: var(--blue); font-weight: 600; font-size: 16px; }
.zp-hmove span { background: radial-gradient(circle, var(--blue) 0 3px, #fff 4px); cursor: move; }
.zp-hrot span { cursor: grab; }

/* ---------- Kleine Bildschirme ---------- */
@media (max-width: 1100px) { body.app { grid-template-columns: 186px 1fr 276px; } .savestate { display: none; } }
@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr 38vh; grid-template-areas: 'top' 'pal' 'stage' 'insp'; }
  .topbar { flex-wrap: wrap; padding: 6px; gap: 6px; }
  .plan-title { order: 3; flex-basis: 100%; max-width: none; }
  .palette { border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 6px; max-height: 128px; }
  .palette > * { flex: none; }
  .pal-sec { border-top: 0; border-left: 1px solid var(--line); padding-left: 6px; }
  .pal-sec .pal-items { display: block; }
  .pal-head::after { display: none; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  body.app { display: block; }
  .topbar, .palette, .inspector, .zoomctl, .statusbar, .hint, .toast, .leaflet-control-zoom { display: none !important; }
  .stagewrap { position: fixed; inset: 0; }
}
