:root {
  /* Brand tokens — keep these in sync with auth-action/action.html. The
     auth-mail templates use the same palette via auth-mails/templates.js.
     Both files are intentionally duplicated because the auth-action page is
     served as standalone HTML (no Vue/SPA asset pipeline). */
  --foam: #ffffff;
  --beer: #f9d32a;
  --beer-dark: #e3be2d;
  --ink: #141414;
  --accent: #1a8f6b;
  --paper: #fffaf0;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  --circle-shadow: rgba(184, 163, 90, 0.32);
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--beer);
  min-height: 100vh;
}

/* Hero geometry mirrors the auth-action handler page exactly so brand
   consistency is preserved across mail → action page → main website:
   - Foam solid: 110px white block at the top
   - Foam wave: 36px transitioning into yellow
   - Wave mid-line at y=128 (page top)
   - Circle (196px) center positioned at y=128 → straddles the boundary
   The page-top math:
     hero-content padding-top (30) + half-circle (98) = 128 = wave-mid. */
.hero {
  position: relative;
  min-height: 260px;
  background: transparent;
  overflow: visible;
}

.foam-solid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 110px;
  background: var(--foam);
  z-index: 0;
}

.foam-wave {
  position: absolute;
  top: 110px;
  left: 0;
  right: 0;
  height: 36px;
  line-height: 0;
  z-index: 0;
  pointer-events: none;
}

.foam-wave svg {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-content {
  position: relative;
  z-index: 1;
  padding-top: 30px;
  text-align: center;
}

.logo-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 196px;
  height: 196px;
  border-radius: 98px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 16px var(--circle-shadow);
  margin: 0 auto;
}

.logo-text {
  font-family: "Luckiest Guy", "Impact", sans-serif;
  font-size: 64px;
  line-height: 1;
  color: #141414;
  letter-spacing: 0;
  text-shadow: 1px 2px 1px rgba(0, 0, 0, 0.18);
  transform: translateY(4px);
}

/* Admin variant: BIR! stays exactly at the circle center (same flex centering
   as the normal logo-circle), and "Admin" is layered as an absolute label
   near the circle bottom. Outer click → "/" via onclick handler; Admin label
   click → "/admin" with stopPropagation so the outer handler doesn't fire. */
