:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --ink: #17201c;
  --muted: #5d6a64;
  --line: #e1ddd3;
  --brand: #2a5bd7;
  --brand-ink: #ffffff;
  --brand-soft: #e7eefc;
  --accent: #c2410c;
  --warn: #b54708;
  --warn-soft: #fdf0e1;
  --info: #1d5fa8;
  --info-soft: #e5eefa;
  --ok: #157347;
  --ok-soft: #e1f3e8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 32, 28, .06), 0 6px 24px rgba(23, 32, 28, .06);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315;
    --surface: #1b1c1f;
    --surface-2: #232428;
    --ink: #ececee;
    --muted: #a1a3a9;
    --line: #2f3135;
    --brand: #7da2ff;
    --brand-ink: #0b1220;
    --brand-soft: #172447;
    --warn: #f0a35b;
    --warn-soft: #33240f;
    --info: #7fb2ee;
    --info-soft: #172840;
    --ok: #59c98e;
    --ok-soft: #14301f;
    --danger: #f2877d;
    --danger-soft: #3a1714;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.loading { padding: 4rem 0; text-align: center; color: var(--muted); }

/* Kopfleiste */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-size: .78rem; }
.topnav { display: none; gap: 4px; }
.topnav a, .tabbar a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem;
  padding: 8px 12px; border-radius: 10px;
}
.topnav a.active { background: var(--brand-soft); color: var(--brand); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; padding: 6px 8px; min-width: 64px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--brand); }
@media (min-width: 820px) {
  .topnav { display: flex; }
  .tabbar { display: none !important; }
  body { padding-bottom: 24px; }
}

/* Karten */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 820px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 600; margin-bottom: 8px; }

/* Buttons */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 10px 20px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* Stempeluhr */
.clock { text-align: center; padding: 26px 18px; }
.clock .time { font-size: 3.2rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.clock .since { color: var(--muted); margin: 6px 0 18px; }
.clock-btn {
  width: 190px; height: 190px; border-radius: 50%; border: 0; cursor: pointer;
  font: inherit; font-size: 1.25rem; font-weight: 750; color: #fff;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(circle at 30% 25%, #1a8a66, #0f6b4f 70%); /* Start-Knopf bleibt immer grün */
  box-shadow: 0 10px 30px rgba(15, 107, 79, .35), inset 0 -4px 0 rgba(0, 0, 0, .12);
  transition: transform .08s ease;
}
.clock-btn svg { width: 40px; height: 40px; }
.clock-btn:active { transform: scale(.97); }
.clock-btn.stop { background: radial-gradient(circle at 30% 25%, #e05a2b, #c2410c 70%); box-shadow: 0 10px 30px rgba(194, 65, 12, .35), inset 0 -4px 0 rgba(0, 0, 0, .12); }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.6s infinite; vertical-align: middle; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 65, 12, .5); } 70% { box-shadow: 0 0 0 10px rgba(194, 65, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(194, 65, 12, 0); } }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 4px; border-top: 1px solid var(--line); text-decoration: none; color: inherit;
}
.list li:first-child .row, .list > .row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row .day {
  width: 52px; text-align: center; border-radius: 12px; background: var(--surface-2); padding: 6px 0; line-height: 1.1;
}
.row .day b { display: block; font-size: 1.25rem; }
.row .day small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.row .main { min-width: 0; }
.row .main .t { font-weight: 650; }
.row .main .s { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; }
.row .end .w { font-weight: 700; font-variant-numeric: tabular-nums; }
.row.check { grid-template-columns: auto auto 1fr auto; }
.row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--brand); }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

