*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: #f0f2f5;
    color: #1a1a1a;
    min-height: 100vh;
}

/* ── Header ── */
.header {
    background: #1e3a5f;
    color: #fff;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: .03em; flex: 1; }
.header .kuerzel-badge {
    background: rgba(255,255,255,.15);
    border-radius: 999px;
    padding: 3px 12px;
    font-size: .8rem;
    font-weight: 600;
}
.header a { color: #fff; text-decoration: none; font-size: .85rem; opacity: .8; }
.header a:hover { opacity: 1; }

/* ── Main layout ── */
.main { padding: 1.2rem 1.5rem; }

/* ── Flash message ── */
.flash {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    border-radius: 6px;
    padding: .5rem .9rem;
    margin-bottom: 1rem;
    font-size: .85rem;
}
.flash.error {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ── Week navigation ── */
.woche-nav {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-bottom: 1rem;
}
.woche-nav a, .woche-nav button, .btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: .35rem .8rem;
    font-size: .85rem;
    cursor: pointer;
    color: #374151;
    text-decoration: none;
    transition: background .12s;
}
.woche-nav a:hover, .btn:hover { background: #f3f4f6; }
.woche-label { font-weight: 600; font-size: .95rem; min-width: 10rem; text-align: center; }

.btn-primary {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}
.btn-primary:hover { background: #16304f; }

.btn-danger {
    background: #fff;
    color: #dc2626;
    border-color: #fca5a5;
}
.btn-danger:hover { background: #fee2e2; }

/* ── Calendar table ── */
.kalender-wrap { overflow-x: auto; }

.kalender {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.kalender th {
    background: #f8f9fb;
    border: 1px solid #e5e7eb;
    padding: 6px 4px;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
}
.kalender th.heute { background: #dbeafe; color: #1d4ed8; }
.kalender th:first-child { width: 3rem; }

.kalender td {
    border: 1px solid #e5e7eb;
    padding: 4px;
    height: 80px;
}

.zelle-inner {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 3px;
    height: 100%;
}
.kalender td:first-child {
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    color: #6b7280;
    background: #f8f9fb;
    vertical-align: middle;
}
.kalender td.heute-col { background: #f0f6ff; }

/* ── Termin card ── */
.termin-karte {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 5px 7px;
    border-radius: 5px;
    text-decoration: none;
    color: #1a1a1a;
    font-size: .75rem;
    line-height: 1.4;
    border: 1px solid rgba(0,0,0,.08);
    transition: filter .1s;
    overflow: hidden;
}
.termin-karte:hover { filter: brightness(.94); }
.termin-karte.voll { opacity: .55; }
.termin-karte .tk-kuerzel { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termin-karte .tk-raum { color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termin-karte .tk-plaetze { color: #555; font-variant-numeric: tabular-nums; }
.termin-karte.voll .tk-plaetze { color: #991b1b; }
.termin-karte .tk-buchungen { display: block; color: #555; font-size: .7rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* "+" add link */
.zelle-add {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    text-decoration: none;
    color: #d1d5db;
    font-size: 1.3rem;
    border: 1.5px dashed #e5e7eb;
    transition: all .15s;
}
.zelle-add:hover { color: #1e3a5f; border-color: #93afd4; background: #eff6ff; }

/* Kompaktes "+" neben vorhandenen Terminen */
.zelle-add.compact {
    flex: 0 0 18px;
    font-size: .85rem;
    border-style: dashed;
    color: #c4c9d4;
    border-color: #e0e3ea;
    border-radius: 4px;
}

/* ── Forms ── */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    max-width: 480px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 1.1rem; color: #1e3a5f; }

.form-row { margin-bottom: .9rem; }
.form-row label { display: block; font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.form-row input, .form-row select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: .4rem .6rem;
    font-size: .9rem;
    outline: none;
    transition: border-color .12s;
}
.form-row input:focus, .form-row select:focus { border-color: #1e3a5f; }

.form-actions { display: flex; gap: .6rem; margin-top: 1.2rem; }

/* ── Termin detail page ── */
.termin-detail {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    max-width: 520px;
}
.termin-detail h2 { font-size: 1.05rem; margin-bottom: 1rem; color: #1e3a5f; }

.detail-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .85rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(0,0,0,.08);
}

.detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .3rem .8rem;
    font-size: .88rem;
    margin-bottom: 1.2rem;
}
.detail-grid dt { color: #6b7280; font-weight: 600; }
.detail-grid dd { color: #1a1a1a; }

.buchungen-liste { margin-top: 1.2rem; }
.buchungen-liste h3 { font-size: .88rem; font-weight: 700; color: #374151; margin-bottom: .5rem; }
.buchung-item {
    display: flex;
    justify-content: space-between;
    padding: .3rem .6rem;
    background: #f8f9fb;
    border-radius: 5px;
    margin-bottom: .25rem;
    font-size: .82rem;
}

/* ── Login page ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
}
.login-box {
    background: #fff;
    border-radius: 10px;
    padding: 2rem;
    width: 320px;
    box-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.login-box h1 { font-size: 1.2rem; color: #1e3a5f; margin-bottom: .25rem; }
.login-box .subtitle { font-size: .8rem; color: #6b7280; margin-bottom: 1.5rem; }

hr.divider { border: none; border-top: 1px solid #e5e7eb; margin: 1rem 0; }

/* ── Dankes-Box ── */
.danke-box {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-top: 1.4rem;
    background: #fff;
    border-radius: 10px;
    padding: .8rem 1.2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    font-size: .88rem;
    color: #374151;
}
.danke-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.danke-box p { margin: 0; }
.danke-box strong { color: #1e3a5f; }

/* ── Responsive ── */
.mobile-only { display: none; }

@media (max-width: 700px) {
  .desktop-only { display: none; }
  .mobile-only  { display: block; }

  /* Header */
  .header { height: auto; padding: .5rem 1rem; flex-wrap: wrap; gap: .4rem; }
  .header h1 { font-size: 1rem; flex: 1; }
  .header-links { display: flex; gap: .8rem; width: 100%; padding-bottom: .2rem; }
  .header-links a { font-size: .82rem; opacity: .9; }

  /* Woche-nav */
  .woche-nav { gap: .4rem; }
  .woche-label { font-size: .82rem; min-width: 0; }
  .btn { padding: .3rem .55rem; font-size: .8rem; }

  /* Tag-Tabs */
  .tag-tabs {
    display: flex;
    gap: 3px;
    background: #fff;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    margin-bottom: .75rem;
  }
  .tag-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 6px 2px;
    font-size: .75rem;
    line-height: 1.3;
    cursor: pointer;
    color: #374151;
    text-align: center;
    transition: background .12s;
    font-family: inherit;
  }
  .tag-tab:hover  { background: #f3f4f6; }
  .tag-tab.active { background: #1e3a5f; color: #fff; }
  .tag-tab small  { font-size: .65rem; display: block; opacity: .85; }

  /* Tag-Panels */
  .tag-panel { display: none; }
  .tag-panel.active { display: block; }

  /* Stunden-Zeilen */
  .m-stunde {
    display: flex;
    align-items: stretch;
    gap: 5px;
    margin-bottom: 4px;
    min-height: 52px;
  }
  .m-stunde.doppel { min-height: 96px; }

  .m-stunde-nr {
    flex: 0 0 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    color: #6b7280;
    background: #f8f9fb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
  }

  .m-stunde-inhalt {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: stretch;
  }
  .m-stunde-inhalt .termin-karte {
    flex: 1;
    justify-content: flex-start;
    padding: 7px 9px;
  }
  .m-stunde-inhalt .zelle-add { min-height: 48px; }
}

/* ── Radio group ── */
.radio-group { display: flex; flex-direction: column; gap: .4rem; margin-top: .15rem; }
.radio-option {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .88rem;
    font-weight: 400;
    color: #374151;
    cursor: pointer;
}
.radio-option input[type=radio] { accent-color: #1e3a5f; width: 15px; height: 15px; }