.logo-circle-admin {
  position: relative;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.logo-circle-admin:hover { transform: translateY(-1px); }
.logo-circle-admin:focus-visible { outline: 2px solid #141414; outline-offset: 3px; }

.logo-admin-label {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  font-family: "Luckiest Guy", "Impact", sans-serif;
  font-size: 20px;
  line-height: 1;
  color: #141414;
  letter-spacing: 0.5px;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.logo-admin-label:hover { background: rgba(0, 0, 0, 0.08); }
.logo-admin-label:focus-visible { outline: 2px solid #141414; outline-offset: 2px; }

.admin-link {
  display: inline-block;
  margin-top: 0.9rem;
  text-decoration: none;
  font-weight: 700;
  color: #fff;
  background: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: 999px;
}

.layout {
  max-width: 920px;
  margin: 0 auto;
  padding: 1rem;
}

.content-card {
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.content-card h2 {
  margin: 0 0 0.5rem;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.94rem;
  color: rgba(0, 0, 0, 0.72);
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
}

input,
textarea,
button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  font-family: inherit;
  font-size: 0.97rem;
}

input,
textarea {
  padding: 0.65rem 0.7rem;
  background: #ffffff;
}

button {
  margin-top: 0.8rem;
  border: none;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.feedback {
  margin: 0.8rem 0 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-btn {
  width: auto;
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 0.55rem 0.8rem;
  margin: 0;
  border-radius: 999px;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

.tab-content {
  margin-top: 1rem;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.11);
  padding: 1rem;
}

.tab-content p {
  margin: 0.45rem 0;
}

.faq-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
}

.faq-list article {
  background: var(--paper);
  border: 1px dashed rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 0.7rem;
}

.faq-list h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

/* FAQ/legal body text comes from SQLite as plain text. Honor the editor's
   line breaks ("\n") and let long URLs/tokens wrap instead of overflow. */
.faq-body,
.legal-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0 0 0.5rem;
}

.panel {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.admin-login-card,
.admin-requests-card {
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

/* Logged-out state: full-width card so the auth area looks like a real
   panel header, not a tiny floating button block. Inner content (form
   inputs, paragraphs) stays at a comfortable reading width via internal
   max-width on direct children. */
.admin-login-card {
  width: 100%;
  padding: 1.4rem 1.2rem;
}

.admin-login-card > h2,
.admin-login-card > .hint,
.admin-login-card > .status,
.admin-login-card > .feedback,
.admin-login-card > form,
.admin-login-card > div {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.admin-login-card > .status {
  display: block;
  width: max-content;
}

@media (min-width: 900px) {
  .admin-login-card {
    padding: 1.8rem 2rem;
  }
  .admin-login-card > h2 {
    text-align: center;
  }
  .admin-login-card > .hint:first-of-type {
    text-align: center;
  }
  .admin-login-card > .status {
    margin-left: auto;
    margin-right: auto;
  }
}

.admin-login-card h2,
.admin-requests-card h2 {
  margin-top: 0;
}

.status {
  display: inline-block;
  margin: 0.4rem 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.85rem;
  font-weight: 700;
}

.status.ok {
  background: rgba(26, 143, 107, 0.17);
}

/* Löschanträge-Header: h2 + Hint links, kompakter "Neu laden"-Button rechts auf
   Desktop. Auf Mobile wickelt der Button unter den Titel und bekommt margin,
   damit er nicht direkt auf der ersten Antrags-Karte liegt. */
.requests-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 0 0 1rem;
}

.requests-header-titles {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 auto;
  min-width: 0;
}

.requests-header-titles h2 {
  margin: 0;
}

.requests-header-titles .hint {
  margin: 0;
}

.requests-reload-btn {
  width: auto;
  margin: 0;
  min-height: 38px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  align-self: flex-start;
  flex: 0 0 auto;
}

@media (max-width: 540px) {
  .requests-header {
    /* Mobile: Titel oben, Button daneben oder darunter — Button bekommt eigene
       Reihe mit margin-top damit er nicht auf die Antrags-Karten klebt. */
    margin-bottom: 0.6rem;
  }
  .requests-reload-btn {
    width: 100%;
    margin-top: 0.4rem;
  }
}

.request-list {
  display: grid;
  gap: 0.8rem;
}

.request-item {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  background: #fff;
  padding: 0.8rem;
}

.request-meta {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.76);
}

.request-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  margin-right: 0.35rem;
}

.status-pill.done {
  background: rgba(26, 143, 107, 0.18);
}

.status-pill.failed {
  background: rgba(184, 31, 31, 0.16);
}

.request-actions {
  margin-top: 0.55rem;
  display: flex;
  gap: 0.5rem;
}

.request-actions button {
  margin-top: 0;
}

.request-actions .secondary {
  background: var(--accent);
}

@media (max-width: 900px) {
  .hero-content {
    padding-top: 1.6rem;
  }
}

/* =========================================================
   Admin-Erweiterung: Tabs, Modals, Forms, Entity-Listen, Toasts
   Mobile-first — alles funktioniert auf 320px aufwärts.
   ========================================================= */

input,
textarea,
select {
  font-size: 16px; /* verhindert iOS-Auto-Zoom beim Fokus */
}

.account-settings {
  margin-top: 0.75rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.18);
  padding-top: 0.5rem;
}

.account-settings > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.admin-tabs {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.25rem;
  padding: 0.25rem;
  background: var(--paper);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

/* Mobile top-nav dropdown — replaces .admin-tabs at narrow viewports.
 * Fully custom (no native <select>) so the dropdown matches the app design
 * instead of opening the iOS/Android picker. Trigger is a pill button;
 * popup is a paper-coloured menu list below it. */
.admin-tabs-mobile {
  display: none; /* shown only on mobile, see media query below */
  grid-column: 1 / -1;
  position: relative;
  margin: 0 0 0.25rem;
}

.admin-tabs-mobile-trigger {
  width: 100%;
  margin: 0;
  padding: 0.7rem 2.4rem 0.7rem 1.1rem;
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  min-height: 48px;
  cursor: pointer;
  text-align: left;
  position: relative;
  display: flex;
  align-items: center;
}

.admin-tabs-mobile-trigger:hover {
  transform: none;
}

.admin-tabs-mobile.is-open .admin-tabs-mobile-trigger {
  border-color: var(--ink);
}

.admin-tabs-mobile-label {
  flex: 1 1 auto;
}

.admin-tabs-mobile-chevron {
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink);
  font-size: 1rem;
  opacity: 0.7;
  transition: transform 0.18s ease;
}

.admin-tabs-mobile.is-open .admin-tabs-mobile-chevron {
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}

.admin-tabs-mobile-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 70vh;
  overflow-y: auto;
  animation: tabs-mobile-popin 0.16s ease;
}

@keyframes tabs-mobile-popin {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-tabs-mobile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  color: var(--ink);
}

.admin-tabs-mobile-item:hover,
.admin-tabs-mobile-item:focus {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.admin-tabs-mobile-item.active {
  background: var(--ink);
  color: #fff;
}

.admin-tabs-mobile-check {
  font-size: 0.95rem;
  opacity: 0.9;
}

@media (max-width: 640px) {
  .admin-tabs {
    display: none;
  }
  .admin-tabs-mobile {
    display: block;
  }
}

.admin-tabs button {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  border: none;
}

.admin-tabs button.active {
  background: var(--ink);
  color: #fff;
}

.admin-tabs button:hover {
  transform: none;
}

.admin-venues-card,
.admin-drinks-card,
.admin-assets-card,
.admin-statistik-card,
.admin-website-card {
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  grid-column: 1 / -1;
  /* Defensiv gegen Inhalte, die breiter sind als der Viewport (lange
   * Function-Namen, breite Tabellen, Code-Blöcke). Innere Scrollbereiche
   * (z.B. .stats-table-scroll) behalten ihre eigene horizontale Scrollbar. */
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.admin-venues-card h2,
.admin-drinks-card h2,
.admin-assets-card h2,
.admin-statistik-card h2,
.admin-website-card h2 {
  margin-top: 0;
}

/* Nested second-level header inside Assets > Orte. The outer Assets header
   already carries the primary subtab nav; the inner row pairs a smaller
   heading with the secondary venues subtabs (Orte / Festivals / Custom). */
.assets-subtab {
  display: block;
}

.assets-secondary-header {
  margin-top: 0.4rem;
}

.assets-secondary-heading {
  font-size: 1.05rem;
  margin: 0.4rem 0 0.4rem;
  color: rgba(0, 0, 0, 0.7);
  font-weight: 600;
}

.firestore-warning {
  background: rgba(184, 31, 31, 0.1);
  border: 1px solid rgba(184, 31, 31, 0.4);
  color: #6a1414;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  margin: 0.5rem 0 0.8rem;
  font-size: 0.9rem;
}

.firestore-warning code {
  background: rgba(0, 0, 0, 0.08);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

/* Neutrale Info-Box für Firestore-Read-Aufschlüsselung — kein Rot, kein
 * Warnungs-Tonfall. Mobile-SDK-Reads sind bei einer Realtime-App normal. */
.firestore-attribution-info {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.75);
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  margin: 0.5rem 0 0.8rem;
  font-size: 0.85rem;
  line-height: 1.45;
}
.firestore-attribution-info strong {
  color: rgba(0, 0, 0, 0.9);
  font-variant-numeric: tabular-nums;
}

.entity-section {
  margin-top: 1.2rem;
}

.entity-section:first-of-type {
  margin-top: 0.5rem;
}

/* Lazy-load footer for the Venues grid. */
.venues-pagination {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  position: relative;
}
.venues-load-more {
  /* Cancel global `button { width: 100% }` so the button sits centered */
  width: auto;
  margin: 0;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
}
/* The sentinel is purely a scroll trigger — invisible, non-interactive. */
.venues-sentinel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  pointer-events: none;
}

.entity-section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.entity-section-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.entity-section-header .category-heading {
  text-transform: capitalize;
}

.entity-section-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.entity-section-actions button,
.entity-section-header button {
  width: auto;
  margin: 0;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.list-toolbar .filter-input,
.list-toolbar .form-select {
  flex: 1 1 140px;
  min-width: 140px;
  margin: 0;
  min-height: 44px;
}

.toolbar-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.toolbar-actions button {
  width: auto;
  margin: 0;
}

.entity-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .entity-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .entity-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.entity-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.entity-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.entity-card-head h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  word-break: break-word;
}

.entity-card .muted {
  color: rgba(0, 0, 0, 0.55);
  font-weight: 400;
  font-size: 0.92em;
}

.entity-meta {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(0, 0, 0, 0.78);
}

.entity-meta-small {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.55);
  word-break: break-all;
}

.entity-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.entity-actions button {
  width: auto;
  margin: 0;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
}

/* Icon-first action buttons. Desktop shows icon + label; mobile collapses to
   icon-only (square-ish, ≥44 px) so 4 buttons fit comfortably in one row. */
.entity-actions .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.entity-actions .action-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.entity-actions .action-label {
  font-size: 0.92rem;
}

.entity-actions .secondary {
  background: var(--accent);
}

.entity-actions .refresh-btn {
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  min-width: 44px;
  flex: 0 0 auto;
  padding: 0.5rem 0.6rem;
  font-size: 1.05rem;
}

.entity-actions .refresh-btn:hover {
  background: rgba(0, 0, 0, 0.16);
}

.admin-tabs .tab-account {
  margin-left: auto;
}

@media (max-width: 720px) {
  .admin-tabs .tab-account {
    margin-left: 0;
  }
}

.admin-account-card {
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  grid-column: 1 / -1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.admin-account-card h2 {
  margin-top: 0;
}

.admin-account-card h3 {
  margin-top: 1.2rem;
}

.card-header-with-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.5rem;
}

.card-header-with-tabs h2 {
  margin: 0;
}

.sub-tabs {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.sub-tabs button {
  width: auto;
  margin: 0;
  min-height: 36px;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
}

.sub-tabs button:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.05);
}

.sub-tabs button.active {
  background: var(--ink);
  color: #fff;
}

@media (max-width: 480px) {
  .sub-tabs {
    width: 100%;
    justify-content: stretch;
  }
  .sub-tabs button {
    flex: 1 1 auto;
  }
}

/* SubTabNav wrapper — takes available flex space so the ResizeObserver has
 * a meaningful clientWidth to compare against the probe's natural width. */
.sub-tabs-nav {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

/* Hidden probe: identical button sizing to .sub-tabs, laid out naturally so
 * scrollWidth reflects the true button row width. Never interactive. */
.sub-tabs-probe {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.2rem;
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: nowrap;
}

.sub-tabs-probe button {
  padding: 0.35rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 999px;
  border: none;
  background: transparent;
  white-space: nowrap;
  font-family: inherit;
}

/* Dropdown mode — compact pill trigger + floating menu, matching the
 * admin-tabs-mobile aesthetic but scaled for sub-tab size. */
.sub-tabs-dropdown {
  position: relative;
  display: inline-block;
}

.sub-tabs-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0.35rem 2rem 0.35rem 0.9rem;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 999px;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.sub-tabs-dropdown-trigger:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.1);
}

