:root {
  --dark: #182842;
  --blue: #1479ef;
  --green: #079b80;
  --red: #d64550;
  --orange: #ff8c27;
  --muted: #62728a;
  --bg: #f3f6fa;
  --card: #ffffff;
  --line: #e3e8ef;
  --frueh: #e0f0ff;
  --spaet: #ffedc8;
  --nacht: #e9e1ff;
  --frei: #f4f6f9;
  --krank: #ffdfe1;
  --urlaub: #b8eac7;
  --urlaub-plan: #eaf5c9;
  --vb: #d8f5ee;
  --tab-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--dark); }

body.noscroll { overflow: hidden; }

#main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
p { line-height: 1.45; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.green { color: var(--green); }
.big { font-size: 18px; font-weight: 700; }
.pre { white-space: pre-line; }
.hidden { display: none; }

.app-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.app-head p { margin: 2px 0 0; font-size: 13px; }

.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--blue);
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px;
}

.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; padding: 6px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(24, 40, 66, .06);
}
.nav-title { text-align: center; font-size: 17px; text-transform: capitalize; }
.nav-arrow {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--bg);
  font-size: 26px; line-height: 1; color: var(--dark);
}

.notice { border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.4; margin-bottom: 10px; }
.notice.warn { background: #fff3e0; color: #8a4a0c; border: 1px solid #ffd8a8; }
.notice.info { background: #e6f6f1; color: #05624f; border: 1px solid #b6e6d8; }

/* Kalender */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { text-align: center; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 2px 0 4px; text-transform: capitalize; }
.cal-empty { min-height: 58px; }
.cal-day {
  position: relative; min-height: 58px; border: 0; border-radius: 10px; padding: 4px 2px 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  font: inherit; color: var(--dark); background: var(--frei); cursor: pointer;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.cal-day:active { transform: scale(.96); }
.cal-day .num { font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-day .code { font-size: 16px; font-weight: 800; min-height: 19px; }
.cal-day.today { outline: 2.5px solid var(--blue); outline-offset: -2.5px; }
.cal-day.provisional { background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.55) 6px 9px); }
.badges { display: flex; gap: 2px; min-height: 13px; }
.badge { font-size: 9.5px; line-height: 13px; min-width: 13px; padding: 0 3px; border-radius: 7px; font-weight: 700; background: #fff; color: var(--dark); }
.badge.v { background: #a6e6da; }
.badge.v.done { background: var(--green); color: #fff; }
.badge.ot { background: var(--orange); color: #fff; }
.badge.m { background: transparent; color: var(--muted); }

.t-frueh { background: var(--frueh); }
.t-spaet { background: var(--spaet); }
.t-nacht { background: var(--nacht); }
.t-frei { background: var(--frei); }
.t-krank { background: var(--krank); }
.t-urlaub { background: var(--urlaub); }
.t-urlaub.planned { background: var(--urlaub-plan); }
.t-vb { background: var(--vb); }
.t-none { background: #fafafa; color: #aaa; }
.t-v { background: #a6e6da; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 2px 14px; font-size: 12px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.06); }

/* Karten */
.card {
  background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(24, 40, 66, .06);
}
.card .btn { margin-top: 10px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.row:last-of-type { border-bottom: 0; }
.row b { white-space: nowrap; }
.row.strong { font-weight: 700; border-top: 1px solid var(--line); }
.hero { display: flex; justify-content: space-between; gap: 12px; }
.hero div { display: flex; flex-direction: column; gap: 4px; }
.hero strong { font-size: 22px; }

.stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.btn {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--dark); font: inherit; font-weight: 600; font-size: 15px; padding: 10px 14px;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: var(--bg); }
.btn:active { opacity: .85; }

/* Statistik */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; font-size: 10.5px; color: var(--muted); }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 1px; }
.bar { width: 45%; min-height: 1px; border-radius: 3px 3px 0 0; }
.bar.a { background: var(--blue); }
.bar.b { background: var(--green); }
.bar-wrap .bar:only-child { width: 70%; }
.scroll-x { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 7px 5px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; text-transform: capitalize; }
.table tbody tr { cursor: pointer; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 16px; /* verhindert Zoom auf iPhone */
  color: var(--dark); background: #fff; border: 1px solid #cdd5e0; border-radius: 10px;
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; min-height: 120px; margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; color: var(--dark); }
.check input { width: 22px; height: 22px; min-height: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* Bottom Sheet */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 25, 45, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease; -webkit-overflow-scrolling: touch;
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #d5dbe4; margin: 4px auto 10px; }
.sheet-body p { margin: 0 0 12px; white-space: pre-line; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; position: sticky; bottom: 0; background: var(--card); padding-top: 8px; }
.sheet-actions .btn { flex: 1 1 30%; }
.menu { display: flex; flex-direction: column; }
.menu-item {
  display: flex; align-items: center; gap: 12px; border: 0; background: none; font: inherit; font-size: 15.5px;
  color: var(--dark); padding: 13px 4px; border-bottom: 1px solid var(--line); text-align: left; min-height: 48px;
}
.menu-item.danger { color: var(--red); font-weight: 600; }
.menu-icon { width: 26px; text-align: center; font-weight: 700; color: var(--muted); }
.menu-item.danger .menu-icon { color: var(--red); }
.ot-list { background: var(--bg); border-radius: 10px; padding: 4px 10px; margin-bottom: 8px; }

@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; }
  .cal-day, .cal-empty { min-height: 72px; }
}

@keyframes up { from { transform: translateY(30px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tabbar button {
  flex: 1; height: var(--tab-h); border: 0; background: none; color: var(--muted); font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tabbar .tab-icon { font-size: 20px; line-height: 1; }
.tabbar .tab-label { font-size: 11px; font-weight: 600; }
.tabbar button.active { color: var(--blue); }

#toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 60;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none; transition: all .2s ease;
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Prämien-Pakete */
.pkg-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "info sum" "ctrl ctrl"; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pkg-info { grid-area: info; display: flex; flex-direction: column; gap: 2px; }
.pkg-sum { grid-area: sum; align-self: center; white-space: nowrap; }
.pkg-ctrl { grid-area: ctrl; display: flex; align-items: center; gap: 8px; }
.pkg-btn { width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 22px; font-weight: 700; color: var(--dark); }
.pkg-count { min-width: 64px; height: 40px; border-radius: 10px; border: 1px solid #cdd5e0; background: #fff; font: inherit; font-size: 17px; font-weight: 700; color: var(--dark); }
.pkg-edit { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 4px; margin-bottom: 10px; }
.small-btn { min-height: 40px; font-size: 14px; margin-bottom: 8px; }
@media (min-width: 600px) {
  .pkg-row { grid-template-columns: 1fr auto auto; grid-template-areas: "info ctrl sum"; align-items: center; }
}
.pkg-toggle { min-width: 110px; height: 40px; border-radius: 10px; border: 1px solid #f1c4c8; background: #fdeef0; color: var(--red); font: inherit; font-size: 16px; font-weight: 700; }
.pkg-toggle.on { border-color: var(--green); background: #e3f6f1; color: var(--green); }