/* Status-Chips */
.chip { display: inline-block; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip.laeuft { background: var(--warn-soft); color: var(--warn); }
.chip.offen { background: var(--info-soft); color: var(--info); }
.chip.freigegeben { background: var(--warn-soft); color: var(--warn); }
.chip.unterschrieben { background: var(--ok-soft); color: var(--ok); }
.chip.role { background: var(--brand-soft); color: var(--brand); }
.chip.off { background: var(--surface-2); color: var(--muted); }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stat small { color: var(--muted); display: block; font-size: .8rem; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

/* Detailtabelle */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.total { display: flex; justify-content: space-between; align-items: center; background: var(--brand-soft); color: var(--brand); border-radius: 12px; padding: 14px 16px; margin-top: 14px; font-weight: 700; }
.total b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

/* Formulare */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .84rem; margin-top: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px; border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .row-fields.three { grid-template-columns: 1fr 1fr 1fr; } }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.switch:first-of-type { border-top: 0; }
.switch label { margin: 0; font-weight: 600; }
.switch input { width: 24px; height: 24px; min-height: 0; accent-color: var(--brand); flex: none; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.notice { background: var(--info-soft); color: var(--info); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* Login */
.login { max-width: 400px; margin: 8vh auto 0; }
.login .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; text-align: center; }

/* Unterschrift */
.sign-page { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 12px); }
.sign-summary { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.sign-summary p { margin: 0; }
.sign-wrap { position: relative; flex: 1; min-height: 200px; background: #fff; border-radius: 16px; border: 2px dashed #b9c4be; overflow: hidden; touch-action: none; }
.sign-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sign-wrap .baseline { position: absolute; left: 6%; right: 6%; bottom: 26%; border-bottom: 1.5px solid #c7d0cb; pointer-events: none; }
.sign-wrap .x { position: absolute; left: 6%; bottom: calc(26% + 4px); color: #9aa8a1; font-size: 1.4rem; pointer-events: none; }
.sign-wrap .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9aa8a1; pointer-events: none; font-size: 1.05rem; }
.sign-actions { display: flex; gap: 10px; margin-top: 12px; }
.sign-actions .btn { flex: 1; }

/* Hilfe */
.help details { border-top: 1px solid var(--line); padding: 12px 0; }
.help details:first-of-type { border-top: 0; }
.help summary { font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.help summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.3rem; line-height: 1; }
.help details[open] summary::after { content: "–"; }
.help details > div { padding-top: 8px; color: var(--ink); }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 44px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 750; display: flex; align-items: center; justify-content: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 650; cursor: pointer; min-height: 38px; }
.tabs button.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* Protokoll */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .d { color: var(--muted); font-size: .8rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; word-break: break-all; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-width: 150px; flex: 1; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav b { min-width: 130px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }

table.users { width: 100%; border-collapse: collapse; }
table.users td, table.users th { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.users th { font-size: .8rem; color: var(--muted); border-top: 0; }

@media print {
  .topbar, .tabbar, .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
.row-link { display: contents; color: inherit; text-decoration: none; }
.notice svg { width: 22px; height: 22px; flex: none; }
.row-fields > *, .field { min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; display: block; }
.total { flex-wrap: wrap; gap: 4px 12px; }
.total b { font-size: 1.3rem; text-align: right; margin-left: auto; }
@media (min-width: 640px) { .total b { font-size: 1.5rem; } }
.sign-actions .btn { min-width: 0; padding: 10px 8px; }
@media (max-width: 520px) {
  .sign-actions { flex-wrap: wrap; }
  .sign-actions .btn.primary { flex-basis: 100%; }
}
.total.soft { background: var(--surface-2); color: var(--ink); font-weight: 600; margin-top: 8px; }
.total.soft small { color: var(--muted); font-weight: 500; }
.stat.highlight { background: var(--brand-soft); }
.stat.highlight small, .stat.highlight b { color: var(--brand); }
.stat.highlight { grid-column: 1 / -1; }

/* Auswertung */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; }
.pill.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
table.ev { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.ev th, table.ev td { padding: 10px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.ev th { font-size: .8rem; color: var(--muted); border-top: 0; }
table.ev .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.ev a { text-decoration: none; color: var(--ink); }
.bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; max-width: 160px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* Demo */
.demo-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 14px; font-size: .8rem; font-weight: 600; background: var(--warn-soft); color: var(--warn); }
.demo-bar button { font: inherit; color: inherit; background: none; border: 0; text-decoration: underline; padding: 8px 6px; min-height: 36px; cursor: pointer; }
.demo-roles { display: grid; gap: 10px; }
.demo-roles .btn { justify-content: flex-start; text-align: left; flex-wrap: wrap; min-height: 64px; gap: 4px 10px; }
.demo-roles .btn small { flex-basis: 100%; font-weight: 500; opacity: .85; padding-left: 32px; }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
@media (max-width: 420px) { table.ev { font-size: .88rem; } table.ev th, table.ev td { padding: 9px 4px; } }

/* Einfache Startseiten: „Das ist jetzt zu tun“, große Knöpfe, Schrittanzeige */
.btn.xl { min-height: 62px; font-size: 1.1rem; width: 100%; padding: 12px 18px; }
.todo { border: 2px solid var(--brand); }
.todo h2 { font-size: 1.3rem; margin-bottom: 6px; }
.todo-item { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.todo h2 + .todo-item { border-top: 0; padding-top: 6px; }
.todo-item b { font-size: 1.1rem; }
.todo.done { border-color: var(--ok); text-align: center; }
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 520px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tiles .btn.xl { background: var(--surface); }
.howto summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; min-height: 44px; display: flex; align-items: center; }
.howto .steps { margin-top: 8px; }
.stepper { display: flex; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.stepper li { flex: 1; text-align: center; font-size: .82rem; font-weight: 700; padding: 9px 4px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.stepper li.done { background: var(--ok-soft); color: var(--ok); }
.stepper li.now { background: var(--brand); color: var(--brand-ink); }
.actions .btn.xl { flex: 1 1 100%; }
.adv { margin-top: 4px; }
.adv summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; color: var(--brand); }
@media (max-width: 639px) {
  .row-fields.three { grid-template-columns: 1fr 1fr; }
  .row-fields.three > .field:first-child { grid-column: 1 / -1; }
}
.adv.card { padding: 2px 16px; }
.adv[open].card { padding-bottom: 12px; }

/* PDF-Ansicht */
.pdf-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* Benutzerliste auf schmalen Bildschirmen als Karten statt Tabelle */
@media (max-width: 560px) {
  table.users, table.users tbody { display: block; }
  table.users thead { display: none; }
  table.users tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
  table.users tr:first-child { border-top: 0; }
  table.users td { border: 0; padding: 2px 0; text-align: left; }
  table.users td:nth-child(4) { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  table.users td:nth-child(-n+3) { grid-column: 1; }
}

/* Logo der Apotheke (beliebiges Seitenverhältnis) */
.brand img { width: auto; height: 34px; max-width: 170px; object-fit: contain; }
.has-logo .brand strong { display: none; } /* mit Logo steht der Name der Apotheke schon im Logo */
.login .logo img { width: auto; height: 64px; max-width: 220px; object-fit: contain; }
.logo-prev { display: block; max-width: 220px; max-height: 80px; margin: 6px 0 10px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.color-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.color-row input[type=color] { width: 64px; min-height: 48px; padding: 4px; }

/* Symbol-Logos */
.logo-slot { display: inline-flex; align-items: center; }
.sym { color: var(--brand); width: 34px; height: 34px; flex: none; }
.login .logo .sym { width: 64px; height: 64px; }
.sym-picker { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.sym-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; min-height: 76px; padding: 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; }
.sym-btn .sym { width: 36px; height: 36px; }
.sym-btn.active { border-color: var(--brand); background: var(--brand-soft); }
.logo-now { margin: 4px 0 8px; } .logo-now .sym { width: 48px; height: 48px; } .logo-now img { max-height: 56px; max-width: 220px; }
.sym-picker { gap: 6px; }
.sym-btn { min-width: 68px; flex: 1 1 68px; max-width: 100px; }