.sub-tabs-dropdown.is-open .sub-tabs-dropdown-trigger {
  background: var(--ink);
  color: #fff;
}

.sub-tabs-dropdown-label {
  flex: 1 1 auto;
}

.sub-tabs-dropdown-chevron {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.85rem;
  opacity: 0.7;
  transition: transform 0.18s ease;
}

.sub-tabs-dropdown.is-open .sub-tabs-dropdown-chevron {
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}

.sub-tabs-dropdown.is-open .sub-tabs-dropdown-trigger .sub-tabs-dropdown-chevron {
  opacity: 1;
}

.sub-tabs-dropdown-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.3rem);
  min-width: 100%;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 60vh;
  overflow-y: auto;
  white-space: nowrap;
  animation: tabs-mobile-popin 0.16s ease;
}

.sub-tabs-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: 38px;
  color: var(--ink);
  list-style: none;
}

.sub-tabs-dropdown-item:hover,
.sub-tabs-dropdown-item:focus {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.sub-tabs-dropdown-item.active {
  background: var(--ink);
  color: #fff;
}

.sub-tabs-dropdown-check {
  font-size: 0.9rem;
  opacity: 0.9;
}

.admin-config-card,
.admin-messages-card,
.admin-stats-card {
  background: var(--paper);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  grid-column: 1 / -1;
  /* Hard guard against any inner element (long uid in <code>, wide table,
     code block) pushing the whole card past the viewport. Inner content can
     scroll inside its own wrapper if needed (e.g. .stats-table-scroll). */
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.admin-config-card h2,
.admin-messages-card h2,
.admin-stats-card h2 {
  margin-top: 0;
}

/* ─────────── Statistik tab ─────────── */
/* The global `button { width: 100%; margin-top: 0.8rem; }` rule defined earlier
 * in this stylesheet is intentional for forms in other admin tabs but breaks
 * inline buttons here. All button rules below explicitly reset width + margin. */

.admin-stats-card button {
  width: auto;
  margin: 0;
}

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.stats-toolbar h2 {
  margin: 0;
  flex: 0 0 auto;
}
.stats-toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.65);
  flex: 1 1 240px;
  min-width: 0;
}
.stats-toolbar > button,
.stats-toolbar > .stats-export-picker > button {
  /* Cancel global `button { width: 100%; margin-top: 0.8rem; }` */
  width: auto;
  margin: 0;
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  min-height: 40px;
  white-space: nowrap;
}
.stats-meta-snapshot,
.stats-meta-scheduler {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.stats-meta-age {
  opacity: 0.7;
}
.stats-fail {
  color: #b00020;
  font-weight: 600;
}
@media (max-width: 540px) {
  .stats-toolbar {
    gap: 0.4rem;
  }
  .stats-toolbar h2 {
    flex: 1 1 auto;
    font-size: 1.2rem;
  }
  .stats-toolbar > button,
  .stats-toolbar > .stats-export-picker > button {
    /* Refresh button moves to its own row on narrow screens */
    flex: 1 1 100%;
    order: 99;
  }
  .stats-toolbar-meta {
    font-size: 0.78rem;
    flex: 1 1 100%;
    order: 1;
  }
  .stats-history-picker {
    flex: 1 1 100%;
    order: 2;
  }
}

/* History picker — custom dropdown matching the admin-tabs-mobile aesthetic.
 * Replaces the native <select> so we can group dates by month, add quick
 * shortcuts (Gestern / vor 7 Tagen / vor 30 Tagen), and keep keyboard nav. */
.stats-history-picker {
  position: relative;
  flex: 0 0 auto;
  min-width: 220px;
}

.stats-history-trigger {
  width: 100%;
  margin: 0;
  padding: 0.55rem 2.4rem 0.55rem 1rem;
  background: var(--paper, #fff);
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  color: var(--ink, #111);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 40px;
  cursor: pointer;
  text-align: left;
  position: relative;
  display: flex;
  align-items: center;
  transition: border-color 120ms;
}
.stats-history-trigger:hover {
  transform: none;
}
.stats-history-trigger:disabled {
  opacity: 0.6;
  cursor: progress;
}
.stats-history-picker.is-open .stats-history-trigger {
  border-color: var(--ink, #111);
}

.stats-history-trigger-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-history-chevron {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink, #111);
  font-size: 0.9rem;
  opacity: 0.7;
  transition: transform 180ms ease;
}
.stats-history-picker.is-open .stats-history-chevron {
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}

.stats-history-spinner {
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--ink, #111);
  border-radius: 50%;
  animation: stats-history-spin 0.8s linear infinite;
}
@keyframes stats-history-spin {
  to { transform: rotate(360deg); }
}

.stats-history-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  margin: 0;
  padding: 0.3rem;
  background: var(--paper, #fff);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.12));
  z-index: 40;
  max-height: 70vh;
  overflow-y: auto;
  min-width: 260px;
  animation: stats-history-popin 160ms ease;
}
@keyframes stats-history-popin {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.stats-history-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 0.3rem;
  margin-bottom: 0.2rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.stats-history-month-header {
  position: sticky;
  top: -0.3rem; /* offset menu padding so it sticks flush */
  background: var(--paper, #fff);
  padding: 0.5rem 0.9rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  z-index: 1;
}
.stats-history-month-header::after {
  content: "";
  display: block;
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin-top: 0.3rem;
}

.stats-history-item {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: none;
  background: transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink, #111);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 40px;
  transition: background 80ms;
}
.stats-history-item:hover,
.stats-history-item.focused {
  background: rgba(0, 0, 0, 0.05);
  transform: none;
}
.stats-history-item:focus {
  outline: none;
}
.stats-history-item.active {
  background: var(--ink, #111);
  color: var(--paper, #fff);
}
.stats-history-item.active.focused {
  background: var(--ink, #111);
  filter: brightness(1.1);
}

.stats-history-item-main {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-history-item-sub {
  font-weight: 500;
  opacity: 0.7;
  margin-left: 0.35rem;
  font-size: 0.85em;
}
.stats-history-item.active .stats-history-item-sub {
  opacity: 0.85;
}

.stats-history-check {
  font-size: 0.95rem;
  opacity: 0.9;
  flex: 0 0 auto;
}

.stats-history-empty {
  margin: 0.5rem 0.9rem;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.6);
}

/* Export picker — kleines Popover neben Live-Refresh. Range-Buttons triggern
 * Browser-Download einer JSON-Datei mit dem Snapshot-Slice für AI-Paste. */
.stats-export-picker {
  position: relative;
  display: inline-block;
}
.stats-export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  margin: 0;
  padding: 0.5rem;
  background: var(--paper, #fff);
  color: var(--ink, #111);
  border: 2px solid var(--ink, #111);
  border-radius: 18px;
  box-shadow: var(--shadow, 0 8px 24px rgba(0, 0, 0, 0.18));
  z-index: 40;
  min-width: 220px;
  animation: stats-history-popin 160ms ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats-export-menu-hint {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(0, 0, 0, 0.6);
  padding: 0.4rem 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 0.2rem;
}
.stats-export-item {
  width: 100%;
  margin: 0;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink, #111);
  text-align: left;
  cursor: pointer;
  transition: background 120ms;
}
.stats-export-item:hover,
.stats-export-item:focus {
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}
.stats-export-item:active {
  background: rgba(0, 0, 0, 0.1);
}

/* Trend arrows in the per-function table. */
.trend {
  margin-left: 0.25rem;
  font-weight: 700;
  font-size: 0.9em;
  cursor: help;
}
.trend-up { color: #c0392b; }
.trend-down { color: #27ae60; }
.trend-flat { color: #999; }

/* Range pill bar — mirrors the look of the top `.admin-tabs` row so the page
 * feels visually consistent. Horizontally scrollable on narrow viewports. */
.stats-range-tabs {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  margin: 0.5rem 0 1.5rem;
  background: var(--paper, #fff);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.stats-range-tabs::-webkit-scrollbar {
  display: none;
}
.stats-range-tabs button {
  /* Cancel global button rule */
  width: auto;
  margin: 0;
  /* Pill style matching .admin-tabs button */
  flex: 1 1 auto;
  scroll-snap-align: start;
  min-height: 40px;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--ink, #111);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.stats-range-tabs button:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: none;
}
.stats-range-tabs button.active {
  background: var(--ink, #111);
  color: var(--paper, #fff);
}
/* Sub-Tab-Nav (Kosten / Functions / Firestore / Infrastruktur) — gleiches
 * Pill-Pattern wie .stats-range-tabs aber etwas zurückhaltender, weil zweite
 * Hierarchie-Ebene. Sitzt zwischen Kompakt-Dashboard und Detail-Sektionen. */
.stats-sub-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  margin: 1rem 0 1rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.stats-sub-tabs::-webkit-scrollbar { display: none; }
.stats-sub-tabs button {
  width: auto;
  margin: 0;
  flex: 1 1 auto;
  scroll-snap-align: start;
  min-height: 36px;
  padding: 0.4rem 0.9rem;
  border-radius: 10px;
  background: transparent;
  color: var(--ink, #111);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.stats-sub-tabs button:hover { background: rgba(0, 0, 0, 0.06); transform: none; }
.stats-sub-tabs button.active {
  background: var(--paper, #fff);
  color: var(--ink, #111);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
@media (max-width: 540px) {
  .stats-sub-tabs button {
    flex: 0 0 auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
  }
}

/* Kompakt-Dashboard — immer sichtbar oberhalb der Sub-Tabs. 4 Karten:
 * Kosten/Monat, €/User, Top-Functions, Status. Auf Mobile 2x2 Grid,
 * auf Desktop 4 nebeneinander. */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0 0.5rem;
}
.stats-dashboard-card {
  background: var(--paper, #fff);
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.stats-dashboard-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(0, 0, 0, 0.55);
}
.stats-dashboard-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ink, #111);
}
.stats-dashboard-value.stats-dashboard-warn {
  color: #b81f1f;
}
/* Sanfter Info-Stil (gelb/amber) — kein "ist kaputt", sondern "schau hier mal". */
.stats-dashboard-value.stats-dashboard-hint {
  color: #a66d00;
}
.stats-dashboard-sub {
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.6);
}
.stats-dashboard-card-list .stats-dashboard-fnlist {
  list-style: none;
  margin: 0.1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.82rem;
}
.stats-dashboard-card-list .stats-dashboard-fnlist li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  min-width: 0;
}
.stats-dashboard-card-list .stats-dashboard-fnlist code {
  font-size: 0.78rem;
  background: transparent;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.stats-dashboard-fnshare {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(0, 0, 0, 0.55);
  flex: 0 0 auto;
}
.stats-dashboard-hints {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stats-dashboard-hints li::before {
  content: "· ";
  margin-right: 0.15rem;
  color: rgba(0, 0, 0, 0.4);
}

@media (max-width: 540px) {
  .stats-range-tabs button {
    flex: 0 0 auto; /* let buttons size to content + horizontal scroll */
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
  }
}

.stats-section {
  margin-top: 1.75rem;
}
.stats-section h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}
.stats-section .hint {
  margin: 0.25rem 0 0.75rem;
}
.stats-subhead {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  opacity: 0.85;
}
@media (max-width: 540px) {
  .admin-stats-card {
    padding: 0.75rem;
  }
  .stats-section {
    margin-top: 1.25rem;
  }
  .stats-section .hint {
    font-size: 0.85rem;
  }
}

/* KPI tiles for Kosten */
.stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
@media (max-width: 540px) {
  .stats-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .stats-kpi-card {
    padding: 0.65rem 0.7rem;
  }
}
.stats-kpi-card {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  /* As a grid item with `1fr`, ensures content can shrink and wrap below the
   * grid track's minimum content-size. Without this, long uppercase labels
   * (e.g. "ZEITRAUM (SCHÄTZUNG, LISTE)") would push the card past its column
   * width and break the layout on mobile. */
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.stats-kpi-card.stats-kpi-primary {
  background: linear-gradient(135deg, rgba(255, 200, 80, 0.25), rgba(255, 140, 60, 0.18));
  border: 1px solid rgba(255, 140, 60, 0.3);
}
.stats-kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.6);
}
.stats-kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
@media (max-width: 540px) {
  .stats-kpi-value {
    font-size: 1.25rem;
  }
  .stats-kpi-label {
    font-size: 0.7rem;
  }
}
.stats-kpi-sub {
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.6);
  line-height: 1.35;
}

/* Hard-facts grid */
.stats-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}
@media (max-width: 540px) {
  .stats-facts {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .stats-fact {
    padding: 0.55rem 0.65rem;
  }
  .stats-fact-value {
    font-size: 1rem;
  }
}
.stats-fact {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stats-fact-primary {
  background: linear-gradient(135deg, rgba(80, 180, 255, 0.18), rgba(80, 180, 255, 0.08));
  border: 1px solid rgba(80, 180, 255, 0.3);
}
.stats-fact-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.55);
}
.stats-fact-value {
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stats-fact-sub {
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.55);
}

/* Services table (desktop / tablet view) */
.stats-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.stats-table th,
.stats-table td {
  padding: 0.45rem 0.7rem;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stats-table th:first-child,
.stats-table td:first-child {
  text-align: left;
}
.stats-table thead {
  background: rgba(0, 0, 0, 0.04);
}
.stats-table tbody tr:nth-child(odd) {
  background: rgba(0, 0, 0, 0.015);
}
.stats-table tbody tr:hover {
  background: rgba(255, 200, 80, 0.12);
}
.stats-table code {
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  /* Function names + Firebase UIDs are long single tokens. Allow them to
     break anywhere so they don't overflow the card on narrow viewports. */
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* Mobile: convert `.stats-table-cardable` rows into stacked cards.
 * Each <td>'s data-label becomes a leading label. The first cell (function
 * name / uid) acts as the card title. Pure CSS — no JS reshuffling. */
@media (max-width: 640px) {
  /* All stats tables currently use the cardable variant, so we can safely
   * drop the wrapper's horizontal-scroll affordance + border on mobile. If
   * a non-cardable table is ever added, move these resets into a more
   * specific selector (e.g. .stats-table-scroll--cards). */
  .stats-table-scroll {
    overflow-x: visible;
    border: none;
    border-radius: 0;
    background: transparent;
  }
  .stats-table-cardable,
  .stats-table-cardable tbody,
  .stats-table-cardable tr {
    display: block;
    width: 100%;
  }
  .stats-table-cardable thead {
    /* The original header row is meaningless once cells are stacked. */
    display: none;
  }
  .stats-table-cardable tr {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.55rem;
  }
  .stats-table-cardable tr:nth-child(odd),
  .stats-table-cardable tr:hover {
    /* Disable striping + hover-tint when in card mode. */
    background: rgba(0, 0, 0, 0.03);
  }
  .stats-table-cardable td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.18rem 0;
    text-align: right;
    white-space: normal;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .stats-table-cardable td > code {
    /* When the label + code don't fit one line, let code drop to its own
       row instead of pushing the row width past the card. */
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
  }
  .stats-table-cardable td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(0, 0, 0, 0.55);
    font-weight: 500;
    flex: 0 0 auto;
  }
  /* First cell becomes the "card title": full-width, no label, separator below. */
  .stats-table-cardable td:first-child {
    display: block;
    text-align: left;
    padding: 0 0 0.4rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.12);
    font-weight: 600;
  }
  .stats-table-cardable td:first-child::before {
    display: none;
  }
  .stats-table-cardable td:first-child code {
    /* Make long function-name code chips wrap cleanly instead of overflowing. */
    word-break: break-all;
    background: transparent;
    padding: 0;
  }
  /* Cost-Mix becomes a stack on mobile too — but with a small left-aligned
   * label group instead of right-justified text, so the rows read naturally
   * under the "Cost-Mix" label. */
  .stats-table-services .stats-mix-cell {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
  }
}

/* ----------------------------------------------------------------------- *
 * Stats table extras: column-header info icon, Keep-Warm badge, Cost-Mix. *
 * ----------------------------------------------------------------------- */
.stats-th-with-info {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.stats-th-info {
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.4);
  cursor: help;
  user-select: none;
  /* Slightly enlarges the hit target without nudging text baseline. */
  line-height: 1;
}
.stats-th-info:hover {
  color: rgba(0, 0, 0, 0.7);
}

.stats-badge {
  display: inline-block;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.45rem;
  vertical-align: 0.08em;
  cursor: help;
  white-space: nowrap;
}
.stats-badge-warm {
  background: rgba(238, 150, 75, 0.18); /* matches the avatar-palette warm-orange used elsewhere */
  color: #b45f17;
  border: 1px solid rgba(238, 150, 75, 0.35);
}

.stats-mix-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-size: 0.78rem;
  line-height: 1.25;
  white-space: nowrap;
}
.stats-mix-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: help;
}
.stats-mix-label {
  color: rgba(0, 0, 0, 0.55);
  min-width: 3.2rem;
  text-align: left;
}
.stats-mix-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 2.6rem;
  text-align: right;
}
.stats-mix-empty {
  color: rgba(0, 0, 0, 0.4);
}
.stats-mix-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex: 0 0 auto;
}
.stats-mix-active { background: #27ae60; }
.stats-mix-idle   { background: #f4c44a; }
.stats-mix-cold   { background: #c0392b; }

.stats-mix-legend {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: baseline;
}
.stats-mix-legend .stats-mix-dot {
  margin-right: 0.15rem;
  position: relative;
  top: 0.05rem;
}

.entity-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}

.entity-card-title h4 {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.entity-card-icon {
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  object-fit: contain;
}

.entity-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: -0.15rem;
}

.icon-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.icon-picker .form-select {
  flex: 1 1 auto;
  min-width: 0;
}

.icon-picker .refresh-btn {
  width: auto;
  flex: 0 0 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  font-size: 1.05rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
}

.icon-picker .refresh-btn:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.16);
}

.icon-preview {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-preview-empty {
  color: rgba(0, 0, 0, 0.35);
  font-weight: 700;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, 0.04);
}

.latlng-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
}

.latlng-row .form-input {
  flex: 1 1 0;
  min-width: 0;
}

.latlng-row .latlng-resolve {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  white-space: nowrap;
  padding: 0.6rem 0.85rem;
}

@media (max-width: 540px) {
  .latlng-row {
    flex-wrap: wrap;
  }
  .latlng-row .form-input {
    flex: 1 1 40%;
  }
  .latlng-row .latlng-resolve {
    flex: 1 1 100%;
  }
}

.address-summary {
  margin: 0;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  font-size: 0.92rem;
  word-break: break-word;
}

.toggle-manual-btn {
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  text-align: left;
}

.toggle-manual-btn:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.12);
}

.address-autocomplete {
  position: relative;
  width: 100%;
}

.address-autocomplete .form-input {
  width: 100%;
}

.autocomplete-loading {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.autocomplete-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.2rem);
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
}

.autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  font-size: 0.93rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(242, 210, 75, 0.35);
}

.autocomplete-item.variant-no-house,
.autocomplete-item.variant-city-only {
  background: rgba(0, 0, 0, 0.04);
}

.autocomplete-item.variant-no-house.active,
.autocomplete-item.variant-city-only.active,
.autocomplete-item.variant-no-house:hover,
.autocomplete-item.variant-city-only:hover {
  background: rgba(242, 210, 75, 0.45);
}

.autocomplete-label {
  flex: 1 1 auto;
  word-break: break-word;
}

.autocomplete-chip {
  flex: 0 0 auto;
  background: var(--ink);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.autocomplete-error {
  padding: 0.6rem 0.8rem;
  color: #b81f1f;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.8rem;
}

.form-actions button {
  width: auto;
  margin: 0;
}

@media (max-width: 720px) {
  .form-actions button {
    width: 100%;
  }
}

button.danger {
  background: #b81f1f;
}

.pill {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  margin-right: 0.3rem;
  white-space: nowrap;
}

.pill-category {
  background: rgba(242, 210, 75, 0.5);
}

.pill-active {
  background: rgba(26, 143, 107, 0.2);
}

.pill-inactive {
  background: rgba(0, 0, 0, 0.12);
}

.pill-base {
  background: rgba(26, 143, 107, 0.35);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 100;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--paper);
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  border-radius: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    padding: 1rem;
  }
  .modal-card {
    max-width: 720px;
    max-height: calc(100dvh - 2rem);
    height: auto;
    border-radius: 18px;
  }
  .modal-sm {
    max-width: 420px;
  }
  .modal-lg {
    max-width: 820px;
  }
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--paper);
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  z-index: 1;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close {
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  transform: none;
  background: rgba(0, 0, 0, 0.13);
}

.modal-body {
  padding: 0.85rem 1rem;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.modal-footer button {
  width: auto;
  margin: 0;
  min-height: 44px;
  flex: 0 1 auto;
}

@media (max-width: 480px) {
  .modal-footer {
    flex-direction: row-reverse;
  }
  .modal-footer button {
    flex: 1 1 auto;
  }
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

@media (min-width: 720px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid .span-2 {
    grid-column: 1 / -1;
  }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0;
}

.required-mark {
  color: #b81f1f;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fff;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  font-family: inherit;
  font-size: 16px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23141414' d='M0 0l6 8 6-8z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2rem;
}

.form-input[readonly] {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.7);
}

.form-textarea {
  min-height: 70px;
  resize: vertical;
}

.field-error {
  margin: 0;
  font-size: 0.8rem;
  color: #b81f1f;
  font-weight: 600;
}

.field-hint {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.55);
}

.has-error .form-input,
.has-error .form-select,
.has-error .form-textarea {
  border-color: #b81f1f;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  min-height: 44px;
  cursor: pointer;
}

.checkbox-line input[type="checkbox"] {
  width: auto;
  margin: 0;
  transform: scale(1.2);
}

.month-day-picker {
  display: flex;
  gap: 0.4rem;
}

.month-day-picker .form-select {
  flex: 1 1 auto;
}

.lang-tabs {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.lang-tabs button {
  width: auto;
  margin: 0;
  min-height: 40px;
  padding: 0.4rem 1rem;
  border-radius: 8px 8px 0 0;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.lang-tabs button.active {
  background: var(--ink);
  color: #fff;
}

.confirm-message {
  margin: 0;
  font-size: 0.98rem;
}

/* ---------- Toast ---------- */

.toast-stack {
  position: fixed;
  top: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 200;
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-stack {
    left: auto;
    right: 1rem;
    top: 1rem;
    max-width: 360px;
  }
}

.toast {
  pointer-events: auto;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.92rem;
  animation: toast-in 0.2s ease;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-success {
  background: var(--accent);
}

.toast-error {
  background: #b81f1f;
}

.toast-text {
  flex: 1 1 auto;
}

.toast-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
}

.toast-close:hover {
  transform: none;
}

/* ---------- Mobile-spezifische Anpassungen ---------- */

@media (max-width: 720px) {
  .panel {
    padding: 0.7rem;
    gap: 0.7rem;
  }
  .admin-login-card,
  .admin-requests-card,
  .admin-venues-card,
  .admin-drinks-card,
  .admin-config-card,
  .admin-messages-card,
  .admin-stats-card,
  .admin-account-card,
  .admin-assets-card,
  .admin-statistik-card,
  .admin-website-card {
    padding: 0.8rem;
    border-radius: 14px;
  }

  /* Löschanträge: longer labels, keep stacked column on mobile */
  .request-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .request-actions button {
    width: 100%;
  }
  /* Entity actions: stay horizontal, become icon-only square buttons so 3–4
     actions fit in one row even at 320px without wasting vertical space. */
  .entity-actions {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .entity-actions .action-btn {
    flex: 1 1 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 0.6rem;
  }
  .entity-actions .action-btn .action-label {
    /* Visually hidden but kept for screen readers (aria-label also set). */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    border: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .entity-actions .action-icon {
    font-size: 1.2rem;
  }
  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }
  .toolbar-actions button {
    flex: 1 1 auto;
  }
}

body {
  overflow-x: hidden;
}

/* ============================================================================
 * Usage-Stats Tab (admin "Statistiken") — App-Usage-Dashboard.
 * Reuses .stats-section, .stats-kpi-card, .stats-table, .stats-range-tabs,
 * .trend-{up,down,flat}; here only the layout details that differ from the
 * Cost-Tab cards.
 * ============================================================================ */

.usage-kpi-grid {
  /* Same row-grid as .stats-kpis, but the cards stretch taller and we want a
     consistent 3-column layout on desktop. .stats-kpis already does auto-fit;
     this keeps the multi-row content from collapsing. */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.usage-kpi-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.95rem 1.05rem;
}

.usage-kpi-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.62);
  letter-spacing: 0.02em;
}

.usage-kpi-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.usage-kpi-primary {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-variant-numeric: tabular-nums;
}

.usage-kpi-primary .stats-kpi-value {
  font-size: 1.7rem;
  line-height: 1.05;
}

.usage-kpi-primary-suffix {
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.55);
  text-transform: lowercase;
}

.usage-kpi-rows {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.45rem;
}

.usage-kpi-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.usage-kpi-row-label {
  color: rgba(0, 0, 0, 0.55);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-kpi-row-value {
  font-weight: 600;
  text-align: right;
}

.usage-kpi-row-spacer {
  display: inline-block;
  min-width: 0.9rem;
}

.usage-kpi-row-lifetime {
  margin-top: 0.18rem;
  padding-top: 0.32rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}
.usage-kpi-row-lifetime .usage-kpi-row-label {
  color: rgba(0, 0, 0, 0.7);
  font-weight: 600;
}

/* ---- Top-N cards row ---- */

.usage-tops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.6rem;
}

.usage-top-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
}

.usage-top-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.usage-top-range {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.usage-top-table th.usage-top-rank,
.usage-top-table td.usage-top-rank {
  width: 2rem;
  text-align: center;
  color: rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}

.usage-top-country-name {
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.6);
  margin-left: 0.35rem;
}

.usage-top-default-badge {
  margin-left: 0.35rem;
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.55);
  font-style: italic;
}

.stats-table-total td {
  border-top: 2px solid rgba(0, 0, 0, 0.18);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.03);
}

.usage-top-category-label {
  text-transform: capitalize;
}

.usage-top-empty {
  text-align: center;
  color: rgba(0, 0, 0, 0.45);
  font-style: italic;
  padding: 0.65rem 0;
}

.usage-drift-detail {
  display: block;
  font-size: 0.78rem;
  margin-top: 0.25rem;
  color: rgba(0, 0, 0, 0.65);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* ============================================================================
 * Auth: 2FA-Setup-Flow + Trusted Devices + Audit-Log
 * ============================================================================ */

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem 0;
  font-weight: 400;
  font-size: 0.9rem;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Sekundäre Aktionen im Login-Flow (Abbrechen, Backup-Code-Toggle). Nicht
 * primärer Button, eher ein „mehr Optionen"-Block. */
.login-secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: center;
  margin-top: 0.7rem;
  font-size: 0.85rem;
}
.link-button {
  /* Override global `button { width: 100% }`. */
  width: auto;
  margin: 0;
  padding: 0.25rem 0.6rem;
  background: transparent;
  color: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover {
  color: rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}

.totp-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin: 1rem 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.025);
  border-radius: 10px;
}
.totp-qr {
  max-width: 256px;
  width: 100%;
  height: auto;
  background: white;
  padding: 8px;
  border-radius: 8px;
}
.totp-secret {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.totp-secret code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
}

.backup-codes-box {
  background: rgba(255, 200, 80, 0.15);
  border: 1px solid rgba(255, 200, 80, 0.4);
  border-radius: 10px;
  padding: 1rem;
  margin: 0.8rem 0;
}
.backup-codes-list {
  list-style: none;
  padding: 0;
  margin: 0.7rem 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem 0.8rem;
}
.backup-codes-list li code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  display: block;
  letter-spacing: 0.08em;
  text-align: center;
}

/* Account-Seite: stacked sections (Login-Daten / 2FA / Geräte / Audit), each in
 * its own entity-section card. Top status header spans full width. */
.admin-account-card {
  display: block;
}

/* Full-width status bar at the top of the Konto tab. Replaces the previous
 * stack of "Eingeloggt"-pill + "Logout"-button at the top so the action and
 * info sit side-by-side, full panel width on desktop. */
.account-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: rgba(26, 143, 107, 0.08);
  border: 1px solid rgba(26, 143, 107, 0.18);
  margin: 0 0 1rem;
  flex-wrap: wrap;
}

.account-status-text {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.78);
}

