/* ==========================================================================
   Basis: Design-Tokens, Reset, Typografie, Hilfsklassen und wiederverwendbare Komponenten.
   Seitenspezifisches steht in site.css, Admin-Spezifisches in admin.css.
   ========================================================================== */

/* ---- Design-Tokens ---- */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #14211e;
  --muted: #5a6864;
  --line: #e1ddd3;
  --brand: #17413a;
  --brand-dark: #0d2723;
  --brand-soft: #e6efec;
  --accent: #b9702b;
  --accent-soft: #f5e8d9;
  --ok: #2c7a4b;
  --ok-soft: #dff1e6;
  --warn: #a8700f;
  --warn-soft: #fbefd2;
  --rent: #5f6670;
  --rent-soft: #e4e6e9;
  --danger: #a63a2e;
  --danger-soft: #fbe9e6;
  --header-bg: rgba(255, 255, 255, .88);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 30, 26, .05), 0 8px 24px rgba(15, 30, 26, .06);
  --shadow-lg: 0 2px 4px rgba(15, 30, 26, .06), 0 18px 44px rgba(15, 30, 26, .14);
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101816; --surface: #19231f; --ink: #e9efec; --muted: #9db0aa; --line: #2a3834;
    --brand: #4d9c88; --brand-dark: #0a1512; --brand-soft: #1b2e29; --accent: #e09a5b; --accent-soft: #3a2a1b;
    --ok: #55c283; --ok-soft: #1c3a29; --warn: #e5b04d; --warn-soft: #3b2f14;
    --rent: #98a1ad; --rent-soft: #2a3036; --danger: #ee7b6d; --danger-soft: #3d1f1b; --header-bg: rgba(25, 35, 31, .88);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 44px rgba(0, 0, 0, .5);
  }
}

/* ---- Reset und Grundlagen ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--font-body);
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
main { flex: 1; outline: none; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.015em; text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 600; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); }
h3 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Layout-Hilfen ---- */
.wrap { width: min(1160px, 100% - 40px); margin-inline: auto; }
.narrow { width: min(640px, 100% - 32px); margin-inline: auto; }
.grid { display: grid; gap: 22px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.cluster { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

/* ---- Hilfsklassen (ersetzen Inline-Styles, damit die CSP streng bleiben kann) ---- */
.muted { color: var(--muted); }
.hint { font-size: .9rem; color: var(--muted); }
.prewrap { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.w-auto { width: auto; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 36px; } .mt-5 { margin-top: 56px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.ml-1 { margin-left: 8px; }
.maxw-sm { max-width: 340px; } .maxw-md { max-width: 680px; } .maxw-lg { max-width: 760px; }
.text-right { text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; transition: top .15s; }
.skip-link:focus { top: 12px; }
.icon { width: 1.5em; height: 1.5em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.loading { padding: 48px 0; text-align: center; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; padding: 10px 20px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 44px; transition: background .15s, border-color .15s, filter .15s; }
.btn:hover { border-color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-lg { min-height: 52px; padding: 12px 26px; font-size: 1.02rem; }
.btn-small { padding: 4px 12px; min-height: 34px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Karten und Badges ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .pad, .card.pad { padding: 22px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.available, .badge.s-erledigt { color: var(--ok); background: var(--ok-soft); }
.badge.reserved, .badge.s-in_bearbeitung { color: var(--warn); background: var(--warn-soft); }
.badge.rented, .badge.s-abgelehnt { color: var(--rent); background: var(--rent-soft); }
.badge.s-neu { color: var(--accent); background: var(--accent-soft); }
.badge.neutral { color: var(--ink); background: var(--bg); border: 1px solid var(--line); }
.badge.neutral::before { display: none; }

/* ---- Formulare ---- */
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .94rem; }
.field { margin-bottom: 15px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; padding: 10px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[readonly] { background: var(--bg); }
textarea { min-height: 96px; resize: vertical; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.checkbox input { margin-top: 5px; width: 18px; height: 18px; flex: none; }
.note { padding: 12px 14px; border-radius: 9px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--surface); }
.note.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.note.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }

/* ---- Tabellen ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); background: var(--bg); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row-sel { background: var(--accent-soft); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--brand-soft); }
td.num, th.num { text-align: right; }
table.wide { min-width: 860px; }

/* ---- Filter-Chips und Tabs ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 28px 0 14px; align-items: center; }
.filters.flush { margin-top: 0; }
.chip { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; }
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed='true'] { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 24px 0; flex-wrap: wrap; }
.tabs button { font-weight: 600; background: none; border: 0; padding: 12px 18px; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- Dialoge ---- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, 100% - 24px); max-height: calc(100dvh - 24px); overflow: auto; box-shadow: 0 24px 70px rgba(0, 0, 0, .4); background: var(--surface); color: var(--ink); }
dialog.wide { width: min(720px, 100% - 24px); }
dialog.xwide { width: min(1080px, 100% - 24px); }
dialog::backdrop { background: rgba(10, 20, 17, .6); backdrop-filter: blur(2px); }
dialog form, dialog .dlg { padding: 26px; }
dialog h2 { font-size: 1.45rem; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.dlg-actions.split { justify-content: space-between; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
