:root {
  /* Farbwelt nach Vorlage Foodzentrale (Regental-Gymnasium) */
  --accent: #2E6B3A;        /* Grün: Primäraktionen, Links */
  --accent-dark: #1F4A28;   /* dunkles Grün */
  --accent-soft: #E4EFE2;   /* helles Grün: Sekundärflächen */
  --green: #2E6B3A;         /* Status anwesend / positiv */
  --blue: #1F4A28;          /* Status "Gehen" (dunkles Grün statt Blau) */
  --red: #B4452F;
  --red-soft: #F7E4E0;
  --orange: #DE9A2B;        /* Amber: Hinweise, Pause */
  --orange-soft: #FBF1DC;
  --gray: #8E9A8A;
  --bg: #F6F7F2;            /* Papierton */
  --card: #FFFFFF;
  --text: #22301F;
  --muted: #5C6B58;
  --line: #DDE3D8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(34, 48, 31, .06), 0 8px 24px rgba(34, 48, 31, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; }
input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.hidden { display: none !important; }

#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  font-size: 17px; font-weight: 500; line-height: 1.2; touch-action: manipulation;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--accent-soft); color: var(--accent-dark); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-link { background: transparent; color: var(--accent); padding: 8px 6px; }
.btn-material { background: rgba(255,255,255,.85); color: var(--text); backdrop-filter: blur(10px); }
.btn-small { font-size: 15px; padding: 8px 12px; }

/* ---------- Kiosk ---------- */
#screen-kiosk { flex-direction: row; }
.kiosk-main { flex: 1; min-width: 0; position: relative; overflow: auto; }
.kiosk-side {
  width: 380px; flex: none; background: var(--card); padding: 24px;
  display: flex; flex-direction: column; border-left: 1px solid var(--line);
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.clock { font-size: 72px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -1px; line-height: 1; }
.clock-date { font-size: 20px; color: var(--muted); margin-top: 6px; }
.presence-title { font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.presence-list { overflow: auto; }
.presence-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 20px; }
.presence-row .status { margin-left: auto; font-size: 16px; color: var(--muted); }
.presence-row .status.orange { color: var(--orange); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--gray); flex: none; }
.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }
.side-spacer { flex: 1; }
.warning { color: var(--orange); font-size: 14px; margin-bottom: 12px; }
.warning .btn { margin-top: 6px; }
.backup-status .backup-ok { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.side-buttons { display: flex; gap: 12px; }
.side-buttons .btn { flex: 1; padding: 16px 10px; }

.tiles-wrap { padding: 28px; padding-top: max(28px, env(safe-area-inset-top)); }
.tiles-title { font-size: 34px; font-weight: 700; }
.tiles-org { font-size: 20px; color: var(--muted); }
.tiles-hint { color: var(--muted); margin: 6px 0 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 18px; min-height: 170px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; text-align: left; border: 3px solid transparent;
  cursor: pointer; width: 100%;
}
.tile:active { transform: scale(.98); }
.tile.present { border-color: rgba(46,107,58,.6); }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-avatar { font-size: 40px; line-height: 1; color: var(--gray); }
.tile.present .tile-avatar { color: var(--green); }
.tile.long { border-color: var(--orange); animation: remind 2s ease-in-out infinite; }
.tile.long .tile-avatar { color: var(--orange); }
@keyframes remind { 0%, 100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 8px rgba(222, 154, 43, .35); } }
@media (prefers-reduced-motion: reduce) { .tile.long { animation: none; box-shadow: 0 0 0 4px rgba(222, 154, 43, .35); } }
.tile .dot { width: 16px; height: 16px; }
.tile-name { font-size: 22px; font-weight: 600; margin-top: auto; }
.tile-status { color: var(--muted); font-size: 15px; margin-top: 4px; }
.tile-status.orange { color: var(--orange); }
.tile-action { color: var(--accent); font-size: 14px; font-weight: 500; margin-top: 6px; }
.tile.scan { background: var(--accent); color: #fff; border-color: var(--accent); }
.tile.scan .tile-name, .tile.scan .tile-status { color: #fff; }
.tile.scan .tile-status { opacity: .85; }
.tile.scan .tile-avatar { color: #fff; }
.empty { color: var(--muted); padding: 20px 0; }

/* ---------- Scanner ---------- */
.scanner { position: absolute; inset: 0; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner video.mirror { transform: scaleX(-1); }
.scan-frame {
  position: absolute; left: 50%; top: 50%; width: 300px; height: 300px; transform: translate(-50%, -50%);
  border: 4px dashed rgba(255,255,255,.7); border-radius: 24px; pointer-events: none;
}
.scan-back { position: absolute; left: 20px; top: max(20px, env(safe-area-inset-top)); border-radius: 999px; }
.scan-hint {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.85); padding: 12px 22px; border-radius: 999px; font-size: 18px; font-weight: 500;
  white-space: nowrap;
}
.scan-message {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 40px; color: #fff; font-size: 20px; background: #222;
}

/* ---------- Rückmeldung ---------- */
.feedback { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.feedback-card {
  background: var(--card); border-radius: 28px; padding: 36px; max-width: 620px; width: calc(100% - 40px);
  text-align: center; border: 4px solid var(--gray); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.feedback-card.in { border-color: var(--green); }
.feedback-card.out { border-color: var(--blue); }
.feedback-card.error { border-color: var(--red); }
.feedback-icon { font-size: 88px; line-height: 1; }
.feedback-card.in .feedback-icon { color: var(--green); }
.feedback-card.out .feedback-icon { color: var(--blue); }
.feedback-card.error .feedback-icon { color: var(--red); }
.feedback-card.info .feedback-icon { color: var(--gray); }
.feedback-title { font-size: 40px; font-weight: 700; margin-top: 10px; }
.feedback-name { font-size: 22px; margin-top: 10px; }
.feedback-detail { font-size: 19px; color: var(--muted); margin-top: 8px; min-height: 1.2em; }
.feedback-buttons { display: flex; gap: 14px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.feedback-buttons .btn { min-width: 150px; padding: 14px 18px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-card {
  background: var(--card); border-radius: 22px; padding: 26px; width: 100%; max-width: 560px; max-height: calc(100% - 32px);
  overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-card h2 { font-size: 22px; text-align: center; }
.modal-sub { color: var(--muted); text-align: center; margin-top: 6px; }
.modal-buttons { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.modal-buttons .btn { min-width: 120px; }

.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 22px 0 14px; min-height: 20px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; background: var(--line); }
.pin-dots span.on { background: var(--accent); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-12px); } 75% { transform: translateX(12px); } }
.pin-error { color: var(--red); text-align: center; font-size: 15px; min-height: 1.2em; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin-top: 12px; }
.pin-key { height: 64px; border-radius: 14px; background: var(--bg); border: 0; font-size: 28px; font-weight: 500; cursor: pointer; }
.pin-key:active { background: var(--accent-soft); }
.pin-key.empty { background: transparent; cursor: default; }

.picker-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.picker-list button {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 0;
  background: var(--bg); font-size: 20px; text-align: left; cursor: pointer;
}
.picker-list button::after { content: "›"; margin-left: auto; color: var(--gray); font-size: 26px; }

/* ---------- Formulare ---------- */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.form-row label { font-size: 14px; color: var(--muted); }
.form-row input[type=text], .form-row input[type=password], .form-row input[type=number], .form-row input[type=datetime-local], .form-row input[type=date], .form-row input[type=time], .form-row select {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 17px; width: 100%;
}
.form-inline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.form-note { font-size: 14px; color: var(--muted); margin-top: 8px; }
.form-message { font-size: 15px; color: var(--muted); margin-top: 8px; }
.form-message.error { color: var(--red); }
.form-message.ok { color: var(--green); }
.segmented { display: inline-flex; background: var(--accent-soft); border-radius: 10px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 8px 16px; border-radius: 8px; font-size: 16px; cursor: pointer; }
.segmented button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch input { width: 24px; height: 24px; }

/* ---------- Vollbild-Ansichten (Zeiten, Verwaltung) ---------- */
.bar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 18px; text-align: center; }
.bar .btn-link:last-child { justify-self: end; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; flex-wrap: wrap; background: var(--card); border-bottom: 1px solid var(--line); }
.month-nav { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; }
.month-nav button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--accent-soft); color: var(--accent-dark); font-size: 22px; cursor: pointer; }
.month-nav .month-label { min-width: 180px; text-align: center; }
.badges { display: flex; gap: 24px; }
.badge { text-align: right; }
.badge .label { font-size: 12px; color: var(--muted); }
.badge .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge .value.neg { color: var(--red); }
.badge .value.pos { color: var(--green); }
.content { flex: 1; overflow: auto; padding: 16px 20px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

.tabs { display: flex; gap: 6px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 14px; border-radius: 10px; font-size: 16px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card .card-footer { font-size: 13px; color: var(--muted); margin-top: 10px; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; font-size: 17px; }
.list-row .sub { color: var(--muted); font-size: 14px; }
.list-row .chev { color: var(--gray); font-size: 24px; }
.list-row .meta { color: var(--muted); font-size: 15px; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 16px; overflow: hidden; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data th { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.total td { font-weight: 600; background: var(--bg); }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: var(--bg); }
.summary-line { display: flex; justify-content: space-between; padding: 12px 4px; font-size: 15px; flex-wrap: wrap; gap: 8px; }
.warn-line { color: var(--orange); font-size: 15px; padding: 8px 4px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #EEF1EA; color: var(--muted); }
.pill.orange { background: var(--orange-soft); color: #9A6A17; }
.pill.green { background: var(--accent-soft); color: var(--accent-dark); }
.pill.absence { background: #E3ECF6; color: #2F4F7A; }
.pill.holiday { background: var(--orange-soft); color: #9A6A17; }
.muted { color: var(--muted); }
.cell-input { width: 80px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 16px; text-align: right; }
table.data tr.calendar td { color: var(--muted); }
.icon-in { color: var(--green); }
.icon-out { color: var(--blue); }
.qr-preview { width: 160px; height: 160px; background: #fff; border-radius: 8px; image-rendering: pixelated; }
.qr-preview svg, .qr-preview img { width: 100%; height: 100%; display: block; }
.two-col { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.admin-detail-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.admin-detail-bar h2 { font-size: 20px; }
.day-header { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 6px; font-weight: 600; color: var(--muted); font-size: 14px; text-transform: uppercase; }
.booking-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: var(--card); border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.booking-row .time { font-size: 20px; font-weight: 600; min-width: 64px; font-variant-numeric: tabular-nums; }
.booking-row .kind { min-width: 80px; }
.booking-row .src { color: var(--muted); font-size: 14px; flex: 1; }

/* ---------- Druck ---------- */
.print-area { display: none; }
@media print {
  body { background: #fff; }
  #app > .screen, .feedback, .modal { display: none !important; }
  .print-area { display: block !important; font-size: 11pt; color: #000; }
  .print-page { page-break-after: always; padding: 0; }
  .print-page:last-child { page-break-after: auto; }
  .print-area h1 { font-size: 18pt; margin: 0 0 2pt; }
  .print-area h2 { font-size: 14pt; margin: 0; }
  .print-area .sub { color: #444; margin-bottom: 10pt; }
  .print-area table { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-top: 8pt; }
  .print-area th, .print-area td { border-bottom: .4pt solid #bbb; padding: 4pt 5pt; text-align: left; }
  .print-area th { background: #eaeaea; font-size: 9pt; }
  .print-area td.num, .print-area th.num { text-align: right; }
  .print-area tr.total td { font-weight: 700; background: #f5f5f5; }
  .print-area .note { font-size: 8.5pt; color: #555; margin-top: 6pt; }
  .print-area .sign { display: flex; gap: 40pt; margin-top: 40pt; font-size: 8.5pt; color: #444; }
  .print-area .sign div { border-top: .6pt solid #333; padding-top: 3pt; width: 200pt; }
  .print-area .footer { position: fixed; bottom: 10pt; right: 0; font-size: 8pt; color: #777; }
  .print-card {
    width: 243pt; height: 153pt; border: .6pt dashed #444; border-radius: 8pt; display: flex; align-items: center;
    gap: 14pt; padding: 12pt 14pt; margin-bottom: 20pt; page-break-inside: avoid;
  }
  .print-card .qr { width: 118pt; height: 118pt; flex: none; }
  .print-card .qr svg { width: 100%; height: 100%; }
  .print-card .org { font-size: 9pt; color: #444; }
  .print-card .name { font-size: 15pt; font-weight: 700; margin: 6pt 0 10pt; }
  .print-card .hint { font-size: 8.5pt; color: #444; }
}

/* ---------- Schmale Bildschirme (iPhone, iPad hochkant) ---------- */
@media (max-width: 900px) {
  #screen-kiosk { flex-direction: column; overflow: auto; }
  .kiosk-main { flex: none; min-height: 60vh; }
  .kiosk-side { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .clock { font-size: 48px; }
  .presence-list { max-height: 220px; }
  .bar h1 { font-size: 16px; }
  .badges { gap: 14px; }
  .badge .value { font-size: 18px; }
  .feedback-title { font-size: 30px; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { min-height: 140px; padding: 14px; }
  .tile-name { font-size: 18px; }
  .pin-pad { grid-template-columns: repeat(3, 68px); }
  .scan-frame { width: 220px; height: 220px; }
}

/* ---------- Tag korrigieren (Meine Zeiten) ---------- */
.month-nav .btn { width: auto; height: auto; font-size: 15px; }
.edit-rows { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.edit-row:last-child { border-bottom: 0; }
.edit-row input[type=time] { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 20px; font-variant-numeric: tabular-nums; }
.edit-row .muted { flex: 1; font-size: 14px; }
.edit-row .btn-link { color: var(--red); }
