/* EWT Stempeluhr — flaches DB-Design wie das Hauptportal:
   DB-Rot, kühle Grautöne, Fira Sans, 1px-Rahmen statt Schatten. */
@font-face { font-family: "Fira Sans"; font-weight: 400; font-display: swap; src: url("/fonts/fira-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 500; font-display: swap; src: url("/fonts/fira-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 700; font-display: swap; src: url("/fonts/fira-sans-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #F0F3F5;
  --surface: #F7F9FA;
  --card: #FFFFFF;
  --fg: #282D37;
  --muted: #646973;
  --border: #D7DCE1;
  --border-strong: #AFB4BB;
  --input: #878C96;
  --red: #EC0016;
  --red-hover: #C50014;
  --red-active: #9B000E;
  --red-soft: #FFF1F2;
  --red-text: #C50014;
  --green: #408335;
  --green-soft: #EEF6EC;
  --amber: #A35A00;
  --amber-soft: #FFF5E0;
  --blue: #0A6ED1;
  --ink: #12245E;
  --focus: #131821;
  --radius: 8px;
  --radius-lg: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0E1116;
    --surface: #161A21;
    --card: #1A1F27;
    --fg: #E8EBEE;
    --muted: #A0A6B0;
    --border: #2C323C;
    --border-strong: #464D59;
    --input: #6B7380;
    --red: #EC0016;
    --red-hover: #FF2E3F;
    --red-active: #FF5462;
    --red-soft: #2A1418;
    --red-text: #FF6B78;
    --green: #7BC46D;
    --green-soft: #17251A;
    --amber: #F0B35A;
    --amber-soft: #2A2112;
    --blue: #5EA8F2;
    --ink: #C9D6FF;
    --focus: #FFFFFF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.45 "Fira Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red-text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.i { display: inline-flex; }
.i svg { width: 20px; height: 20px; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- Kopf + Navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; height: 56px; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand img { width: 44px; height: auto; display: block; }
.brand b { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-size: 14px; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a {
  text-decoration: none; color: var(--fg); padding: 8px 12px; border-radius: var(--radius); font-weight: 500;
  border-bottom: 2px solid transparent; border-radius: 0;
}
.topnav a:hover { background: var(--surface); }
.topnav a[aria-current="page"] { border-bottom-color: var(--red); color: var(--fg); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(var(--tabs, 4), 1fr);
  padding-bottom: var(--safe-bottom);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 10px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500;
  border-top: 2px solid transparent; margin-top: -1px;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a[aria-current="page"] { color: var(--red-text); border-top-color: var(--red); }

main { max-width: 960px; margin: 0 auto; padding: 20px 16px calc(96px + var(--safe-bottom)); }
@media (min-width: 760px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  main { padding-bottom: 48px; }
}

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 500; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Formulare ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--input); border-radius: var(--radius);
}
.input:focus { outline: none; border-color: var(--focus); box-shadow: inset 0 0 0 1px var(--focus); }
.input[aria-invalid="true"] { border-color: var(--red); }
textarea.input { min-height: 72px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 160px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--card); color: var(--fg);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.primary:active { background: var(--red-active); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { color: var(--red-text); border-color: var(--red-text); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Heute / Stempeln ---------- */
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.clock { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -.02em; }
.stamps { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 16px; }
@media (min-width: 560px) { .stamps { grid-template-columns: 1fr 1fr; } }
.stamp {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 18px 16px; min-height: 96px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
}
.stamp:hover { border-color: var(--border-strong); }
.stamp .ic {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--red); color: #fff;
}
.stamp .ic svg { width: 28px; height: 28px; }
.stamp .lbl { display: block; font-weight: 700; font-size: 18px; }
.stamp .hint { display: block; color: var(--muted); font-size: 14px; }
.stamp .time { margin-left: auto; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stamp.done { background: var(--surface); }
.stamp.done .ic { background: var(--green); }
.stamp.next { border: 2px solid var(--red); padding: 17px 15px; }
.stamp:disabled { cursor: default; }
.stamp-edit { position: absolute; right: 8px; bottom: 6px; font-size: 13px; color: var(--muted); }

.status {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; font-size: 15px;
}
.status svg { width: 20px; height: 20px; flex: none; }
.status.ok { background: var(--green-soft); border-color: transparent; color: var(--fg); }
.status.ok svg { color: var(--green); }
.status.warn { background: var(--amber-soft); border-color: transparent; }
.status.warn svg { color: var(--amber); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--fg); }
.preview { font-size: 14px; color: var(--muted); margin: -6px 0 14px; }
.preview b { color: var(--fg); font-weight: 500; }
.preview.too-long b { color: var(--red-text); }
.saved { font-size: 13px; color: var(--muted); }

/* ---------- Monat ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.month-nav h1 { margin: 0; flex: 1; text-align: center; font-size: 22px; }
.month-nav .btn { min-width: 44px; padding: 0 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; }
.stat b { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.hl b { color: var(--red-text); }

.days { list-style: none; margin: 0; padding: 0; }
.day {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; background: var(--card);
  width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
}
.days li:last-child .day { border-bottom: 0; }
.day:hover { background: var(--surface); }
.day .d { text-align: center; line-height: 1.1; }
.day .d b { display: block; font-size: 22px; font-weight: 700; }
.day .d span { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.day .t { min-width: 0; }
.day .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day .t span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.day .r { text-align: right; font-variant-numeric: tabular-nums; }
.day .r b { display: block; font-weight: 500; }
.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red-text); border-color: transparent; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; color: var(--border-strong); margin-bottom: 8px; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--card); color: var(--fg);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
dialog::backdrop { background: rgba(19, 24, 33, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 16px; }
.dlg-foot { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- Unterschrift ---------- */
.sigpad {
  position: relative; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fff;
  touch-action: none; height: 180px;
}
.sigpad canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.sigpad .line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1px solid #AFB4BB; pointer-events: none; }
.sigpad .ph { position: absolute; left: 24px; bottom: 18px; font-size: 13px; color: #878C96; pointer-events: none; }
.sigprev { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; align-items: center; justify-content: center; min-height: 96px; }
.sigprev img { max-height: 72px; max-width: 100%; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(420px, 100%); padding: 24px; }
.auth .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth .logo img { width: 64px; }
.auth .switch { text-align: center; margin-top: 16px; font-size: 15px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--red-text); text-decoration: underline; cursor: pointer; }
.err { color: var(--red-text); font-size: 14px; margin: 0 0 12px; }
.note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-size: 14px; margin-bottom: 14px; }
.note.warn { background: var(--amber-soft); border-color: transparent; }
.note ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Tabelle (Admin) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-weight: 500; color: var(--muted); background: var(--surface); }
.table-wrap { overflow-x: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; background: var(--surface); padding: 2px 6px; border-radius: 4px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-bottom)); z-index: 50; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
@media (min-width: 760px) { #toasts { bottom: 24px; } }
.toast { background: #282D37; color: #fff; border-radius: var(--radius); padding: 12px 14px; font-size: 15px; animation: up .2s ease-out both; }
.toast.error { background: var(--red-active); }
@media (prefers-color-scheme: dark) { .toast { background: #E8EBEE; color: #131821; } .toast.error { background: #FF5462; color: #131821; } }
@keyframes up { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
