/* Hort-App – gemeinsames Stylesheet. Tablet zuerst, grosse Tippflaechen (min. 48 px). */
:root {
  --teal: #2A9D8F;
  --teal-dark: #218075;
  --teal-soft: #E4F1EF;
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --line: #E3DED3;
  --text: #2B2B2B;
  --muted: #6B6660;
  --warn: #E76F51;
  --warn-soft: #FBE7E0;
  --ok: #4C956C;
  --sun: #E9C46A;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
  --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.hidden { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--teal); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.topbar .brand { display: flex; flex-direction: column; min-width: 0; }
.topbar .brand b { font-size: 1.05rem; line-height: 1.2; }
.topbar .brand span { font-size: .8rem; opacity: .85; }
.topbar nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a, .topbar .linkbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 16px; border-radius: 12px;
  background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
  border: 0; cursor: pointer; font-weight: 600;
}
.topbar nav a[aria-current="page"] { background: #fff; color: var(--teal-dark); }
.topbar nav a:hover, .topbar .linkbtn:hover { background: rgba(255,255,255,.26); }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
main > h1 { margin-bottom: 14px; }
.section { margin-bottom: 28px; }
.section > h2 { margin-bottom: 8px; }
.section + .section { margin-top: 28px; }
.section > .label { margin: 0 0 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { background: #FAF8F3; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.danger { background: var(--warn-soft); border-color: #F0C3B4; color: #8D3A22; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- Zaehler ---------- */
.counters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.counter { padding: 14px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.counter b { display: block; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter span { font-size: .85rem; color: var(--muted); }
.counter.present b { color: var(--teal); }
.counter.gone b { color: var(--muted); }
.counter.absent b { color: var(--warn); }

/* ---------- Filter ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.chip {
  min-height: var(--tap); padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.search {
  min-height: var(--tap); padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; min-width: 220px; flex: 1 1 220px; max-width: 340px;
}

/* ---------- Kinderkarten ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.child {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  padding: 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); box-shadow: var(--shadow); cursor: pointer; min-height: 88px;
}
.child:hover { border-color: var(--teal); }
.child.soon { border-color: var(--warn); background: var(--warn-soft); }
.child.is-gone, .child.is-absent { opacity: .68; }
.child .info { min-width: 0; flex: 1; }
.child .name { font-weight: 650; }
.child .meta { font-size: .82rem; color: var(--muted); }
.child .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }

.avatar {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 27px; background: var(--teal-soft);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.7);
}
.avatar.lg { width: 96px; height: 96px; font-size: 50px; }
.avatar.xl { width: 120px; height: 120px; font-size: 64px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650;
  background: #EFEDE7; color: var(--muted);
}
.badge.present { background: var(--teal-soft); color: var(--teal-dark); }
.badge.gone { background: #E7E4DC; color: #5B5650; }
.badge.absent { background: var(--warn-soft); color: #8D3A22; }
.badge.group { color: #fff; }
.badge.allergy { background: #FDF0D5; color: #8A6300; }
.badge.room { background: #EFF4F3; color: #3D5B56; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- Dialog (Kind-Blatt) ---------- */
dialog {
  border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(30,28,25,.45); }
.sheet-head { display: flex; gap: 14px; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.sheet-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow: auto; }
.sheet-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }
.note { background: #FBF9F4; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.note b { display: block; margin-bottom: 2px; }
.note.allergy { background: #FDF0D5; border-color: #EFDCA8; }
.label { font-size: .85rem; color: var(--muted); font-weight: 650; }

/* ---------- Raeume ---------- */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: start; }
.room { padding: 14px; }
.room h3 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.room .count { font-size: .88rem; color: var(--muted); margin: 4px 0 8px; }
.bar { height: 10px; border-radius: 999px; background: #EAE6DC; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.bar.full > i { background: var(--warn); }
.people { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.person { width: 72px; text-align: center; font-size: .78rem; }
.person .avatar { width: 48px; height: 48px; font-size: 25px; margin: 0 auto 4px; }
.person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Leitung ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.code {
  font-size: 3.6rem; font-weight: 700; letter-spacing: .18em;
  font-variant-numeric: tabular-nums; color: var(--teal-dark); text-align: center;
}
.statrow { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.statrow:first-child { border-top: 0; }
.statrow .bars { display: flex; flex-direction: column; gap: 6px; }
.statbar { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.statbar .bar { flex: 1; }
.statbar .bar > i { background: var(--sun); }
.statbar.today .bar > i { background: var(--teal); }
.statbar .num { width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.hours { display: flex; gap: 3px; align-items: flex-end; height: 52px; margin-top: 8px; }
.hours i { flex: 1; background: var(--teal-soft); border-radius: 4px 4px 0 0; min-height: 2px; }
.hourlabels { display: flex; gap: 3px; font-size: .62rem; color: var(--muted); }
.hourlabels span { flex: 1; text-align: center; }

/* ---------- Anmeldung ---------- */
.login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 26px; }
.login-card .logo { width: 72px; height: 72px; display: block; margin: 0 auto 14px; border-radius: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field input {
  min-height: var(--tap); padding: 0 14px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.msg { padding: 10px 14px; border-radius: 12px; font-weight: 600; }
.msg.error { background: var(--warn-soft); color: #8D3A22; }
.msg.info { background: var(--teal-soft); color: var(--teal-dark); }

/* ---------- Offline / Installation / Toast ---------- */
#offline-banner {
  position: fixed; left: 0; right: 0; top: 0; z-index: 90;
  background: var(--warn); color: #fff; padding: 10px 16px; text-align: center; font-weight: 650;
}
#install-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; box-shadow: var(--shadow); max-width: min(420px, calc(100vw - 32px));
}
#install-bar p { margin: 0; font-size: .88rem; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 95;
  background: #2B2B2B; color: #fff; padding: 12px 18px; border-radius: 14px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast .btn { background: #fff; border-color: #fff; }

/* ---------- Kiosk ---------- */
body.kiosk { background: var(--bg); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.kiosk-top {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px;
  background: var(--teal); color: #fff;
}
.kiosk-top .roomicon { font-size: 34px; }
.kiosk-top h1 { font-size: 1.5rem; }
.kiosk-top .places { margin-left: auto; font-size: 1.1rem; font-weight: 650; background: rgba(255,255,255,.18); padding: 8px 16px; border-radius: 999px; }
.kiosk-main { padding: 20px; }
.kiosk-main > h2 { font-size: 1.7rem; text-align: center; margin-bottom: 18px; }
.groupgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; max-width: 1100px; margin: 0 auto; }
.groupbtn {
  min-height: 150px; border-radius: 24px; border: 0; color: #fff; cursor: pointer;
  font-size: 1.8rem; font-weight: 700; display: grid; place-items: center; gap: 6px;
  box-shadow: var(--shadow);
}
.tilegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; max-width: 1200px; margin: 0 auto; }
.tile {
  border: 2px solid var(--line); background: #fff; border-radius: 24px; cursor: pointer;
  padding: 16px 8px; display: grid; justify-items: center; gap: 8px; min-height: 180px;
  box-shadow: var(--shadow);
}
.tile:active { transform: scale(.97); }
.tile .tilename { font-size: 1.25rem; font-weight: 700; }
.kiosk-inside { padding: 0 20px 24px; }
.kiosk-inside h3 { font-size: 1rem; color: var(--muted); margin-bottom: 8px; font-weight: 650; }
.kiosk-back { display: block; margin: 22px auto 0; min-height: 60px; font-size: 1.15rem; padding: 0 36px; }

.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--teal); color: #fff; text-align: center; padding: 24px;
}
.overlay.full { background: var(--sun); color: #4A3A10; }
.overlay .big { font-size: 2.4rem; font-weight: 750; max-width: 18ch; line-height: 1.2; margin: 0 auto; }
.overlay .sub { font-size: 1.3rem; margin-top: 10px; opacity: .92; }
.overlay .avatar { margin: 0 auto 18px; background: rgba(255,255,255,.28); }

.keypad-wrap { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.keypad-card { width: min(420px, 100%); padding: 24px; text-align: center; }
.codebox {
  font-size: 2.6rem; letter-spacing: .3em; font-variant-numeric: tabular-nums;
  min-height: 64px; display: grid; place-items: center; color: var(--teal-dark); font-weight: 700;
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.keypad button { min-height: 68px; font-size: 1.6rem; font-weight: 650; border-radius: 16px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.keypad button:active { background: var(--teal-soft); }

/* ---------- Telefon ---------- */
@media (max-width: 640px) {
  main { padding: 12px; }
  .counters { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .counter b { font-size: 1.5rem; }
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar nav { width: 100%; margin-left: 0; }
  .topbar nav a, .topbar .linkbtn { flex: 1; padding: 0 10px; }
  .statrow { grid-template-columns: 1fr; }
  .kiosk-main > h2 { font-size: 1.3rem; }
  .groupbtn { min-height: 110px; font-size: 1.4rem; }
  .tilegrid { grid-template-columns: repeat(2, 1fr); }
  .overlay .big { font-size: 1.8rem; }
  .code { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