.account-status-text .status {
  margin: 0;
}

.account-status-user strong {
  color: var(--ink);
}

.account-status-2fa {
  color: rgba(0, 0, 0, 0.6);
  font-size: 0.88rem;
}

.account-status-2fa-warn {
  color: #8a4b00;
}

.account-logout-btn {
  width: auto;
  margin: 0;
  min-height: 38px;
  padding: 0.45rem 1.1rem;
}

.account-feedback {
  margin: 0 0 1rem;
}

/* Each Konto sub-section uses the shared `.entity-section` look. The forms
 * inside should still stay readable on wide screens, so cap their width but
 * keep them anchored left. */
.admin-account-card .account-form,
.admin-account-card .account-2fa-box,
.admin-account-card .trusted-devices-list,
.admin-account-card .audit-log-list {
  max-width: 640px;
}

.admin-account-card .entity-section .entity-section-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

/* Audit-log + trusted-device sections can use the full card width on desktop
 * since their list rows benefit from horizontal space. */
.admin-account-card .entity-section .trusted-devices-list,
.admin-account-card .entity-section .audit-log-list {
  max-width: 100%;
}

/* Pagination footer used by the Audit-Log. Centered controls with prev/next
 * buttons on either side and the page status in between. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 1rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.pager-btn {
  width: auto;
  margin: 0;
  min-height: 36px;
  padding: 0.35rem 0.9rem;
}

.pager-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pager-status {
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.65);
}

@media (max-width: 540px) {
  .account-status-header {
    align-items: stretch;
  }
  .account-logout-btn {
    width: 100%;
  }
}

.account-2fa-box {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 0.6rem 0 1rem;
}
/* Logout-Button volle Breite ist okay, aber Inline-Buttons im Account-Card
 * sollen NICHT die ganze Card sprengen. */
