:root {
  --bg: #f3f4f6; --panel: #ffffff; --line: #e2e4e8; --text: #1b1f27; --muted: #6b7280;
  --akzent: #192382; --akzent-hell: #e8eaf6; --gefahr: #b42318; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1, h2 { margin: 0 0 .6em; font-weight: 600; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
small, .hint { color: var(--muted); font-size: 12px; }
.hint { margin: .2em 0 .6em; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--akzent); }
.brand-mark { width: 18px; height: 18px; border: 3px solid var(--akzent); border-radius: 50%; display: inline-block; }

/* ---- Login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-box { background: var(--panel); padding: 32px; border-radius: var(--radius); width: min(380px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.login-box .brand { margin-bottom: 20px; }
.login-box label { display: block; margin: 12px 0 4px; font-weight: 500; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-box button { width: 100%; margin-top: 18px; padding: 11px; font-size: 15px; }
.fehler { background: #fde8e6; color: var(--gefahr); padding: 10px 12px; border-radius: 8px; }
.hinweis { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---- Kopfzeile ---- */
.top { display: grid; grid-template-columns: 220px 1fr auto; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-mitte { display: flex; align-items: center; gap: 12px; }
#stempel-name { font-size: 16px; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; width: min(420px, 50vw); background: transparent; }
#stempel-name:hover, #stempel-name:focus { border-color: var(--line); background: #fff; outline: none; }
.status { color: var(--muted); font-size: 12px; }
.top-rechts { display: flex; align-items: center; gap: 12px; }
.nutzer { color: var(--muted); font-size: 12px; }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: 240px 400px 1fr; gap: 16px; padding: 16px; min-height: calc(100vh - 56px); }
.bibliothek, .regler, .vorschau { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.bibliothek { padding: 14px; display: flex; flex-direction: column; }
.bib-kopf { display: flex; justify-content: space-between; align-items: center; }
.liste { list-style: none; padding: 0; margin: 8px 0; flex: 1; overflow: auto; }
.liste li { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.liste li:hover { background: var(--bg); }
.liste li.aktiv { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }
.liste li small { color: var(--muted); white-space: nowrap; }
.bib-fuss { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }

.regler { padding: 6px 14px; overflow: auto; max-height: calc(100vh - 90px); }
details { border-bottom: 1px solid var(--line); padding: 6px 0; }
details:last-child { border-bottom: 0; }
summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style: none; }
summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
.zeile { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.zeile > label:first-child:not(.check):not(.radio):not(.btn) { width: 128px; flex-shrink: 0; color: var(--muted); }
.zeile input[type=text], .zeile select { flex: 1; min-width: 60px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.zeile input[type=number] { width: 62px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.zeile input[type=range] { flex: 1; accent-color: var(--akzent); }
.zeile output { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.zeile input[type=color] { width: 44px; height: 28px; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: none; }
.zeile .kurz { max-width: 50px; flex: 0; }
.check, .radio { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.check input, .radio input { accent-color: var(--akzent); }
.nur-rund, .nur-rechteck { display: none; }
body[data-form=rund] .nur-rund { display: flex; }  body[data-form=rund] p.nur-rund { display: block; }
body[data-form=rechteck] .nur-rechteck { display: flex; }  body[data-form=rechteck] p.nur-rechteck { display: block; }
body[data-form=rechteck] label.nur-rechteck { display: inline-flex; }

.vorschau { padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.vorschau-rahmen { flex: 1; width: 100%; display: grid; place-items: center; background:
  repeating-conic-gradient(#e9eaee 0 25%, #f7f7f9 0 50%) 0 0 / 24px 24px; border-radius: var(--radius); min-height: 420px; }
#preview { max-width: 100%; max-height: 70vh; box-shadow: 0 8px 30px rgba(0,0,0,.12); background: #fff; }
.aktionen { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: #c8ccd4; background: #fafafa; }
.btn.primary { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.btn.primary:hover { background: #121a63; }
.btn.klein { padding: 5px 10px; font-size: 12px; }
.btn.gefahr { color: var(--gefahr); }
.btn.datei { display: inline-block; }
dialog { border: 0; border-radius: var(--radius); padding: 20px 24px; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(0,0,0,.3); }
#dialog-text { white-space: pre-wrap; margin-bottom: 14px; line-height: 1.5; }

a.btn { text-decoration: none; display: inline-block; }
.btn.breit { display: block; text-align: center; margin-top: 18px; padding: 11px; font-size: 15px; }
.erfolg { background: #e7f6ec; color: #1e6b3a; padding: 10px 12px; border-radius: 8px; }

/* ---- Verwaltung ---- */
.verwaltung { max-width: 960px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.karte { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.karte.gesperrt { opacity: .7; }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.karte-kopf h2 { margin: 0; }
.reihe { display: flex; gap: 8px; flex-wrap: wrap; }
.reihe input, .reihe select { flex: 1; min-width: 180px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.tabelle { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tabelle th, .tabelle td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.tabelle th { color: var(--muted); font-weight: 500; font-size: 12px; }
.aktionen-zelle { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.rot { color: var(--gefahr); }
.pw-karte { background: #fff8e1; border: 1px solid #f0d78c; border-radius: var(--radius); padding: 12px 16px; }
.pw-karte code { font-size: 15px; background: #fff; padding: 2px 6px; border-radius: 4px; user-select: all; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .regler { max-height: none; }
  .top { grid-template-columns: 1fr; gap: 6px; }
}
