/* Kaffeeklatsch – Mitglieder-App
   Farben aus dem Homepage-Entwurf. Ein bewusster Akzent: das Einladungs-Ticket. */

:root {
  --bg: #f7faf6;
  --surface: #ffffff;
  --text: #20251f;
  --muted: #5b6458;
  --line: #dde3d7;
  --green: #4f8f78;
  --green-dark: #2f654f;
  --green-deep: #1f3d31;
  --green-soft: #e3f1ea;
  --sun: #f2c766;
  --sun-soft: #fbefcc;
  --rose: #c95f62;
  --rose-soft: #f8e3e3;
  --radius-s: 8px;
  --radius-m: 14px;
  --focus: 0 0 0 3px var(--bg), 0 0 0 5px var(--green);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--green-dark); font-weight: 600; }
a:hover { color: var(--green-deep); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 750; }
p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Grundgerüst ---------- */

.loading {
  display: grid; place-items: center; min-height: 100dvh; color: var(--muted);
}

/* Auth-Seiten: grüner Kopf mit Logo, Formular darunter */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.auth-head {
  background: var(--green-deep);
  color: #fff;
  padding: 28px 20px 64px;
  display: grid;
  justify-items: center;
}

.auth-head a { display: block; width: min(230px, 62vw); }
.auth-head img { display: block; width: 100%; height: auto; filter: brightness(0) invert(1); }

.auth-body {
  width: min(440px, calc(100% - 32px));
  margin: -40px auto 40px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 24px 22px;
  box-shadow: 0 14px 40px rgba(31, 61, 49, 0.12);
}

.panel > h1 + p,
.panel > h2 + p { margin-top: 8px; color: var(--muted); }

.auth-foot {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.auth-foot a + a { margin-left: 14px; }

/* ---------- Formulare ---------- */

form { display: grid; gap: 16px; margin-top: 20px; }

.field { display: grid; gap: 6px; }

.field label { font-weight: 650; font-size: 0.95rem; }

.hint { font-size: 0.85rem; color: var(--muted); }
form > .hint { margin-top: -8px; }

input, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 11px 12px;
  min-height: 46px;
}

input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

input[aria-invalid="true"] { border-color: var(--rose); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button, .btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-s);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--text);
  color: #fff;
}

button:hover, .btn:hover { background: var(--green-deep); color: #fff; }
button:disabled { opacity: 0.6; cursor: progress; }

.btn-quiet {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--line);
}
.btn-quiet:hover { background: var(--green-soft); color: var(--green-deep); border-color: var(--green-soft); }

.btn-danger { background: transparent; color: var(--rose); border: 1.5px solid var(--rose-soft); }
.btn-danger:hover { background: var(--rose-soft); color: var(--rose); }

.btn-small { min-height: 38px; padding: 6px 12px; font-size: 0.9rem; }

/* Meldungen */
.msg {
  border-radius: var(--radius-s);
  padding: 12px 14px;
  font-size: 0.95rem;
}
.msg-error { background: var(--rose-soft); color: #7a2a2c; }
.msg-ok { background: var(--green-soft); color: var(--green-deep); }
.msg-info { background: var(--sun-soft); color: #5c4710; }

/* ---------- Einladungs-Ticket (der eine Akzent) ---------- */

.ticket {
  position: relative;
  margin: -6px -6px 22px;
  background: var(--sun);
  color: var(--text);
  border-radius: var(--radius-m);
  padding: 20px 22px 22px;
  transform: rotate(-1.2deg);
  box-shadow: 0 10px 26px rgba(92, 71, 16, 0.18);
}

/* Perforation links und rechts */
.ticket::before,
.ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px; height: 22px;
  margin-top: -11px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: inset 0 2px 3px rgba(92, 71, 16, 0.25);
}
.ticket::before { left: -11px; }
.ticket::after { right: -11px; }

.ticket h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); }
.ticket p { margin-top: 6px; font-weight: 600; }
.ticket .ticket-note { font-size: 1.05rem; }