.admin-account-card .account-2fa-box button,
.admin-account-card .trusted-device-row button,
.admin-account-card .revoke-all-btn {
  width: auto;
  align-self: flex-start;
  min-height: 38px;
  padding: 0.45rem 1rem;
  margin: 0.4rem 0 0;
}
.admin-account-card .account-2fa-box button {
  margin-top: 0.6rem;
}
.admin-account-card .revoke-all-btn {
  margin-top: 0.5rem;
}

.trusted-devices-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.6rem 0 1rem;
}
.trusted-device-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.015);
}
.trusted-device-info {
  flex: 1 1 auto;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.trusted-device-info > div {
  /* Title row + hint rows wrappen normal, brechen aber bei langen UA-Strings. */
  white-space: normal;
  overflow-wrap: anywhere;
}
.trusted-device-info .mono {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.7rem;
  word-break: break-all;
}
.td-current {
  color: #27ae60;
  font-weight: 600;
  font-size: 0.78rem;
}

.audit-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.015);
  font-size: 0.78rem;
}
.audit-row {
  display: grid;
  grid-template-columns: 130px 200px 100px 1fr;
  gap: 0.5rem;
  padding: 0.25rem 0.45rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.audit-row.fail {
  background: rgba(192, 57, 43, 0.07);
}
.audit-row.ok .audit-action {
  color: rgba(0, 0, 0, 0.78);
}
.audit-row.fail .audit-action {
  color: #c0392b;
  font-weight: 600;
}
.audit-time {
  color: rgba(0, 0, 0, 0.55);
}
.audit-user {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: rgba(0, 0, 0, 0.6);
}
.audit-meta {
  color: rgba(0, 0, 0, 0.45);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .audit-row {
    grid-template-columns: 1fr;
    gap: 0.05rem;
  }
}

/* Usage-Tab Trend-Semantik invertiert die Cost-Tab-Farben: bei Kosten ist
 * "mehr" schlecht (rot ↑), bei App-Aktivität ist "mehr" gut (grün ↑).
 * Wir überschreiben die globalen .trend-up/.trend-down Farben nur innerhalb
 * des Usage-Stats-Containers. */
.admin-stats-card .usage-kpi-card .trend-up,
.admin-stats-card .usage-kpi-row .trend-up {
  color: #27ae60;
}
.admin-stats-card .usage-kpi-card .trend-down,
.admin-stats-card .usage-kpi-row .trend-down {
  color: #c0392b;
}

@media (max-width: 640px) {
  .usage-kpi-card {
    padding: 0.85rem 0.95rem;
  }
  .usage-tops-grid {
    grid-template-columns: 1fr;
  }
  /* Card-mode of stats-table-cardable already collapses rows on mobile; the
     "rank" cell becomes redundant there (numbering is implicit in stacked
     cards), so hide it to keep the cards clean. */
  .usage-top-table td.usage-top-rank::before {
    content: "Platz";
  }
}

/* ---------- Config page extensions ---------- */

/* Toolbar above the config sections. Compact reload button on desktop (auto
   width so it doesn't stretch into a giant bar like the global button rule
   would have it). Mobile keeps the full-width treatment for thumb reach via
   the @media override below. */
.config-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0 0 0.8rem 0;
}

