/* Dienstplan – Oberfläche. Mobile zuerst, Systemschrift (keine externen Schriften), Dunkelmodus folgt dem Gerät. */
:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #1a2027; --muted: #5f6b78; --line: #dfe4ea;
  --accent: #0e7c86; --accent-ink: #ffffff; --accent-soft: #e3f2f3;
  --danger: #b3261e; --danger-soft: #fde7e5; --warn: #8a5a00; --warn-soft: #fff1d6; --good: #16784a;
  --t-dienst: #ffffff; --t-frei: #e6e9ed; --t-urlaub: #ffe0b8; --t-krank: #ffd3d1; --t-azk: #d3e4ff; --t-ff: #dcefd9; --t-offen: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 40, .08), 0 4px 14px rgba(20, 30, 40, .06);
  --radius: 14px;
  --nav-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101316; --card: #1a1f24; --text: #e7eaee; --muted: #9aa5b1; --line: #2c343c;
    --accent: #3fb8c3; --accent-ink: #06272a; --accent-soft: #15353a;
    --danger: #ff8a80; --danger-soft: #3a1c1a; --warn: #ffcb6b; --warn-soft: #3a2d10; --good: #6fd6a2;
    --t-dienst: #1a2a2c; --t-frei: #272d33; --t-urlaub: #4a3317; --t-krank: #4a2321; --t-azk: #1f3354; --t-ff: #1f3a24; --t-offen: #1a1f24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--accent); }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }

/* Rahmen */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; display: flex; align-items: center; gap: 8px; min-height: 52px;
}
.topbar h1 { margin: 0; font-size: 1.1rem; flex: 1; }
.view { width: 100%; max-width: 760px; margin: 0 auto; padding: 12px 12px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px;
  padding: 10px 14px; min-height: 44px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { min-width: 44px; padding: 8px; }

.field { display: block; margin-bottom: 12px; }
.field > span, .field > .lbl { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .cell:focus-visible, .rowbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.check span { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.err { color: var(--danger); font-size: .9rem; margin-top: 4px; }
.err-box, .ok-box, .warn-box { border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: .92rem; }
.err-box { background: var(--danger-soft); color: var(--danger); }
.ok-box { background: var(--accent-soft); color: var(--text); }
.warn-box { background: var(--warn-soft); color: var(--warn); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; background: var(--line); color: var(--muted); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.good { background: var(--accent-soft); color: var(--good); }
.pos { color: var(--good); } .neg { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }

/* Anmeldung */
.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 32px) 16px 32px; }
.auth h1 { font-size: 1.6rem; text-align: center; margin-bottom: 4px; }
.auth .logo { width: 84px; height: 84px; display: block; margin: 0 auto 12px; border-radius: 20px; box-shadow: 0 1px 6px rgba(14, 45, 79, .16); }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }
.auth form { margin-bottom: 8px; }
.auth form h2 { font-size: 1rem; margin: 18px 0 8px; }
.auth .btn.ghost.block { margin-top: 4px; }
.auth .center { text-align: center; }
.auth input[name='code'] { font-size: 1.4rem; letter-spacing: .25em; text-align: center; }
.pw { position: relative; }
.pw input { padding-right: 76px; }
.pw button { position: absolute; right: 4px; top: 4px; min-height: 36px; }

/* Google-Schaltfläche: weiß, Google-Logo, Text „Mit Google anmelden“ */
.btn.google { background: #fff; color: #1f1f1f; border-color: #747775; gap: 10px; margin-bottom: 14px; }
.btn.google svg { flex: none; }
@media (prefers-color-scheme: dark) { .btn.google { background: #131314; color: #e3e3e3; border-color: #8e918f; } }

/* Verwaltung: Kennzahlen und Balken */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.tile .k { font-size: .75rem; color: var(--muted); }
.tile .v { font-size: 1.4rem; font-weight: 700; }
.stack.plain { list-style: none; margin: 0; padding: 0; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(70px, 42%) 1fr auto; align-items: center; gap: 8px; padding: 3px 0; font-size: .9rem; }
.bars .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bars .fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bars .bn { color: var(--muted); font-size: .82rem; }

/* Monat */
.monthnav { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.monthnav h2 { margin: 0; flex: 1; text-align: center; font-size: 1.2rem; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.summary .k { font-size: .75rem; color: var(--muted); }
.summary .v { font-size: 1.25rem; font-weight: 700; }
.carry strong { white-space: nowrap; }
.carry { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; }
.toolbar { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--text); padding: 8px 12px; min-height: 40px; font: inherit; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { text-align: center; font-size: .72rem; color: var(--muted); padding: 2px 0; }
.cell {
  position: relative; min-height: 84px; padding: 4px 3px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); text-align: left; font: inherit; color: var(--text); cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column; gap: 1px; appearance: none;
}
.cell.empty { border: 0; background: transparent; cursor: default; min-height: 0; }
.cell .d { font-size: .78rem; font-weight: 700; display: flex; justify-content: space-between; }
.cell .t { font-size: .68rem; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell .t sup { font-size: .5rem; margin-left: 1px; vertical-align: top; line-height: 1; color: var(--muted); }
.cell .lbl { font-size: .7rem; font-weight: 700; color: var(--accent); }
.cell .fac { font-size: .66rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .tl { font-size: .72rem; font-weight: 600; }
.cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.cell.holiday .d { color: var(--danger); }
.cell.weekend:not(.type-dienst):not(.type-frei):not(.type-urlaub):not(.type-krank):not(.type-azk):not(.type-ff):not(.type-offen) { background: transparent; }
.cell.none { background: transparent; border-style: dashed; }
.cell.warn::after { content: "!"; position: absolute; right: 4px; bottom: 3px; font-size: .75rem; font-weight: 800; color: var(--warn); }
.type-dienst { background: var(--t-dienst); border-left: 3px solid var(--accent); }
.type-frei { background: var(--t-frei); }
.type-urlaub { background: var(--t-urlaub); }
.type-krank { background: var(--t-krank); }
.type-azk { background: var(--t-azk); }
.type-ff { background: var(--t-ff); }
.type-offen { background: var(--t-offen); border-style: dashed; }
.holname { font-size: .58rem; color: var(--danger); line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.list .rowbtn {
  display: flex; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; margin-bottom: 8px; cursor: pointer; font: inherit; color: var(--text); align-items: flex-start;
}
.list .rowbtn.muted { background: transparent; border-style: dashed; color: var(--muted); }
.list .dt { width: 46px; text-align: center; flex: none; }
.list .dt b { display: block; font-size: 1.2rem; line-height: 1.1; }
.list .dt span { font-size: .72rem; color: var(--muted); }
.list .info { flex: 1; min-width: 0; }
.list .info .l1 { font-weight: 700; }
.list .info .l2, .list .info .l3 { font-size: .88rem; color: var(--muted); }
.list .cr { font-weight: 700; flex: none; font-variant-numeric: tabular-nums; }
.list .rowbtn.type-dienst { border-left: 4px solid var(--accent); }
.list .rowbtn.type-frei { background: var(--t-frei); } .list .rowbtn.type-urlaub { background: var(--t-urlaub); }
.list .rowbtn.type-krank { background: var(--t-krank); } .list .rowbtn.type-azk { background: var(--t-azk); } .list .rowbtn.type-ff { background: var(--t-ff); }

table.calc { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.calc td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.calc td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.calc tr.sum td { font-weight: 700; border-top: 2px solid var(--line); }
table.calc tr.sub td { color: var(--muted); font-size: .85rem; }

table.ledger { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.ledger th { text-align: right; font-weight: 600; font-size: .75rem; color: var(--muted); padding: 4px; }
table.ledger th:first-child, table.ledger td:first-child { text-align: left; }
table.ledger td { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.ledger tr.link { cursor: pointer; }
table.ledger tr.gap td { color: var(--muted); font-style: italic; }
.bignum { font-size: 2rem; font-weight: 800; }

/* Archiv */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); padding: 0; cursor: pointer; aspect-ratio: 3 / 4; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .68rem; padding: 1px 6px; border-radius: 6px; }
.viewer img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }

/* Sheet */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 16, .5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 620px; max-height: 94dvh; display: flex; flex-direction: column;
  border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--card); border-radius: 18px 18px 0 0; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.05rem; }
.sheet-body { overflow: auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 18px); -webkit-overflow-scrolling: touch; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } .sheet-head { border-radius: 18px 18px 0 0; } }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.types .btn { min-height: 48px; }
.types .btn[aria-pressed=true] { outline: 3px solid var(--accent); }
.place { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--card); margin-bottom: 12px; }
.place .addr { font-weight: 600; }
.credit { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 12px; }
.credit b { font-size: 1.3rem; }
.save-status { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.save-status.saving { color: var(--muted); } .save-status.error, .save-status.retry { color: var(--danger); font-weight: 600; }
.save-status.saved { color: var(--good); }
details.hist summary { cursor: pointer; color: var(--accent); padding: 6px 0; }
details.hist li { font-size: .85rem; margin-bottom: 4px; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; background: #1f2933; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); max-width: 520px; display: flex; gap: 12px; align-items: center; font-size: .92rem; }
.toast.error { background: var(--danger); } .toast button { background: none; border: 0; color: #8fe3ea; font: inherit; font-weight: 700; cursor: pointer; padding: 4px; }
.toast.error button { color: #fff; }

.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Einrichtung (install.php) */
.install-box { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
table.checks { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: .9rem; }
table.checks td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
td.ok { color: var(--good); font-weight: 600; } td.bad { color: var(--danger); font-weight: 600; }
.form label { display: block; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
.form input { margin-top: 4px; }

@media (min-width: 560px) { .cell { min-height: 96px; } .cell .t { font-size: .8rem; } .cell .lbl { font-size: .78rem; } .cell .fac { font-size: .72rem; } }
@media print {
  .topbar, .tabbar, .toolbar, .monthnav button, .no-print { display: none !important; }
  body { background: #fff; color: #000; } .card { box-shadow: none; }
}