@media (prefers-reduced-motion: no-preference) {
  .ticket { animation: ticket-in 520ms cubic-bezier(.2, .8, .2, 1.1) both; }
  @keyframes ticket-in {
    from { transform: translateY(-14px) rotate(-5deg); opacity: 0; }
    to   { transform: rotate(-1.2deg); opacity: 1; }
  }
}

/* ---------- Eingeloggt ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--green-deep);
  color: #fff;
}

.topbar .brand { display: block; width: 140px; }
.topbar .brand img { display: block; width: 100%; height: auto; filter: brightness(0) invert(1); }

.topbar nav { display: flex; gap: 6px; align-items: center; }
.topbar nav a, .topbar nav button {
  color: #fff;
  background: transparent;
  border: 0;
  font-weight: 650;
  font-size: 0.92rem;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: var(--radius-s);
  text-decoration: none;
}
.topbar nav a:hover, .topbar nav button:hover,
.topbar nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: #fff; }

.page {
  width: min(760px, calc(100% - 32px));
  margin: 28px auto 64px;
  display: grid;
  gap: 20px;
}

.page-head p { margin-top: 6px; color: var(--muted); max-width: 60ch; }

/* Einladungsliste */
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.item {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 16px;
}

.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.item-title { font-weight: 700; }
.item-meta { color: var(--muted); font-size: 0.9rem; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.state {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-deep);
}
.state-used { background: #eceee9; color: var(--muted); }
.state-expired { background: var(--rose-soft); color: #7a2a2c; }

.linkbox {
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-m);
}

@media (max-width: 420px) {
  .row { grid-template-columns: 1fr; }
  .topbar .brand { width: 112px; }
  .panel { padding: 20px 16px; }
}

/* ---------- Admin-Bereich ---------- */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;           /* am Handy wischbar, aber ohne sichtbare Leiste */
  box-shadow: inset 0 -1.5px 0 var(--line);
  margin-bottom: -4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--green-deep); border-bottom-color: var(--green); }