.config-toolbar > button {
  width: auto;
  margin: 0;
  min-height: 38px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
}

.entity-section-subtitle {
  display: inline-block;
  font-weight: 400;
  font-size: 0.8rem;
  color: rgba(0, 0, 0, 0.55);
  margin-left: 0.5rem;
}

.entity-section-subtitle code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.entity-section-intro {
  margin: 0 0 0.8rem 0;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.65);
}

.entity-section-intro em {
  font-style: italic;
}

.config-subgroup-title {
  margin: 1.1rem 0 0.5rem 0;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.config-subgroup-title:first-of-type {
  margin-top: 0.2rem;
}

.legacy-toggle {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.65);
}

/* Label row carrying optional badges + help-tip next to the label text. */
.form-label-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.1rem;
}

.form-label-row .form-label {
  flex: 0 0 auto;
}

.form-label-range {
  font-weight: 400;
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.55);
  margin-left: 0.25rem;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  line-height: 1.4;
}

.badge-legacy {
  background: #fff4d6;
  color: #8a5a00;
  border: 1px solid #f0d27c;
}

/* Tier badges next to radius/threshold field labels. Subtle progression from
   muted-grey (Tier 0, default) up to a warmer accent for Tier 3, so the eye
   picks up "this lever sits high up the tier chain". */
