:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #1b2333;
  --muted: #5f6b80;
  --border: #dde3ee;
  --brand: #1f4fd8;
  --brand-dark: #173aa3;
  --topbar: #101a33;
  --topbar-text: #ffffff;
  --danger-bg: #fdeceb;
  --danger-text: #a3271f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 26, 51, .06), 0 6px 20px rgba(16, 26, 51, .06);
  --header-h: 68px; /* tatsaechliche Hoehe der stehenbleibenden Kopfleiste, fuer andere feststehende Bereiche darunter */
}

@media (max-width: 820px) {
  :root { --header-h: 108px; }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

/* Seite bleibt scrollbar, aber ohne sichtbaren Scrollbalken (Rollen/Wischen funktioniert weiter) */
html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar { display: none; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body::-webkit-scrollbar { display: none; }

/* Scrollbare Bereiche innerhalb der Seite (z. B. der Warenkorb) ebenfalls ohne sichtbaren Scrollbalken */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar { display: none; }

a { color: var(--brand); }

h1 { margin: 0 0 .25rem; font-size: 1.75rem; line-height: 1.2; }
h2 { margin: 0 0 .5rem; font-size: 1.15rem; }

.muted { color: var(--muted); margin-top: 0; }

/* Kopfleiste: bleibt beim Scrollen oben stehen (scrollt nicht mit) */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--topbar); color: var(--topbar-text); box-shadow: 0 2px 10px rgba(16, 26, 51, .18); }
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { color: var(--topbar-text); text-decoration: none; font-weight: 700; font-size: 1.25rem; letter-spacing: .02em; }
.tenant-name {
  flex: 1 1 auto;
  min-width: 0;
  color: #c9d3ea;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 1rem;
  border-left: 1px solid rgba(255, 255, 255, .2);
}
.userbox { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.username { color: #e6ebf7; }
form.inline { display: inline; margin: 0; }

/* Seite */
.page { flex: 1 0 auto; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.crumbs span { margin: 0 .25rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.login-card { max-width: 420px; margin: 2rem auto; }

/* Formulare */
.form label { display: block; margin: 1rem 0 .25rem; font-weight: 600; }
.form input[type="email"], .form input[type="password"], .form input[type="text"] {
  width: 100%;
  padding: .7rem .8rem;
  font: inherit;
  border: 1px solid #c3ccdd;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.form .btn { margin-top: 1.25rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: .65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--topbar-text); border-color: rgba(255, 255, 255, .35); padding: .4rem .8rem; }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.btn-lg { padding: .9rem 1.5rem; font-size: 1.1rem; }
.btn-block { display: block; width: 100%; }
.btn-disabled { background: #e5e9f2; color: #8a94a8; cursor: not-allowed; }
.btn-choice { width: 100%; text-align: left; background: #fff; color: var(--text); border-color: var(--border); }
.btn-choice:hover { border-color: var(--brand); }

.choice-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin: 1rem 0 0; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }

/* Startseite */
.hero { margin-bottom: 1.5rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border-top: 6px solid var(--brand);
}
.tile h2 { font-size: 1.6rem; letter-spacing: .04em; margin: 0; }
.tile p { color: var(--muted); margin: 0 0 1rem; }
.tile-admin { border-top-color: #0f766e; }
.tile-calendar { border-top-color: #7c3aed; }
.tile.is-disabled { opacity: .7; }
.tile .btn { align-self: flex-start; }

/* Kasse */
.empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); border: 2px dashed var(--border); border-radius: 10px; padding: 1.5rem; text-align: center; }

/* Verwaltung */
.admin-group { margin-top: 1.5rem; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
.admin-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.admin-item-name { font-weight: 600; }
.badge { align-self: flex-start; font-size: .75rem; color: var(--muted); background: #eef1f7; border-radius: 999px; padding: .1rem .6rem; }

@media (max-width: 820px) {
  .tenant-name { order: 3; flex-basis: 100%; padding-left: 0; border-left: 0; }
  .userbox { margin-left: auto; }
}

/* ===== Hauptnavigation (Kopfleiste) ===== */
.topnav { display: flex; gap: .25rem; margin-left: auto; }
.topnav-link { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .95rem; border-radius: 8px; color: #d6ddf0; text-decoration: none; font-weight: 600; }
.topnav-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topnav-link.is-active { background: rgba(255, 255, 255, .2); color: #fff; }
.userbox { margin-left: 0; }
.brand + .userbox { margin-left: auto; }
.who { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.userrole { font-size: .72rem; color: #9fb0d8; }
.here { display: none; background: rgba(255, 255, 255, .16); border-radius: 999px; padding: .1rem .75rem; font-size: .85rem; color: #fff; }

.mobile-menu { display: none; margin-left: auto; position: relative; }
.mobile-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; min-height: 44px; padding: .4rem 1rem; border: 1px solid rgba(255, 255, 255, .4); border-radius: 8px; color: #fff; font-weight: 600; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu[open] summary { background: rgba(255, 255, 255, .15); }
.mobile-menu-panel { position: absolute; right: 0; top: calc(100% + .5rem); width: min(86vw, 320px); background: #fff; color: var(--text); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 26, 51, .28); padding: .5rem; z-index: 30; display: grid; gap: .2rem; }
.mobile-link { display: block; width: 100%; padding: .9rem 1rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-decoration: none; text-align: left; font: inherit; font-weight: 600; cursor: pointer; min-height: 48px; }
.mobile-link:hover { background: #eef2fb; }
.mobile-link.is-active { background: var(--brand); color: #fff; }
.mobile-logout { color: var(--danger-text); }
.mobile-who { display: flex; flex-direction: column; padding: .5rem 1rem .75rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.mobile-who span { color: var(--muted); font-size: .85rem; }

@media (max-width: 820px) {
  .topnav, .userbox { display: none; }
  .mobile-menu { display: block; }
  .here { display: inline-block; }
}

/* Startseite: Mein Konto und Abmelden */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.quick-link { display: flex; flex-direction: column; gap: .15rem; min-height: 72px; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); margin: 0; }
.quick-link:hover { border-color: var(--brand); }
.quick-title { font-weight: 700; }
.quick-text { color: var(--muted); font-size: .9rem; }
.quick-logout { padding: 0; }
.quick-button { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; width: 100%; height: 100%; min-height: 72px; padding: 1rem 1.25rem; background: transparent; border: 0; border-radius: var(--radius); font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.quick-button .quick-title { color: var(--danger-text); }

/* Verwaltung: Weg zurueck */
.nav-back { color: var(--brand); font-weight: 600; margin-bottom: .25rem; border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; }
.narrow { max-width: 760px; margin: 0 auto; }
