/* ============================================================
 * KNW Signature – Oberfläche
 * ============================================================ */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e3e7ee;
  --line-2: #eef1f5;
  --brand: #2743b8;
  --brand-600: #1f3593;
  --brand-50: #eef1fd;
  --brand-100: #dfe5fb;
  --ink-pen: #f2a33a;
  --sidebar: #0d1424;
  --sidebar-2: #151e33;
  --sidebar-ink: #aeb8cc;
  --ok: #157f3c; --ok-bg: #e3f6ea;
  --warn: #a35a06; --warn-bg: #fdf1dc;
  --danger: #b4232a; --danger-bg: #fde7e8;
  --info: #1f5fae; --info-bg: #e5effc;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px -8px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -16px rgba(15, 23, 42, .35);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --input-border: #d6dbe4;
  --topbar-bg: rgba(243, 244, 247, .85);
  --row-hover: #fafbfd;
  --switch-off: #cfd6e1;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14.5px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 560; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, color .15s; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); border-color: var(--input-border); }
.btn:focus-visible, .input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(39, 67, 184, .3); }
.btn.primary:hover { background: var(--brand-600); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: #f3c3c6; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; height: 32px; }
.btn.icon.sm { width: 28px; height: 28px; }
.btn.block { width: 100%; }
.btn.lg { height: 42px; font-size: 14.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); outline: none; }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.grid-zip { display: grid; grid-template-columns: 120px 1fr; gap: 0 14px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type=color] { width: 38px; height: 38px; padding: 3px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex: none; }
.color-field .input { font-family: var(--mono); font-size: 12.5px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 20px; background: var(--switch-off); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(14px); }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.form-ok { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ink-pen); color: #1b1404; font-size: 11px; font-weight: 700; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; background: radial-gradient(1200px 600px at 10% -10%, #2a3f86 0%, transparent 60%), radial-gradient(700px 500px at 110% 110%, #3b2a12 0%, transparent 55%), var(--sidebar); color: #e8ecf5; padding: 44px 56px; display: flex; flex-direction: column; }
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-art > * { position: relative; z-index: 1; }
.auth-art h2 { font-size: 34px; line-height: 1.12; font-weight: 680; letter-spacing: -0.025em; max-width: 460px; margin-top: auto; }
.auth-art h2 em { font-style: normal; color: var(--ink-pen); }
.auth-art .lead { color: #aeb8cc; font-size: 15px; max-width: 440px; margin-top: 14px; }
.auth-features { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; color: #cdd5e4; font-size: 13.5px; }
.auth-features li { display: flex; gap: 10px; align-items: center; }
.auth-features svg { color: var(--ink-pen); }
.auth-sample { margin-top: 34px; margin-bottom: auto; background: var(--surface); color: var(--ink); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow-lg); max-width: 430px; transform: rotate(-1.2deg); }
.auth-sample .mail-lines { display: grid; gap: 7px; margin-bottom: 18px; }
.auth-sample .mail-lines span { height: 7px; border-radius: 4px; background: #e8ebf1; }
.auth-foot { margin-top: 28px; font-size: 12px; color: #7d889e; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 390px; }
.auth-box h1 { font-size: 25px; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 26px; }
.auth-switch { margin-top: 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: inherit; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(140deg, #3653d4, #1b2c78); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.logo-mark svg { width: 22px; height: 22px; }
.logo small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-pen); margin-top: -2px; }

/* ---------- App-Shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; z-index: 30; }
.sidebar .logo { color: #fff; padding: 2px 8px 18px; }
.nav-group { margin-top: 10px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #66728a; padding: 8px 10px 6px; font-weight: 650; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-ink); font-weight: 520; font-size: 13.5px; text-decoration: none; margin-bottom: 1px; }
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: #1d2947; color: #fff; box-shadow: inset 2px 0 0 var(--ink-pen); }
.nav a .count { margin-left: auto; }
.side-foot { margin-top: auto; border-top: 1px solid #1e2840; padding-top: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: #3a4a78; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { display: block; font-size: 11.5px; color: #7d889e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .btn { color: var(--sidebar-ink); }
.side-user .btn:hover { background: var(--sidebar-2); color: #fff; }
.tenant-chip { margin: 0 4px 6px; padding: 10px 12px; border-radius: 9px; background: var(--sidebar-2); font-size: 12px; }
.tenant-chip b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--topbar-bg); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .crumbs { font-size: 13px; color: var(--muted); }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }
.burger { display: none; }
.content { padding: 8px 28px 48px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 5px; }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.stack { display: grid; gap: 18px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.stat .ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.stat .ic.pen { background: #fdf1dc; color: #a35a06; }
.stat .ic.ok { background: var(--ok-bg); color: var(--ok); }
.stat .ic.violet { background: #f1eafd; color: #6d3fc2; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.progress { height: 8px; border-radius: 8px; background: var(--line-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 8px; background: var(--brand); transition: width .3s; }
.progress.full > span { background: var(--warn); }
.seats { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 7px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--row-hover); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user b { display: block; font-weight: 600; }
.cell-user span { display: block; font-size: 12.5px; color: var(--muted); }
.keybox { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px 3px 8px; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.toolbar .input { max-width: 280px; height: 34px; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--line-2); border-radius: 9px; }
.tabs button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 560; color: var(--muted); padding: 5px 12px; border-radius: 7px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 46px; height: 46px; border-radius: 12px; background: var(--line-2); display: grid; place-items: center; margin: 0 auto 12px; color: var(--faint); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

.notice { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); background: var(--info-bg); color: #18457e; font-size: 13.5px; margin-bottom: 18px; align-items: flex-start; }
.notice.warn { background: var(--warn-bg); color: #7a4204; }
.notice.danger { background: var(--danger-bg); color: #8a1a20; }
.notice .btn { margin-left: auto; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 550; }

/* ---------- Signaturvorschau ---------- */
.sig-frame { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; overflow-x: auto; }
.mail { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; max-width: 760px; margin: 0 auto; }
.mail-head { padding: 12px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.mail-head b { color: var(--ink-2); font-weight: 600; display: inline-block; width: 52px; }
.mail-dots { display: flex; gap: 6px; margin-bottom: 6px; }
.mail-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e1e5ec; }
.mail-body { padding: 22px 24px 26px; overflow-x: auto; }
.mail-text { font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #374151; margin-bottom: 20px; line-height: 1.55; }
.mail.mobile { max-width: 380px; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.tpl-card:hover { box-shadow: var(--shadow); border-color: var(--input-border); }
.tpl-thumb { height: 190px; overflow: hidden; background: linear-gradient(180deg, #fff, #fbfcfd); border-bottom: 1px solid var(--line-2); padding: 20px 22px; position: relative; cursor: pointer; }
.tpl-thumb .scale { transform: scale(.78); transform-origin: top left; width: 128%; pointer-events: none; }
.tpl-thumb::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(transparent, #fff); }
.tpl-meta { padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.tpl-meta .name { font-weight: 620; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-meta .when { font-size: 12px; color: var(--muted); }

.starter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.starter { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--surface); cursor: pointer; text-align: left; font: inherit; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.starter:hover { border-color: var(--input-border); }
.starter.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.starter .prev { height: 120px; overflow: hidden; padding: 14px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.starter .prev .scale { transform: scale(.6); transform-origin: top left; width: 166%; pointer-events: none; }
.starter .txt { padding: 10px 12px; }
.starter .txt b { display: block; font-size: 13.5px; }
.starter .txt span { font-size: 12px; color: var(--muted); }

/* ---------- Editor ---------- */
.editor-top { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.editor-top .name-input { border: 1px solid transparent; background: transparent; font: inherit; font-size: 16px; font-weight: 650; padding: 6px 9px; border-radius: 7px; min-width: 0; width: 320px; color: var(--ink); }
.editor-top .name-input:hover { border-color: var(--line); }
.editor-top .name-input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-100); }
.editor-top .spacer { flex: 1; }
.dirty-dot { font-size: 12px; color: var(--warn); display: inline-flex; align-items: center; gap: 6px; }
.dirty-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.editor { display: grid; grid-template-columns: 300px 330px minmax(0, 1fr); height: calc(100vh - 60px); }
.ed-col { overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); }
.ed-col.preview-col { background: var(--bg); border-right: 0; display: flex; flex-direction: column; }
.ed-section { padding: 16px; border-bottom: 1px solid var(--line-2); }
.ed-section h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.blocks { display: grid; gap: 6px; }
.blk { display: flex; align-items: center; gap: 9px; padding: 8px 8px 8px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; user-select: none; }
.blk:hover { border-color: var(--input-border); }
.blk.active { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand); }
.blk.dragging { opacity: .4; }
.blk.drop-before { box-shadow: 0 -3px 0 0 var(--ink-pen); }
.blk.drop-after { box-shadow: 0 3px 0 0 var(--ink-pen); }
.blk .grip { color: var(--faint); cursor: grab; display: grid; place-items: center; width: 16px; }
.blk .bi { width: 28px; height: 28px; border-radius: 7px; background: var(--line-2); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.blk.active .bi { background: var(--surface); color: var(--brand); }
.blk .bt { flex: 1; min-width: 0; }
.blk .bt b { display: block; font-size: 13px; font-weight: 600; }
.blk .bt span { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk .bact { display: flex; gap: 0; opacity: 0; transition: opacity .12s; }
.blk:hover .bact, .blk.active .bact { opacity: 1; }
.blk .bact .btn { width: 24px; height: 24px; color: var(--muted); }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pal { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px dashed var(--input-border); border-radius: 8px; background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 560; color: var(--ink-2); cursor: pointer; text-align: left; transition: border-color .12s, background .12s; }
.pal:hover { border-color: var(--brand); border-style: solid; background: var(--brand-50); color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-family: var(--mono); font-size: 11px; padding: 3px 7px; border-radius: 5px; background: var(--line-2); color: var(--ink-2); border: 0; cursor: pointer; }
.chip:hover { background: var(--brand-100); color: var(--brand); }
.layout-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.layout-opt { border: 1.5px solid var(--line); border-radius: 8px; padding: 9px; background: var(--surface); cursor: pointer; font: inherit; font-size: 12px; color: var(--ink-2); text-align: left; }
.layout-opt.active { border-color: var(--brand); background: var(--brand-50); color: var(--brand); font-weight: 600; }
.layout-opt .mini { height: 34px; margin-bottom: 6px; display: flex; gap: 4px; align-items: center; }
.layout-opt .mini i { display: block; background: #d7dce6; border-radius: 2px; height: 5px; }
.layout-opt.active .mini i { background: #b7c3ef; }
.layout-opt .mini .ac { background: var(--brand) !important; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.social-row { display: grid; grid-template-columns: 110px 1fr 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.social-row .input { height: 34px; font-size: 12.5px; padding: 0 8px; }
.img-field { display: grid; gap: 8px; }
.img-field .thumb { height: 64px; border: 1px dashed var(--input-border); border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.img-field .thumb img { max-height: 54px; max-width: 90%; }
.prev-toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface); }
.prev-toolbar select.input { height: 32px; width: auto; font-size: 12.5px; }
.prev-stage { padding: 28px 24px; flex: 1; }
.settings-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(13, 20, 36, .45); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.wide { max-width: 760px; }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px; font-size: 13.5px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: pop .18s ease; max-width: 380px; }
.toast.err { background: var(--danger); }
.toast svg { color: #7ee2a1; }
.toast.err svg { color: #fff; }

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.loading .spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }

details.howto { border: 1px solid var(--line); border-radius: 9px; padding: 0 14px; margin-bottom: 8px; background: var(--surface); }
details.howto summary { cursor: pointer; padding: 11px 0; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.howto summary::-webkit-details-marker { display: none; }
details.howto summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 18px; font-weight: 400; }
details.howto[open] summary::after { content: "–"; }
details.howto ol { margin: 0 0 12px; padding-left: 20px; color: var(--ink-2); font-size: 13px; display: grid; gap: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 280px minmax(0, 1fr); height: auto; }
  .ed-col { max-height: none; }
  .ed-col.settings-col { grid-column: 1; }
  .ed-col.preview-col { grid-column: 2; grid-row: 1 / span 2; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 24px; }
  .auth-art h2 { font-size: 26px; margin-top: 30px; }
  .auth-sample, .auth-features, .auth-foot { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .burger { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .cols, .cols-even, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
  .ed-col.settings-col, .ed-col.preview-col { grid-column: auto; grid-row: auto; }
  .ed-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-top .name-input { width: 100%; }
  .editor-top .dirty-dot, .editor-top .badge { display: none; }
  .editor-top { padding: 0 12px; gap: 8px; }
  .starter-grid { grid-template-columns: 1fr; }
  .tpl-grid { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { flex-direction: column; gap: 10px; padding: 14px; }
  .page-head { align-items: flex-start; }
}

/* ============================================================
 * Dunkles Design
 * ============================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f1c;
  --surface: #111829;
  --surface-2: #0d1322;
  --ink: #e6eaf3;
  --ink-2: #c2c9d8;
  --muted: #8a94a8;
  --faint: #5d677c;
  --line: #222d44;
  --line-2: #182033;
  --brand: #6a86ff;
  --brand-600: #5672f5;
  --brand-50: #172152;
  --brand-100: #24326e;
  --sidebar: #060a14;
  --sidebar-2: #10182b;
  --ok: #5fd68d; --ok-bg: #0f2b1c;
  --warn: #f5b84a; --warn-bg: #2f220b;
  --danger: #ff7b80; --danger-bg: #3a1519;
  --info: #84b5ff; --info-bg: #11264a;
  --input-border: #2b3853;
  --topbar-bg: rgba(10, 15, 28, .82);
  --row-hover: #141c30;
  --switch-off: #36435f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .6);
}
:root[data-theme="dark"] .btn.primary { color: #fff; }
:root[data-theme="dark"] .notice { color: #bcd6ff; }
:root[data-theme="dark"] .notice.warn { color: #f7d28f; }
:root[data-theme="dark"] .notice.danger { color: #ffc0c3; }
:root[data-theme="dark"] .stat .ic.pen { background: #2f220b; color: #f5b84a; }
:root[data-theme="dark"] .stat .ic.violet { background: #241a3d; color: #b69cf5; }
:root[data-theme="dark"] .toast { background: #1d2740; border: 1px solid #2b3853; }
:root[data-theme="dark"] .toast.err { background: #7d1d23; }
:root[data-theme="dark"] .layout-opt .mini i { background: #2d3a56; }
:root[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .count { color: #1b1404; }
:root[data-theme="dark"] .input:focus { box-shadow: 0 0 0 3px rgba(106, 134, 255, .25); }
:root[data-theme="dark"] .chip { background: #1b2540; }
:root[data-theme="dark"] .auth { background: var(--surface); }
:root[data-theme="dark"] .tpl-thumb::after { background: linear-gradient(transparent, #fff); }

/* E-Mail-Vorschauen bleiben immer hell – so sieht es beim Empfänger aus */
.sig-frame, .mail, .tpl-thumb, .starter .prev { background: #ffffff !important; color: #111827; }
.mail { border-color: #e3e7ee; }
.mail-head { background: #f8f9fb !important; border-bottom-color: #eef1f5 !important; color: #64748b !important; }
.mail-head b { color: #334155 !important; }
.mail-dots i { background: #e1e5ec !important; }
.mail-text { color: #374151 !important; }
.img-field .thumb { background: #f8f9fb; }
:root[data-theme="dark"] .sig-frame, :root[data-theme="dark"] .mail { border-color: #2b3853; }

/* Theme-Schalter */
.theme-btn { position: relative; }
.auth-tools { position: fixed; top: 16px; right: 16px; z-index: 40; display: flex; gap: 8px; }
.auth-tools .btn { background: var(--surface); }

/* ---------- Produkt-Kennzeichnung ---------- */
.logo small.home { color: #5fd3b0; }
.logo small.admin { color: #a5b4fc; }
.product-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; padding: 3px 9px; border-radius: 20px; background: var(--brand-50); color: var(--brand); }
.product-pill.home { background: #e2f6ef; color: #0f7a5b; }
:root[data-theme="dark"] .product-pill.home { background: #0d2a22; color: #5fd3b0; }

/* ---------- Registrierungs-Overlay ---------- */
.chooser-back { position: fixed; inset: 0; z-index: 90; background: rgba(6, 10, 20, .62); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; animation: fade .2s ease; overflow-y: auto; }
.chooser { width: 100%; max-width: 780px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px; animation: pop .22s ease; }
.chooser h2 { font-size: 23px; }
.chooser > p { color: var(--muted); margin: 6px 0 22px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice { text-align: left; border: 1.5px solid var(--line); border-radius: 14px; padding: 20px; background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.choice:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); transform: translateY(-2px); }
.choice .ci { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.choice.home .ci { background: #e2f6ef; color: #0f7a5b; }
:root[data-theme="dark"] .choice.home .ci { background: #0d2a22; color: #5fd3b0; }
.choice h3 { font-size: 17px; }
.choice .product-pill { align-self: flex-start; }
.choice ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; display: grid; gap: 3px; }
.choice .go { margin-top: auto; font-weight: 600; color: var(--brand); font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.chooser .foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.type-switch .product-pill { flex: none; }
.type-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 18px; font-size: 13px; }

/* ---------- Login / 2FA ---------- */
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.check { display: flex; gap: 9px; align-items: center; font-size: 13.5px; color: var(--ink-2); margin: -2px 0 16px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: .35em; text-align: center; height: 50px !important; }
.code-input.otp { font-size: 14px !important; letter-spacing: .02em; }
.method-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.method-tabs button { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 560; cursor: pointer; }
.method-tabs button.active { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.step-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); margin-bottom: 16px; }
.step-icon svg { width: 24px; height: 24px; }

/* ---------- Sicherheit ---------- */
.sec-item { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.sec-item:last-child { border-bottom: 0; }
.sec-item .si { width: 38px; height: 38px; border-radius: 10px; background: var(--line-2); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.sec-item .si.on { background: var(--ok-bg); color: var(--ok); }
.sec-item .st { flex: 1; min-width: 0; }
.sec-item .st p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.sub-list { margin-top: 10px; display: grid; gap: 6px; }
.sub-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.sub-row .grow { flex: 1; min-width: 0; }
.sub-row .grow span { display: block; font-size: 11.5px; color: var(--muted); }
.qr-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid #e3e7ee; line-height: 0; }
.qr svg { width: 176px; height: 176px; display: block; }
.secret-key { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; word-break: break-all; }
.codes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: var(--mono); font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.policy-row { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.policy-row:last-child { border-bottom: 0; }
.policy-row .pt b { display: block; font-size: 13.5px; font-weight: 600; }
.policy-row .pt span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; max-width: 520px; }
.policy-row .switch { padding: 0; }
.policy-row.disabled { opacity: .55; }

@media (max-width: 900px) {
  .choice-grid { grid-template-columns: 1fr; }
  .chooser { padding: 22px; }
  .auth-tools { top: 10px; right: 10px; }
}