.badge-tier {
  font-size: 0.65rem;
  padding: 0.08rem 0.4rem;
  letter-spacing: 0.05em;
}

.badge-tier-0 {
  background: #eef0f3;
  color: #4a5568;
  border: 1px solid #d2d6dc;
}

.badge-tier-1 {
  background: #e6f4ff;
  color: #1e4e8c;
  border: 1px solid #b5d8f5;
}

.badge-tier-2 {
  background: #e6f8ee;
  color: #1b6b3a;
  border: 1px solid #b5e2c8;
}

.badge-tier-3 {
  background: #fdebd7;
  color: #8a4b00;
  border: 1px solid #f3c993;
}

.badge-tier-all {
  background: #f0e8ff;
  color: #4b2a8a;
  border: 1px solid #d4c4f0;
}

.badge-tier-gate {
  background: #f5f5f5;
  color: #555;
  border: 1px dashed #c0c0c0;
}

/* Dirty-state: blue accent border on inputs whose draft value differs from
   the saved one. Error styling overrides via specificity (red wins). */
.form-field.is-dirty .form-input,
.form-field.is-dirty .form-select,
.form-field.is-dirty .form-textarea {
  border-color: #2b6cb0;
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.12);
}

.form-field.is-dirty .form-label::after {
  content: " •";
  color: #2b6cb0;
  font-weight: 700;
}

