/* ============================================================
   Karl-Event – Haupt-Stylesheet (Hell & Dunkel)
   Optik an den Karl-Verbund angeglichen (Marineblau/Blau).
   Themes über CSS-Variablen; data-theme="auto|light|dark" am <html>.
   ============================================================ */

:root,
html[data-theme="light"],
html[data-theme="auto"] {
	color-scheme: light;
	--bg: #eef2f7; --bg-soft: #e6edf6; --bg-grad-1: #dbe6f3; --bg-grad-2: #f4f7fb;
	--surface: #ffffff; --surface-raised: #f6f8fb;
	--text: #1f2a37; --muted: #6b7685; --line: #dde3ec;
	--primary: #1f3b5c; --primary-strong: #2a5483; --primary-soft: #dbe9fb;
	--accent: #2f80ed;
	--danger: #dc2626; --danger-soft: #fdeaea;
	--success: #16653a; --success-soft: #e7f6ec;
	--warn: #8a5a08; --warn-soft: #fff4e0;
	--shadow: 0 8px 28px rgba(31, 59, 92, 0.10); --radius: 14px;
	--seat-free: #cfe6d0; --seat-free-b: #4caf50;
	--seat-sel: #2f80ed; --seat-sold: #b9c1cc; --seat-block: #6b7685;
}
@media (prefers-color-scheme: dark) {
	html[data-theme="auto"] {
		color-scheme: dark;
		--bg: #0f141b; --bg-soft: #1c2531; --bg-grad-1: #131b26; --bg-grad-2: #0c1118;
		--surface: #161d27; --surface-raised: #1c2531;
		--text: #e6ebf2; --muted: #93a1b3; --line: #2a3645;
		--primary: #4f86c6; --primary-strong: #3f6fa8; --primary-soft: #1c2f48; --accent: #5aa2ff;
		--danger: #ff8a7a; --danger-soft: #3a1717; --success: #7ee2a8; --success-soft: #14301f;
		--warn: #ffd591; --warn-soft: #3a2c12; --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
		--seat-free: #1e3a26; --seat-free-b: #4caf50; --seat-sold: #2a3645; --seat-block: #3a4150;
	}
}
html[data-theme="dark"] {
	color-scheme: dark;
	--bg: #0f141b; --bg-soft: #1c2531; --bg-grad-1: #131b26; --bg-grad-2: #0c1118;
	--surface: #161d27; --surface-raised: #1c2531;
	--text: #e6ebf2; --muted: #93a1b3; --line: #2a3645;
	--primary: #4f86c6; --primary-strong: #3f6fa8; --primary-soft: #1c2f48; --accent: #5aa2ff;
	--danger: #ff8a7a; --danger-soft: #3a1717; --success: #7ee2a8; --success-soft: #14301f;
	--warn: #ffd591; --warn-soft: #3a2c12; --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
	--seat-free: #1e3a26; --seat-free-b: #4caf50; --seat-sold: #2a3645; --seat-block: #3a4150;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
	font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
	font-size: 15px; line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
input, select, textarea {
	width: 100%; border: 1px solid var(--line); border-radius: 10px;
	background: var(--surface-raised); color: var(--text); padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; min-height: 90px; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 11px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: .03em; }
code { border: 1px solid var(--line); border-radius: 6px; background: var(--surface-raised); padding: 2px 6px; font-size: 0.86rem; }

/* ---------------- Auth (Login / Setup / Update) ---------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px;
	background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 60%); }
.auth-wrap { width: min(100%, 460px); }
.auth-card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
	box-shadow: var(--shadow); padding: 30px 28px; display: grid; gap: 14px; position: relative; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.brand-name { font-size: 1.25rem; font-weight: 800; }
.brand-sub { color: var(--muted); font-size: 0.82rem; }
.brand-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 800; font-size: 22px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 0.78rem; margin: 16px 0 0; }
.auth-theme { position: absolute; top: 22px; right: 22px; }
.stack { display: grid; gap: 14px; }
.section-h { margin: 8px 0 -2px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.note { padding: 10px 12px; border-radius: 10px; font-size: 0.92rem; margin: 0; font-weight: 700; }
.note.ok { background: var(--success-soft); color: var(--success); }
.note.err { background: var(--danger-soft); color: var(--danger); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.log-box { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-family: ui-monospace, monospace; font-size: 0.86rem; }
.changelog { padding-left: 18px; } .changelog li { margin: 4px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--text); cursor: pointer; font-weight: 700; min-height: 38px; padding: 9px 14px; }
.btn-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.block { width: 100%; }

/* ---------------- App-Shell (Admin) ---------------- */
body.app { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.sidebar { grid-row: 1 / 3; grid-column: 1; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding-top: 10px; overflow-y: auto; }
.side-brand { width: 46px; height: 46px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; flex: 0 0 auto; }
.side-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.side-link { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; color: var(--muted); font-size: 9.5px; font-weight: 600; text-align: center; border-left: 3px solid transparent; }
.side-link .ic { font-size: 18px; line-height: 1; }
.side-link:hover { color: var(--text); background: var(--surface-raised); }
.side-link.on { color: var(--accent); border-left-color: var(--accent); background: var(--surface-raised); }
.side-ver { margin-top: auto; padding: 8px 4px 12px; width: 100%; text-align: center; }
.ver-badge { display: inline-block; font-size: 10px; line-height: 1.2; color: var(--muted); padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); }
.ver-up { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.topbar { grid-row: 1; grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(14px, 2.5vw, 26px); background: var(--surface); border-bottom: 1px solid var(--line); }
.tb-title { font-weight: 700; font-size: 1.02rem; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-raised); color: var(--text); cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.tb-btn:hover { border-color: var(--accent); }
.tb-user { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 5px 11px; background: var(--surface-raised); }
.tb-name { font-weight: 800; white-space: nowrap; font-size: 0.9rem; }
.content { grid-row: 2; grid-column: 2; overflow: auto; }
.page-pad { padding: 22px clamp(14px, 2.5vw, 28px); width: min(100%, 1320px); }
.app-footer { padding: 16px 26px; margin-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.76rem; text-align: center; }
.app-footer a, .site-footer a { color: var(--muted); text-decoration: underline; }

/* ---------------- Buttons ---------------- */
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--text); cursor: pointer; font-weight: 700; min-height: 38px; padding: 9px 14px; white-space: nowrap; }
.button:hover, .icon-button:hover { border-color: var(--accent); }
.button-primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.button-ghost { background: transparent; }
.button-danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.button-danger:hover { background: var(--danger); color: #fff; }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 0.86rem; }
.button-wide { width: 100%; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.icon-button { width: 38px; height: 38px; padding: 0; }

.alert { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; padding: 12px 14px; font-weight: 700; }
.alert-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.alert-success { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.alert-info { border-color: var(--accent); background: var(--primary-soft); color: var(--text); }

/* ---------------- Köpfe / Panels / Formulare ---------------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h1 { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.section-head h2 { margin: 0; font-size: 1.15rem; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 0.74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 18px; }
.panel + .panel { margin-top: 18px; }
.narrow { width: min(100%, 760px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.stacked-form { display: grid; gap: 16px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.check-row input { width: auto; }
.check-row span { margin: 0; }
.hint { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }
.subform { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
.subform > legend { font-weight: 800; font-size: 0.92rem; padding: 0 6px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 680px; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table-actions form { margin: 0; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .num { font-size: 1.7rem; font-weight: 900; }
.stat .lbl { color: var(--muted); font-size: 0.82rem; font-weight: 700; }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 0.74rem; font-weight: 800; border: 1px solid var(--line); background: var(--surface-raised); color: var(--muted); }
.badge.b-ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.b-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.b-bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.b-info { background: var(--primary-soft); color: var(--primary-strong); border-color: transparent; }
html[data-theme="dark"] .badge.b-info { color: var(--accent); }

/* ---------------- Öffentliche Webseite ---------------- */
body.site { display: flex; flex-direction: column; }
.site-wrap { width: min(100%, 1080px); margin: 0 auto; padding: 0 clamp(16px, 4vw, 28px); }
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-bar { width: min(100%, 1080px); margin: 0 auto; padding: 12px clamp(16px, 4vw, 28px); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.1rem; }
.site-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 18px; }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 700; }
.site-nav a:hover { color: var(--text); background: var(--surface-raised); }
.site-main { flex: 1; padding: 0 0 40px; }
.hero { background: linear-gradient(160deg, var(--primary), var(--primary-strong)); color: #fff; padding: 48px 0 40px; margin-bottom: 28px; }
.hero .site-wrap { display: grid; gap: 12px; }
.hero h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.4rem); }
.hero p { margin: 0; max-width: 680px; font-size: 1.05rem; opacity: .92; }
.hero .pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.hero .pill { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 5px 12px; font-size: 0.84rem; font-weight: 700; }
.site-section { padding: 8px 0 10px; }
.site-section h2 { font-size: 1.3rem; margin: 22px 0 4px; }
.site-section .sub { color: var(--muted); margin: 0 0 18px; }
.session-list { display: grid; gap: 14px; }
.session-card { display: grid; grid-template-columns: 96px 1fr auto; gap: 18px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 16px 18px; }
.session-date { text-align: center; border-right: 1px solid var(--line); padding-right: 14px; }
.session-date .d { font-size: 1.7rem; font-weight: 900; line-height: 1; }
.session-date .mo { text-transform: uppercase; color: var(--accent); font-weight: 800; font-size: 0.78rem; }
.session-date .yr { color: var(--muted); font-size: 0.74rem; }
.session-body { min-width: 0; }
.session-body h3 { margin: 0 0 4px; font-size: 1.08rem; }
.session-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 0.88rem; }
.session-cta { text-align: right; display: grid; gap: 8px; justify-items: end; }
.session-price { font-weight: 900; font-size: 1.05rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.9fr); gap: 24px; align-items: start; margin-top: 24px; }
.prose h1 { font-size: 1.7rem; margin: 0 0 6px; }
.prose h2 { font-size: 1.15rem; margin: 22px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.prose p { white-space: pre-line; }
.aside-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 20px; position: sticky; top: 80px; display: grid; gap: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.92rem; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; text-align: right; }
.empty-state { border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); padding: 28px; text-align: center; }

