/* Vereinsverwaltung – Design */
:root {
    --blau: #2563eb;
    --blau-dunkel: #1e40af;
    --grau-bg: #f4f6fb;
    --grau-linie: #e2e8f0;
    --text: #1e293b;
    --text-hell: #64748b;
    --gruen: #16a34a;
    --rot: #dc2626;
    --gelb: #d97706;
    --weiss: #ffffff;
    --radius: 10px;
    --schatten: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--grau-bg);
    font-size: 15px;
    line-height: 1.5;
}

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

.layout { display: flex; min-height: 100vh; }

/* Nur mobil sichtbar (siehe Media-Query unten) */
.topbar { display: none; }
.donut { display: none; }
.sidebar-backdrop { display: none; }

/* ---------- Seitenleiste ---------- */
.sidebar {
    width: 240px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 22px; padding: 4px 6px 0; }
.brand-logo { font-size: 56px; line-height: 1; }
.brand-logo-img { width: 104px; height: 104px; max-width: 100%; object-fit: contain; background: #fff; border-radius: 14px; padding: 8px; }
.brand-kreis { width: 100%; aspect-ratio: 1 / 1; border-radius: 50%; background-repeat: no-repeat;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.verein-wechsel { margin-bottom: 18px; }
.verein-wechsel select { width: 100%; background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.15); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.verein-wechsel select option { color: #1e293b; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.brand-adresse { font-size: 12px; line-height: 1.45; opacity: .72; }
.brand-sub { font-size: 12px; opacity: .6; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a, .sidebar-bottom a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover, .sidebar-bottom a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar nav a.active, .sidebar-bottom a.active { background: var(--blau); color: #fff; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid #1e293b; }
.sidebar-bottom a { display: block; }

/* ---------- Inhalt ---------- */
.content { flex: 1; padding: 30px 40px; max-width: 1200px; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; margin: 0; }
.page-header .sub { color: var(--text-hell); font-size: 14px; margin-top: 2px; }

h1, h2, h3 { color: var(--text); }
h2 { font-size: 18px; margin: 26px 0 12px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--blau); color: #fff;
    padding: 9px 16px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.12s;
}
.btn:hover { background: var(--blau-dunkel); text-decoration: none; }
.btn-sekundaer { background: #fff; color: var(--text); border: 1px solid var(--grau-linie); }
.btn-sekundaer:hover { background: #f8fafc; }
.btn-gefahr { background: var(--rot); }
.btn-gefahr:hover { background: #b91c1c; }
.btn-klein { padding: 5px 10px; font-size: 13px; }

/* ---------- Karten ---------- */
.karte {
    background: var(--weiss);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: 22px;
    margin-bottom: 20px;
    border: 1px solid var(--grau-linie);
}
.karten-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kennzahl { background: var(--weiss); border: 1px solid var(--grau-linie); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--schatten); }
.kennzahl .wert { font-size: 26px; font-weight: 700; }
.kennzahl .label { color: var(--text-hell); font-size: 13px; margin-top: 2px; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; background: var(--weiss); border-radius: var(--radius); overflow: hidden; box-shadow: var(--schatten); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--grau-linie); }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-hell); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td.rechts, th.rechts { text-align: right; }

/* ---------- Formulare ---------- */
form .feld { margin-bottom: 16px; }
form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #334155; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=password], input[type=search], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--grau-linie); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blau); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
textarea { resize: vertical; min-height: 90px; }
.feld-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.feld-hinweis { font-size: 12px; color: var(--text-hell); margin-top: 4px; }
fieldset { border: 1px solid var(--grau-linie); border-radius: var(--radius); padding: 18px; margin: 0 0 20px; }
fieldset legend { font-weight: 700; padding: 0 8px; color: var(--blau); }

/* ---------- Badges / Status ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-aktiv { background: #dcfce7; color: #166534; }
.badge-inaktiv { background: #f1f5f9; color: #475569; }
.badge-ausgetreten { background: #fee2e2; color: #991b1b; }
.badge-ehrenmitglied { background: #fef3c7; color: #92400e; }
.badge-offen { background: #fee2e2; color: #991b1b; }
.badge-bezahlt { background: #dcfce7; color: #166534; }
.badge-gruppe { background: #e0e7ff; color: #3730a3; margin: 2px; }

/* ---------- Flash-Meldungen ---------- */
.flash-container { margin-bottom: 20px; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 10px; font-weight: 500; border: 1px solid transparent; }
.flash-erfolg { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.flash-fehler { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.flash-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* ---------- Werkzeugleiste (Suche/Filter) ---------- */
.werkzeug { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.werkzeug .suche { flex: 1; min-width: 200px; }
.werkzeug select { width: auto; }

.leer { text-align: center; padding: 50px 20px; color: var(--text-hell); }
.leer .icon { font-size: 42px; margin-bottom: 10px; }

.tag-auswahl { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-auswahl label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; background: #f1f5f9; padding: 6px 12px; border-radius: 20px; cursor: pointer; margin: 0; }
.tag-auswahl input { width: auto; }

.aktionen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Detail-Ansicht */
.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.detail-grid dt { font-weight: 600; color: var(--text-hell); font-size: 13px; }
.detail-grid dd { margin: 0; }

.hilfe-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px; font-size: 14px; }
.hilfe-box strong { color: var(--blau-dunkel); }

/* ---------- Kalenderansichten ---------- */
.kal-tabs { display: inline-flex; gap: 2px; background: #eef2f7; padding: 3px; border-radius: 9px; }
.kal-tabs a { padding: 6px 15px; border-radius: 7px; font-weight: 600; color: #475569; font-size: 13px; }
.kal-tabs a:hover { text-decoration: none; color: var(--blau); }
.kal-tabs a.aktiv { background: #fff; color: var(--blau); box-shadow: var(--schatten); }

.kal-event { display: block; font-size: 11px; padding: 2px 5px; border-radius: 4px; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.kal-event.eigen { background: #dbeafe; color: #1e40af; }
.kal-event.eigen:hover { background: #bfdbfe; text-decoration: none; }
.kal-event.extern { background: #f1f5f9; color: #475569; }
.kal-entwurf { border: 1px dashed rgba(255,255,255,0.9); }

/* Monat */
.kal-monat { width: 100%; border-collapse: collapse; table-layout: fixed; box-shadow: var(--schatten); }
.kal-monat th { background: #f8fafc; padding: 8px; font-size: 12px; text-transform: uppercase; color: var(--text-hell); border: 1px solid var(--grau-linie); }
.kal-monat td { border: 1px solid var(--grau-linie); vertical-align: top; height: 100px; padding: 4px; background: #fff; overflow: hidden; }
.kal-tag-nr { font-size: 12px; color: #64748b; font-weight: 600; display: inline-block; min-width: 20px; text-align: center; }
.kal-td-heute .kal-tag-nr { background: var(--blau); color: #fff; border-radius: 50%; }
.kal-td-aus { background: #fafbfc; }
.kal-td-aus .kal-tag-nr { color: #cbd5e1; }

/* Woche */
.kal-woche { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.kal-wtag { background: #fff; border: 1px solid var(--grau-linie); border-radius: 10px; min-height: 200px; padding: 8px; box-shadow: var(--schatten); }
.kal-wtag-kopf { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: #334155; }

/* Jahr */
.kal-jahr { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kal-mini { border: 1px solid var(--grau-linie); border-radius: 10px; padding: 12px; background: #fff; box-shadow: var(--schatten); }
.kal-mini h3 { margin: 0 0 8px; font-size: 14px; }
.kal-mini table { width: 100%; border-collapse: collapse; box-shadow: none; }
.kal-mini td { text-align: center; font-size: 11px; padding: 3px 0; color: #334155; border: none; }
.kal-mini td.aus { color: transparent; }
.kal-mini td.hat { background: var(--blau); color: #fff; border-radius: 50%; font-weight: 700; }
.kal-mini td.heute { outline: 2px solid var(--blau); border-radius: 50%; }

/* Termin-Tooltip (Hover) */
.kal-tip { position: fixed; z-index: 9999; display: none; max-width: 250px;
    background: #0f172a; color: #fff; padding: 8px 11px; border-radius: 8px;
    font-size: 12px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,0.25); pointer-events: none; }

/* Termin-Detail-Fenster (Klick) */
.kal-modal-bg { position: fixed; inset: 0; z-index: 9998; display: none;
    background: rgba(15,23,42,0.45); align-items: center; justify-content: center; padding: 20px; }
.kal-modal-box { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 460px;
    width: 100%; position: relative; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.kal-modal-x { position: absolute; top: 12px; right: 12px; border: none; background: #f1f5f9;
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px; color: #475569; }
.kal-modal-x:hover { background: #e2e8f0; }
.kal-ev { cursor: pointer; }

/* ---------- Mobile Ansicht: Seitenleiste als Schublade ---------- */
@media (max-width: 760px) {
    /* Obere Leiste mit Menü-Knopf */
    .topbar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 900;
        background: #fff; border-bottom: 1px solid var(--grau-linie);
        padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
    }
    .topbar-titel { font-weight: 700; font-size: 16px; }

    /* Rundes Donut-Menü: schwebt unten rechts, öffnet die Navigation */
    .donut {
        display: grid; place-items: center; box-sizing: border-box;
        position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
        z-index: 1001; width: 60px; height: 60px; padding: 0;
        border-radius: 50%; cursor: pointer; color: var(--auf-primaer, #fff);
        background: var(--blau);
        border: 4px solid #fff;                 /* äußerer Ring */
        box-shadow: 0 6px 20px rgba(15,23,42,0.40),
                    inset 0 0 0 3px rgba(255,255,255,0.35);  /* innerer Ring → Donut */
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.2s ease;
    }
    .donut:active { transform: scale(0.94); }

    /* Symbol: drei Striche, die sich beim Öffnen zum ✕ drehen */
    .donut .donut-icon,
    .donut .donut-icon::before,
    .donut .donut-icon::after {
        content: ""; display: block; width: 22px; height: 3px;
        border-radius: 2px; background: currentColor;
        transition: transform 0.22s ease, opacity 0.18s ease;
    }
    .donut .donut-icon { position: relative; }
    .donut .donut-icon::before { position: absolute; left: 0; top: -7px; }
    .donut .donut-icon::after  { position: absolute; left: 0; top: 7px; }
    body.nav-offen .donut .donut-icon { background: transparent; }
    body.nav-offen .donut .donut-icon::before { transform: translateY(7px) rotate(45deg); }
    body.nav-offen .donut .donut-icon::after  { transform: translateY(-7px) rotate(-45deg); }

    @media (prefers-reduced-motion: reduce) {
        .donut, .donut .donut-icon,
        .donut .donut-icon::before, .donut .donut-icon::after { transition: none; }
    }

    /* Layout stapeln, Seitenleiste als ausklappbare Schublade */
    .layout { display: block; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;
        width: min(84vw, 300px); z-index: 1000; overflow-y: auto;
        transform: translateX(-100%); transition: transform 0.22s ease;
    }
    body.nav-offen .sidebar { transform: none; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 999; background: rgba(15,23,42,0.45); }
    body.nav-offen .sidebar-backdrop { display: block; }
    body.nav-offen { overflow: hidden; }

    .content { padding: 18px 16px; max-width: none; }
    .page-header h1 { font-size: 20px; }

    /* Datentabellen horizontal scrollbar (Kalender-Tabellen ausgenommen) */
    .content table:not(.kal-monat):not(.kal-mini) {
        display: block; overflow-x: auto; white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Detail-Ansicht einspaltig */
    .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
    .detail-grid dt { margin-top: 10px; }

    /* Kalender kompakter */
    .kal-woche { grid-template-columns: 1fr; }
    .kal-monat td { height: auto; min-height: 46px; padding: 2px; }
    .kal-monat th { padding: 5px 2px; font-size: 10px; }
    .kal-tag-nr { min-width: 18px; }
    .kal-event { font-size: 10px; padding: 1px 4px; }
}

@media print {
    .sidebar { display: none; }
    .content { padding: 0; max-width: none; }
    .no-print { display: none !important; }
}

/* @-Erwähnungen: Auswahl-Box beim Tippen */
.mention-box { position: absolute; z-index: 60; background: #fff; border: 1px solid #d3dbe3;
    border-radius: 8px; box-shadow: 0 6px 20px rgba(20,40,70,.16); min-width: 190px; max-height: 210px;
    overflow: auto; margin-top: 2px; }
.mention-opt { padding: 8px 12px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.mention-opt.an, .mention-opt:hover { background: #eef4fb; }
