:root {
    --bg: #F7F5F0;
    --surface: #FFFFFF;
    --ink: #1E2A24;
    --muted: #5B6B63;
    --muted-2: #8A9089;
    --line: #EDE9DD;
    --line-strong: #D8D3C6;
    --line-hover: #C7CFC8;
    --placeholder: #A8ACA3;
    --brand: #2E6F5E;
    --brand-hover: #255C4E;
    --brand-ink: #FFFFFF;
    --ok-bg: #E4EFEA;
    --ok-ink: #1F5C48;
    --warn-bg: #FBEEDD;
    --warn-ink: #92600D;
    --danger-bg: #FBEAEA;
    --danger-ink: #A23B33;
    --avatar-bg: #EDE4D3;
    --avatar-ink: #8A5A2B;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Work Sans', -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.serif { font-family: 'Fraunces', serif; }

h1 { font-family: 'Fraunces', serif; font-weight: 600; font-size: 28px; margin: 0 0 6px; }
h2 { font-family: 'Work Sans', sans-serif; font-weight: 600; font-size: 17px; margin: 0 0 12px; }
h3 { font-family: 'Work Sans', sans-serif; font-weight: 600; font-size: 15px; margin: 0 0 10px; color: var(--ink); }
.muted { color: var(--muted); }

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 76px;
    padding: 0 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.brand-mark {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 50%;
    object-fit: cover;
}
.brand-text { font-size: 17px; color: var(--ink); }
.brand-text small { font-family: 'Work Sans', sans-serif; color: var(--muted-2); font-weight: 400; font-size: 14px; }

.mainnav { display: flex; gap: 20px; flex: 1; flex-wrap: wrap; padding-left: 12px; }
.mainnav a { color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.mainnav a:hover { color: var(--ink); }

.subnav { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.subnav a { color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.subnav a:hover { color: var(--ink); }

/* --- Finanzen --- */
.fin-einnahme { color: var(--ok-ink); font-weight: 600; }
.fin-ausgabe { color: var(--danger-ink); font-weight: 600; }
.fin-vorschlag { font-size: 12.5px; color: var(--muted); }

.logout { display: flex; align-items: center; gap: 16px; }
.logout .user { color: var(--muted); font-size: 14px; }
.logout .user strong { color: var(--ink); font-weight: 600; }
.avatar {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 50%;
    background: var(--avatar-bg);
    color: var(--avatar-ink);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.topbar .btn.btn-ghost {
    border: none;
    background: transparent;
    padding: 6px 2px;
    color: var(--muted);
    font-size: 14px;
}
.topbar .btn.btn-ghost:hover { color: var(--ink); background: transparent; }

/* --- Layout --- */
.container { max-width: 1040px; margin: 0 auto; padding: 40px 40px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { margin-bottom: 6px; }
.page-head .actions { display: flex; gap: 8px; }

/* Kopf der öffentlichen Seiten (Schulcafé, Mitbringliste): Titel und Logo
   immer auf gleicher Höhe nebeneinander, Untertitel darunter – bewusst
   eigene Klasse statt .page-head, da dessen Mobil-Variante (Spalte) hier
   nicht passt. */
.public-head-wrap { margin-bottom: 28px; }
.public-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.public-head h1 { margin: 0; flex: 1 1 auto; min-width: 0; }
.public-beschreibung { white-space: pre-line; margin: 10px 0 0; line-height: 1.5; }
.page-head-logo { width: 120px; height: 120px; flex: 0 0 120px; border-radius: 50%; object-fit: cover; }

/* --- Cards & tiles --- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    margin: 0 0 20px;
}
.card-narrow { max-width: 440px; }
.card h2:first-child { margin-top: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.grid .card { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.tile {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 24px;
    color: inherit;
    text-decoration: none;
}
.tile:hover { border-color: var(--line-hover); text-decoration: none; }
.tile-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--ok-bg);
    color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.tile-title { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.tile-desc { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* --- Forms --- */
label { display: block; margin: 0 0 16px; font-weight: 500; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel],
input[type=search], select, textarea {
    width: 100%;
    margin-top: 6px;
    padding: 11px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    font: inherit;
    font-family: 'Work Sans', sans-serif;
    font-weight: 400;
    color: var(--ink);
    background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }

fieldset.roles { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 16px; padding: 12px 14px; }
fieldset.roles legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
label.check { font-weight: 400; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
label.check input { width: auto; margin-top: 0; }

.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-bar input[type=search] { flex: 0 0 280px; }
.filter-bar select { width: auto; }
.filter-bar input, .filter-bar select { margin-top: 0; }

.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.inline-form input { margin-top: 0; }
input.input-narrow { width: 64px; }
input.input-time { width: 130px; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { border-color: var(--line-hover); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; }
.btn-small {
    padding: 4px 6px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
}
.btn-small:hover { color: var(--ink); border-color: transparent; text-decoration: underline; }

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 13px; font-weight: 600;
    color: var(--muted-2);
    text-transform: uppercase; letter-spacing: 0.04em;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--line);
}
.table td { font-size: 14px; color: var(--ink); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table td.right, .table .right { text-align: right; }
.table td.center, .table th.center { text-align: center; }

.rechte-matrix-wrap { overflow-x: auto; }
.rechte-matrix th, .rechte-matrix td { white-space: nowrap; }
.rechte-matrix td:first-child, .rechte-matrix th:first-child { white-space: normal; }
.rechte-modul-zeile td { background: var(--bg); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-2); padding-top: 10px; padding-bottom: 10px; }

/* --- Badges, flash, alerts --- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-off { background: var(--warn-bg); color: var(--warn-ink); }

.flash { background: var(--ok-bg); border: 1px solid #CFE3D8; color: var(--ok-ink); padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.alert { background: var(--danger-bg); border: 1px solid #F0CFCB; color: var(--danger-ink); padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; }
.field-error { display: block; color: var(--danger-ink); font-weight: 400; font-size: 13px; margin-top: 4px; }

.filelist { list-style: none; padding: 0; margin: 0 0 16px; }
.filelist li { padding: 4px 0; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* --- Anmeldung (Split-Layout) --- */
body.auth { background: var(--surface); }
body.auth .container { max-width: none; padding: 0; margin: 0; }
body.auth .container > .flash,
body.auth .container > .alert { margin: 24px; }

.auth-shell { display: flex; min-height: 100vh; }
.auth-brand {
    width: 480px; flex: 0 0 480px;
    background: var(--brand);
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 56px; overflow: hidden;
}
.auth-brand::before, .auth-brand::after {
    content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,0.07);
}
.auth-brand::before { width: 300px; height: 300px; top: -90px; right: -110px; }
.auth-brand::after { width: 340px; height: 340px; bottom: -130px; left: -70px; background: rgba(255,255,255,0.05); }
.auth-logo { position: relative; z-index: 1; display: block; width: 72px; height: 72px; border-radius: 50%; margin-bottom: 24px; background: rgba(255,255,255,0.9); }
.auth-headline { position: relative; z-index: 1; color: #FFFFFF; font-size: 34px; font-weight: 600; line-height: 1.25; max-width: 380px; }
.auth-sub { position: relative; z-index: 1; color: rgba(255,255,255,0.85); font-size: 16px; margin-top: 18px; max-width: 360px; line-height: 1.55; }
.auth-copy { position: relative; z-index: 1; color: rgba(255,255,255,0.6); font-size: 13px; }

.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 56px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 10px; }
.auth-form h1 { font-size: 32px; margin-bottom: 8px; }
.auth-form .muted { margin-bottom: 28px; }
.auth-form .btn-primary { width: 100%; justify-content: center; padding: 13px; font-size: 16px; margin-top: 4px; }
.auth-footnote { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted-2); text-align: center; line-height: 1.5; }
.auth-forgot { margin-top: 16px; text-align: center; font-size: 14px; }

/* --- Schulcafé --- */
.cafe-slot { border-top: 1px solid var(--line); padding: 16px 0; }
.cafe-slot:first-of-type { padding-top: 0; }

.cafe-taetigkeiten { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cafe-taetigkeit { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.cafe-taetigkeit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cafe-namen { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.cafe-namen li { padding: 2px 0; }
.cafe-anmelden { display: flex; gap: 8px; }
.cafe-anmelden input { margin-top: 0; }
.cafe-anmelden .btn { white-space: nowrap; padding: 11px 14px; }
.cafe-kontakt-hinweis { font-size: 12.5px; color: var(--ok-ink); margin: 6px 0 0; }
.cafe-slot-warnung { font-size: 12.5px; color: var(--danger-ink); font-weight: 600; margin: 6px 0 0; }

.cafe-eintraege { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.cafe-eintrag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
    padding: 3px 4px 3px 10px; font-size: 13px;
}
.cafe-kontakt-inline { color: var(--muted-2); font-size: 12px; }
.cafe-eintrag-loeschen { display: inline-flex; margin: 0; }
.cafe-eintrag-x {
    border: none; background: transparent; color: var(--muted-2); cursor: pointer;
    font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 999px;
}
.cafe-eintrag-x:hover { background: var(--danger-bg); color: var(--danger-ink); }

/* --- Mitbringliste --- */
.mitbringen-anmelden { flex-wrap: wrap; }
.mitbringen-anmelden input[type=text] { flex: 1 1 160px; min-width: 0; }
.mitbring-liste-ueberschrift { margin: 24px 0 10px; }
/* Öffentliche Seite: Typen-Karten im Raster – zwei nebeneinander, wenn Platz ist. */
.mitbring-typen { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-bottom: 8px; }
.mitbring-typ-karte { margin: 0; padding: 18px; display: flex; flex-direction: column; }
.mitbring-typ-karte .cafe-anmelden-wrap { margin-top: auto; }
/* Zwei Textfelder teilen sich die Zeile, Eintragen-Button immer darunter. */
.mitbring-typ-karte .mitbringen-anmelden input[type=text] { flex: 1 1 calc(50% - 4px); }
.mitbring-typ-karte .mitbringen-anmelden .btn { flex: 0 0 auto; }
.mitbring-typ-karte .mitbring-typ-head { justify-content: space-between; }
.mitbring-typ-karte .cafe-namen { margin-bottom: 10px; }
.mitbring-liste-kopf { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.mitbring-liste-titel { display: flex; gap: 8px; align-items: center; flex: 1 1 280px; }
.mitbring-liste-titel input { margin-top: 0; flex: 1; min-width: 0; font-weight: 600; }
.mitbring-typ { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.mitbring-typ h3 { margin: 0; }
.mitbring-typ-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mitbring-typ-head h3 { margin: 0; }
.mitbring-typ-neu input.input-ziel { margin-top: 0; width: 130px; }
.mitbring-typ-neu { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.mitbring-typ-neu input[type=text] { margin-top: 0; flex: 1 1 180px; min-width: 0; }
.mitbring-typ-neu .check { margin: 0; }
.textarea-gross { min-height: 220px; resize: vertical; }

/* --- Schulcafé: Kontakt-Dialog --- */
.cafe-kontakt-dialog {
    border: none;
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}
.cafe-kontakt-dialog::backdrop { background: rgba(20,26,22,0.45); }
.cafe-kontakt-dialog h2 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.cafe-kontakt-dialog .muted { margin: 0 0 18px; font-size: 13.5px; line-height: 1.5; }
.cafe-kontakt-error {
    background: var(--danger-bg); color: var(--danger-ink);
    padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.cafe-kontakt-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* --- Mobil (Tablet/Smartphone) --- */
@media (max-width: 760px) {
    .topbar { height: auto; padding: 12px 16px; gap: 8px 16px; }
    .brand { order: 1; }
    .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
    .brand-text { font-size: 15px; }
    .brand-text small { display: none; }
    .logout { order: 2; gap: 10px; }
    .logout .user { display: none; }
    .avatar { width: 30px; height: 30px; flex-basis: 30px; font-size: 12px; }
    .mainnav {
        order: 3;
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 16px;
        padding-left: 0;
        -webkit-overflow-scrolling: touch;
    }
    .mainnav a { white-space: nowrap; font-size: 13.5px; }

    .container { padding: 20px 16px 48px; }

    h1 { font-size: 22px; }
    .page-head { flex-direction: column; align-items: stretch; margin-bottom: 20px; }
    .page-head .actions { flex-wrap: wrap; }
    .public-head-wrap { margin-bottom: 20px; }
    .page-head-logo { width: 56px; height: 56px; flex: 0 0 56px; }

    .card { padding: 16px; border-radius: 12px; margin-bottom: 14px; overflow-x: auto; }

    .tiles, .grid { grid-template-columns: 1fr; gap: 12px; }
    .tile { padding: 18px; }

    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input[type=search] { flex: 1 1 auto; }
    .filter-bar select { width: 100%; }

    label { margin-bottom: 14px; }
    input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel],
    input[type=search], select, textarea {
        padding: 10px 12px;
    }
    .btn { padding: 10px 14px; }

    .table th, .table td { padding: 10px; font-size: 13px; }

    .cafe-taetigkeiten { grid-template-columns: 1fr; gap: 10px; }
    .cafe-taetigkeit { padding: 12px; border-radius: 8px; }
    .cafe-slot { padding: 12px 0; }
    .cafe-anmelden { flex-wrap: wrap; }
    .cafe-anmelden input[type=text] { flex: 1 1 140px; min-width: 0; }
    .mitbring-typen { grid-template-columns: 1fr; gap: 10px; }
    .mitbring-typ-karte { padding: 14px; margin: 0; }
    .mitbring-typ-karte .mitbringen-anmelden input[type=text] { flex-basis: 100%; }

    .auth-shell { flex-direction: column; min-height: auto; }
    .auth-brand { width: auto; flex: none; padding: 24px 24px 20px; min-height: auto; }
    .auth-brand::before, .auth-brand::after { display: none; }
    .auth-logo { width: 44px; height: 44px; margin-bottom: 12px; }
    .auth-headline { font-size: 21px; max-width: none; }
    .auth-sub, .auth-copy { display: none; }
    .auth-form-wrap { padding: 28px 20px; }

    .cafe-kontakt-dialog { max-width: none; width: calc(100% - 32px); padding: 20px; }
}
