/* Fairmanager Invitation – gemeinsame Gestaltung. Mobil zuerst, ohne Fremdbibliotheken. */
:root {
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f3f4f6;
    --card: #ffffff;
    --accent: #c8102e;
    --accent-dark: #9f0d25;
    --ok: #15803d;
    --warn: #b45309;
    --info: #1d4ed8;
    --radius: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.right { text-align: right; }
.centered { text-align: center; }
table.data th.wrap { white-space: normal; min-width: 6.5rem; }
table.data th.right { text-align: right; }
table.data th.centered { text-align: center; }
.nowrap { white-space: nowrap; }

/* Seitenrahmen */
.topbar { background: var(--ink); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; letter-spacing: .04em; margin-right: .5rem; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #e5e7eb; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar form { margin: 0; }
.topbar .who { color: #cbd5e1; font-size: .875rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .875rem; }

/* Knöpfe und Formulare */
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: #9ca3af; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-sm { padding: .25rem .6rem; min-height: 32px; font-size: .875rem; }
/* Im Verwaltungs- und Editor-Bereich sind alle Knöpfe gleich hoch (die Höhe von „Bearbeiten“): Text, Symbol, Link und Knopf, mit und ohne btn-sm. */
.topbar ~ main .btn { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 32px; padding: .25rem .6rem; font-size: .875rem; line-height: 1.25; }
/* Knopf nur mit Symbol (zum Beispiel der Mülleimer zum Löschen): quadratisch, Symbol mittig. */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: .25rem; min-width: 32px; }
.topbar ~ main .btn-icon { padding: .25rem; min-width: 32px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: .875rem; color: var(--muted); }
input, select, textarea { display: block; width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #d1d5db; border-radius: 6px; padding: .5rem .6rem; min-height: 40px; margin-top: .2rem; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; min-height: 0; margin: 0 .4rem 0 0; }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.form-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
/* Eine Einstellung mit Erklärung darunter (Seite Einstellungen). */
.setting { padding: .85rem 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; padding-top: 0; }
.setting:last-child { padding-bottom: 0; }
.setting > p { margin: .35rem 0 0; }
.setting .check { padding-top: 0; }
.check { display: flex; align-items: center; color: var(--ink); font-size: 1rem; padding-top: 1.4rem; }
.inline { display: inline-flex; align-items: center; gap: .5rem; }
.input-xs { width: 4.6rem; }

/* Meldungen und Abzeichen */
.msg { padding: .6rem .8rem; border-radius: 6px; margin: 0 0 1rem; border: 1px solid; }
.msg-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.msg-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.msg-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e5e7eb; color: #374151; white-space: nowrap; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-no { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-off { background: #4b5563; color: #fff; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: .45rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
/* Spaltenbreiten für Tabellen mit Eingabefeldern: nichts wird abgeschnitten, Knöpfe brechen um. */
table.data .col-name { min-width: 12rem; }
table.data .col-role { min-width: 9rem; }
table.data .col-actions { min-width: 8rem; max-width: 16rem; }
table.data tr:hover td { background: #fafafa; }
table.data tr.sub td { background: #fafafa; }

/* Belegungsbalken */
.bar { background: #e5e7eb; border-radius: 999px; height: 10px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.warn > span { background: #d97706; }
.bar.full > span { background: var(--accent); }

/* Anmeldung und RSVP-Seite */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: .8rem; background: var(--card); padding: 1.6rem; border-radius: 10px; border: 1px solid var(--line); }
.rsvp-card { width: 100%; max-width: 520px; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.rsvp-hero { display: block; width: 100%; height: auto; }
.rsvp-head { background: var(--ink); color: #fff; padding: 1.2rem 1.4rem; letter-spacing: .06em; font-size: .85rem; }
.rsvp-body { padding: 1.4rem; }
.rsvp-body h1 { font-size: 1.5rem; }

/* Schieber: Erst nach dem Umlegen werden „Ich komme“ und „Ich komme nicht“ aktiv. Rein per CSS, damit es ohne Skript funktioniert. */
.unlock { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 0; cursor: pointer; user-select: none; }
.unlock input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.unlock .track { width: 64px; height: 34px; border-radius: 999px; background: #d1d5db; position: relative; transition: background .15s; flex: none; }
.unlock .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .15s; }
.unlock input:checked + .track { background: var(--ok); }
.unlock input:checked + .track::after { transform: translateX(30px); }
.unlock input:focus-visible + .track { outline: 3px solid #93c5fd; outline-offset: 2px; }
.answer { display: grid; gap: .7rem; }
.answer button { min-height: 52px; font-size: 1.05rem; font-weight: 600; border-radius: 8px; border: 0; cursor: pointer; transition: opacity .15s; }
.answer .yes { background: var(--ok); color: #fff; }
.answer .no { background: #fff; color: #991b1b; border: 2px solid #fecaca; }
.answer button { opacity: .35; pointer-events: none; }
.unlock-scope:has(input:checked) .answer button { opacity: 1; pointer-events: auto; }
/* Alte Browser ohne :has() sollen nicht mit toten Knöpfen dastehen: Dort sind die Knöpfe immer aktiv (der Server prüft den Schieber trotzdem). */
@supports not selector(:has(*)) { .answer button { opacity: 1; pointer-events: auto; } }

/* Vorschau von Mails */
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.preview-frame.mobile { max-width: 390px; display: block; margin: 0 auto; }
pre.text-preview { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--line); padding: .8rem; border-radius: 6px; font-size: .85rem; }

@media (max-width: 640px) {
    main { padding: 1rem .75rem 3rem; }
    .card { padding: .85rem; }
}
/* Werkzeugleiste über einer Tabelle (Mülleimer, Export, Import, Plus), rechtsbündig neben der Überschrift. */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.toolbar .btn { margin: 0; }
table.data .col-check { width: 2.2rem; text-align: center; }
table.data .col-check input { margin: 0; width: auto; min-height: 0; display: inline-block; }

/* Popup (Modal): immer im sichtbaren Bereich, bei viel Inhalt mit eigener Bildlaufleiste */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, .5); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 2rem 1rem; }
.modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 760px; padding: 1.1rem 1.25rem 1.25rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; }
.modal h3 { margin: 1.1rem 0 .4rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.modal .link-box { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
@media (max-width: 600px) { .modal-backdrop { padding: .5rem; } }

/* Status-Knöpfe im Popup: Was gilt, ist farbig wie das Abzeichen in der Tabelle */
.btn-status.sel { font-weight: 600; border-color: transparent; }
.btn-status.sel.badge-ok { background: #dcfce7; color: #166534; box-shadow: inset 0 0 0 1px #86efac; }
.btn-status.sel.badge-no { background: #fee2e2; color: #991b1b; box-shadow: inset 0 0 0 1px #fca5a5; }
.btn-status.sel.badge-warn { background: #fef3c7; color: #92400e; box-shadow: inset 0 0 0 1px #fcd34d; }
.btn-status.sel.badge-off { background: #4b5563; color: #fff; }

/* Knöpfe unten in den Popups zum Eintragen (FormModal) */
.form-actions { margin-top: .75rem; }

/* Übersichten (Editoren und Admins): Kennzahlen, Ringdiagramme */
.grid.cols-6, .grid.cols-7 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 1rem; }
.donut-box { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.donut { flex: none; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; font-size: .9rem; }
.donut-legend li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.donut-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.donut-legend span { width: 3rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { margin-bottom: .9rem; font-size: .9rem; }
.meter-head { display: flex; justify-content: space-between; margin-bottom: .25rem; }
.meter-head b { font-variant-numeric: tabular-nums; }
.meter-track { height: 12px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; }
.meter-fill.customers { background: #2563eb; }
.meter-fill.employees { background: #ea580c; }