/* ---------- Help-Tip ---------- */

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  /* Push help-tip to the right end of the label row */
  margin-left: auto;
}

.help-tip-trigger {
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
  background: #fff;
  color: rgba(0, 0, 0, 0.65);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  /* Mobile tap target: 22 visual, expand hit area via padding-fallback below */
}

.help-tip-trigger:hover,
.help-tip-trigger:focus-visible,
.help-tip-trigger.is-open {
  background: #141414;
  color: #fff;
  border-color: #141414;
  outline: none;
}

/* Desktop tooltip-style popover */
.help-tip-popover {
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, 86vw);
  background: #141414;
  color: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  line-height: 1.45;
}

.help-tip-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 8px;
  width: 12px;
  height: 12px;
  background: #141414;
  transform: rotate(45deg);
  border-radius: 2px;
}

.help-tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.help-tip-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.95);
  word-break: break-all;
}

.help-tip-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  min-height: 0;
}

.help-tip-close:hover,
.help-tip-close:focus-visible {
  color: #fff;
  outline: none;
}

.help-tip-content {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.help-tip-content p {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.92);
}

.help-tip-content code {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  font-size: 0.78rem;
  color: #ffd7a8;
  word-break: break-word;
}

.help-tip-content strong {
  color: #ffd7a8;
  font-weight: 700;
}

/* Mobile bottom-sheet variant */
.help-tip-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  animation: help-tip-fade-in 0.15s ease;
}

.help-tip-sheet {
  position: relative;
  width: 100%;
  background: #141414;
  color: #fff;
  border-radius: 18px 18px 0 0;
  padding: 1rem 1.1rem 1.4rem;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  animation: help-tip-slide-up 0.2s ease;
}

.help-tip-sheet::before {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  margin: 0 auto 0.7rem;
}

.help-tip-sheet .help-tip-title {
  font-size: 0.95rem;
}

.help-tip-sheet .help-tip-content p {
  font-size: 0.92rem;
}

.help-tip-sheet .help-tip-close {
  font-size: 1.6rem;
}

@keyframes help-tip-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes help-tip-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* On narrow screens shrink the popover into the column edge and let the
   bottom-sheet take over via the JS viewport check. */
@media (max-width: 640px) {
  .config-toolbar {
    justify-content: stretch;
  }
  .config-toolbar button {
    flex: 1 1 auto;
  }
  .config-subgroup-title {
    font-size: 0.88rem;
  }
  .form-label-range {
    /* Always wrap range under the label on mobile so the title stays readable */
    display: block;
    margin-left: 0;
    margin-top: 0.05rem;
  }
}

/* Force-grid for the config panel on wider screens — pack two columns even
   when the parent's form-grid would otherwise stretch wider. */
@media (min-width: 1024px) {
  .admin-config-card .form-grid {
    gap: 1rem 1.4rem;
  }
}

/* ---------- SimpleTextEditor (Website-Tab) ---------- */

.simple-editor {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 0.4rem;
}

.simple-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.simple-editor-action {
  width: auto;
  margin: 0;
  min-height: 32px;
  padding: 0.25rem 0.7rem;
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}

.simple-editor-action:hover {
  background: rgba(0, 0, 0, 0.12);
  transform: none;
}

.simple-editor-textarea {
  width: 100%;
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  background: #fff;
  padding: 0.7rem 0.85rem;
  /* Monospace so line breaks + indentation are predictable. Sizing in the
     editor mirrors readable prose elsewhere (~16px), not code-sized 14px. */
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
  min-height: 180px;
}

.simple-editor-textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(20, 20, 20, 0.08);
}

/* ---------- Website-Tab admin layout ---------- */

.faq-create-row {
  display: flex;
  justify-content: flex-start;
}

.faq-create-row button {
  width: auto;
  margin: 0;
  min-height: 38px;
  padding: 0.45rem 1.1rem;
}

.faq-card-edit {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: rgba(0, 0, 0, 0.015);
}

.faq-card-edit.is-new {
  /* New, unsaved FAQ card gets a hint of green so it stands out from saved ones. */
  border-color: rgba(26, 143, 107, 0.35);
  background: rgba(26, 143, 107, 0.04);
}

.faq-card-edit.is-dirty {
  /* Match the dirty-blue used by form-field for consistency across the admin. */
  border-color: rgba(43, 108, 176, 0.45);
  box-shadow: 0 0 0 1px rgba(43, 108, 176, 0.12);
}

.faq-card-header {
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.faq-card-title-wrap {
  flex: 1 1 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.faq-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.faq-card-actions button {
  width: auto;
  margin: 0;
  min-height: 36px;
  padding: 0.35rem 0.7rem;
}

.faq-move-btn {
  min-width: 38px;
  padding: 0.35rem 0.55rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.faq-move-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.char-counter {
  margin: 0.25rem 0 0.6rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .faq-card-actions {
    width: 100%;
    justify-content: stretch;
  }
  .faq-card-actions button {
    flex: 1 1 auto;
  }
  .faq-move-btn {
    flex: 0 0 auto;
  }
}