.section-title { font-size: 1.05rem; margin-bottom: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.stat {
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 16px;
}
.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { font-weight: 650; }
.stat-sub { font-size: 0.85rem; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.feed li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.feed li:first-child { border-top: 0; }
.feed time { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

.state-admin { background: var(--sun-soft); color: #5c4710; }

.kv { margin: 14px 0 0; display: grid; gap: 0; }
.kv-row { display: grid; grid-template-columns: minmax(150px, 40%) 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv-row:first-child { border-top: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.muted { color: var(--muted); font-size: 0.88rem; }
.muted-note { margin-top: 14px; color: var(--muted); font-size: 0.88rem; }

.mini-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 0; }
.mini-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}
.log-list li span:first-child { min-width: 0; }

.inline-form { margin-top: 16px; }

code { font-size: 0.88em; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

@media (max-width: 560px) {
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
  .feed li { grid-template-columns: 24px 1fr; }
  .feed time { grid-column: 2; }
  .topbar nav a, .topbar nav button { padding: 8px 7px; font-size: 0.85rem; }
}

[data-body] { display: grid; gap: 28px; }
.topbar nav a, .topbar nav button { white-space: nowrap; }

@media (max-width: 560px) {
  .topbar { padding: 10px 12px; }
  .topbar .brand { width: 96px; }
  .topbar nav { gap: 2px; }
}

/* Admin-Hinweise: nur bei echten Problemen */
.alerts { margin-bottom: 22px; }
.alerts ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  background: var(--sun-soft);
  border-left: 4px solid var(--sun);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.alert-critical { background: var(--rose-soft); border-left-color: var(--rose); }
.alert p { font-size: 0.92rem; margin-top: 2px; opacity: 0.85; }
.alerts-foot { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
nav a.has-alert::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 5px;
  vertical-align: super;
  border-radius: 50%;
  background: var(--rose);
}

/* Konto-Menü oben rechts */
.usermenu { position: relative; }
.topbar nav button.nav-icon { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; cursor: pointer; }
.topbar nav button.nav-icon svg { display: block; }
.topbar nav button.nav-icon[aria-expanded="true"],
.topbar nav button.nav-icon[aria-current="page"] { background: rgba(255, 255, 255, 0.14); }
.usermenu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(260px, calc(100vw - 24px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: 0 12px 32px rgba(20, 40, 30, 0.18);
  padding: 6px;
  z-index: 10;
}
.usermenu-panel[hidden] { display: none; }
.usermenu-head { display: grid; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu-head span:not(.state) { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.usermenu-head .state { justify-self: start; margin-top: 4px; }
.topbar .usermenu-panel a,
.topbar .usermenu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-weight: 550;
  font-size: 0.95rem;
  padding: 10px 12px;
  min-height: 0;
  border-radius: var(--radius-s);
  white-space: normal;
  cursor: pointer;
}
.topbar .usermenu-panel a:hover,
.topbar .usermenu-panel button:hover { background: var(--green-soft); color: var(--text); }
.usermenu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.topbar .usermenu-panel [data-logout] { color: var(--rose); }

/* Sprung aus dem Konto-Menü: Abschnitt nicht unter der festen Kopfzeile verstecken */
.panel { scroll-margin-top: 84px; }

/* Kalender */
.home-section { margin-bottom: 22px; }
.section-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.section-row .section-title { margin-bottom: 12px; }
.cal-month + .cal-month { margin-top: 24px; }
.ev {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.ev-date {
  display: grid;
  justify-items: center;
  line-height: 1.1;
  background: var(--green-soft);
  color: var(--green-deep);
  border-radius: var(--radius-s);
  padding: 7px 4px;
}
.ev-wd, .ev-mon { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.ev-day { font-size: 1.45rem; font-weight: 800; }
.ev-body { display: grid; gap: 3px; min-width: 0; }
.ev-body .item-title { overflow-wrap: anywhere; }
.ev-desc summary { cursor: pointer; font-size: 0.88rem; color: var(--green-dark); font-weight: 600; }
.ev-desc p { white-space: pre-line; font-size: 0.92rem; margin-top: 6px; color: var(--muted); }
.cal-sub { margin-top: 28px; }

/* ---------- Mailversand-Status (Admin > System) ---------- */
.mailcheck {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  --tone: var(--muted);
  --tone-soft: #eceee9;
}
.mailcheck-ok { --tone: var(--green); --tone-soft: var(--green-soft); }
.mailcheck-warning { --tone: #c99a1e; --tone-soft: var(--sun-soft); }
.mailcheck-error { --tone: var(--rose); --tone-soft: var(--rose-soft); }

.mailcheck-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  background: var(--tone-soft);
}
.mailcheck-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tone);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.mailcheck-title { display: grid; gap: 2px; min-width: 0; }
.mailcheck-title strong { font-size: 1.05rem; }
.mailcheck-sub { font-size: 0.88rem; color: var(--muted); }
.mailcheck-sub time { font-weight: 650; color: var(--text); }
.mailcheck-err { color: #7a2a2c; }
.mailcheck-btn { background: var(--surface); white-space: nowrap; }

.steps { list-style: none; margin: 0; padding: 4px 16px; display: grid; }
.step {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}
.step:first-child { border-top: 0; }
.step > div { display: grid; gap: 2px; min-width: 0; }
.step strong { font-size: 0.95rem; overflow-wrap: anywhere; }
.step-text { font-size: 0.88rem; color: var(--muted); }
.step code { justify-self: start; margin-top: 4px; font-size: 0.78rem; }
.step-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  background: #eceee9;
  color: var(--muted);
}
.step-ok .step-icon { background: var(--green-soft); color: var(--green-deep); }
.step-fail .step-icon { background: var(--rose); color: #fff; }
.step-fail .step-text { color: #7a2a2c; }
.step .muted { font-size: 0.8rem; white-space: nowrap; padding-top: 2px; }

.mailcheck-kv { margin: 0; padding: 4px 16px 8px; border-top: 1px solid var(--line); background: var(--bg); }
.mailcheck-kv dd .state { margin-right: 4px; }
.mailcheck-details { margin-top: 6px; font-size: 0.85rem; }
.mailcheck-details summary { cursor: pointer; color: var(--muted); }
.mailcheck-details code { display: block; margin-top: 6px; white-space: pre-wrap; }

.spin {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12em;
}

@media (prefers-reduced-motion: no-preference) {
  .mailcheck-ok .mailcheck-dot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--tone);
    animation: mc-pulse 2.4s ease-out infinite;
  }
  @keyframes mc-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.7); opacity: 0; }
  }
  .spin { animation: mc-spin 0.8s linear infinite; }
  @keyframes mc-spin { to { transform: rotate(360deg); } }
  .mailcheck.is-checking .steps { opacity: 0.45; transition: opacity 0.2s; }
  .mailcheck.just-checked .mailcheck-head { animation: mc-flash 0.9s ease-out; }
  @keyframes mc-flash {
    0% { filter: brightness(1.08) saturate(1.3); }
    100% { filter: none; }
  }
}

@media (max-width: 560px) {
  .mailcheck-head { grid-template-columns: auto 1fr; }
  .mailcheck-btn { grid-column: 1 / -1; justify-self: stretch; }
}

/* Bestätigungs-Dialog */
dialog.confirm {
  width: min(460px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(20, 40, 30, 0.35);
  overflow: hidden;
}
dialog.confirm[open] { animation: confirm-in 0.16s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
dialog.confirm::backdrop { background: rgba(20, 30, 25, 0.5); backdrop-filter: blur(2px); }
.confirm-body { display: grid; grid-template-columns: 44px 1fr; gap: 14px; padding: 24px 24px 0; }
.confirm-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--rose-soft);
  color: var(--rose);
}
dialog.confirm h2 { font-size: 1.15rem; line-height: 1.3; margin-top: 2px; }
dialog.confirm p { margin-top: 6px; color: var(--muted); font-size: 0.95rem; }
dialog.confirm p strong { color: var(--text); }
.confirm-check {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 18px 24px 0 82px;
  padding: 12px 14px;
  border: 1.5px solid var(--rose-soft);
  border-radius: var(--radius-s);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.confirm-check:hover { background: #fdf5f5; }
.confirm-check:has(input:checked) { background: var(--rose-soft); border-color: var(--rose); }
.confirm-check input {
  appearance: auto;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--rose);
  cursor: pointer;
}
.confirm-check input:focus { box-shadow: none; }
.confirm-check input:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding: 14px 24px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.confirm-actions button { min-height: 42px; padding: 8px 16px; }
.btn-delete { background: var(--rose); color: #fff; border: 0; }
.btn-delete:hover:not(:disabled) { background: #b0494c; color: #fff; }
.btn-delete:disabled { opacity: 0.4; cursor: not-allowed; }
@media (max-width: 480px) {
  .confirm-body { grid-template-columns: 1fr; padding: 22px 20px 0; }
  .confirm-check { margin: 16px 20px 0; }
  .confirm-actions { padding: 12px 20px; }
  .confirm-actions button { flex: 1; }
}

/* Dialog-Varianten */
.confirm-warn .confirm-icon { background: var(--sun-soft); color: #8a6512; }
.confirm-neutral .confirm-icon { background: var(--green-soft); color: var(--green-dark); }

/* Deaktivierte Mitglieder */
.state-disabled { background: #eceee9; color: var(--muted); }
.item-disabled .item-title, .item-disabled > .item-meta { opacity: 0.6; }