/* Ticket-Auswahl */
.ticket-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ticket-row:last-of-type { border-bottom: none; }
.ticket-info b { display: block; }
.ticket-qty { width: 90px; flex: 0 0 auto; }
.cart-total { display: flex; justify-content: space-between; font-weight: 900; font-size: 1.15rem; margin-top: 10px; }

/* ---------------- Saalplan ---------------- */
.seatmap-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-raised); padding: 12px; }
.seatmap { position: relative; }
.seat { position: absolute; width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--seat-free-b); background: var(--seat-free); display: grid; place-items: center; font-size: 9px; cursor: pointer; user-select: none; }
.seat.sold, .seat.held { background: var(--seat-sold); border-color: var(--seat-sold); color: var(--muted); cursor: not-allowed; }
.seat.blocked { background: var(--seat-block); border-color: var(--seat-block); cursor: not-allowed; }
.seat.sel { background: var(--seat-sel); border-color: var(--seat-sel); color: #fff; }
.seatmap-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0; font-size: 0.82rem; color: var(--muted); }
.seatmap-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.seatmap-legend .sw { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }
.stage { background: var(--primary); color: #fff; text-align: center; border-radius: 8px; padding: 8px; font-weight: 800; letter-spacing: .1em; margin-bottom: 14px; }

/* ---------------- Kasse & Scan (Personal) ---------------- */
body.staff { display: flex; flex-direction: column; min-height: 100vh; }
.staff-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px clamp(12px,3vw,22px); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.staff-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; }
.staff-right { display: flex; align-items: center; gap: 10px; }
.staff-main { flex: 1; padding: clamp(12px,3vw,22px); width: min(100%, 1100px); margin: 0 auto; }
.scan-stage { display: grid; gap: 14px; max-width: 560px; margin: 0 auto; }
#scan-video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 4/3; object-fit: cover; }
.scan-result { border-radius: var(--radius); padding: 22px; text-align: center; font-weight: 900; font-size: 1.3rem; border: 2px solid var(--line); }
.scan-result.ok { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.scan-result.dup { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.scan-result.bad { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.scan-meta { font-size: 0.92rem; font-weight: 600; color: var(--text); margin-top: 8px; }
.scan-live { display: flex; gap: 18px; justify-content: center; margin-top: 8px; }
.scan-live .num { font-size: 1.6rem; font-weight: 900; }

/* ---------------- Doku ---------------- */
.doc h2 { font-size: 1.1rem; margin: 22px 0 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.doc ul, .doc ol { margin: 6px 0 6px 4px; padding-left: 20px; line-height: 1.7; }
.doc code { word-break: break-all; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1000px) {
	.detail-grid { grid-template-columns: 1fr; }
	.aside-card { position: static; }
	.form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
	body.app { grid-template-columns: 64px 1fr; }
	.side-link { font-size: 8.5px; }
	.tb-name { display: none; }
	.session-card { grid-template-columns: 64px 1fr; }
	.session-cta { grid-column: 1 / -1; justify-items: stretch; text-align: left; }
	.session-date { border-right: none; border-bottom: 1px solid var(--line); padding: 0 0 10px; }
}
