:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #dfe4eb;
  --text: #1b2430;
  --muted: #667385;
  --primary: #2457d6;
  --primary-soft: #e6edfc;
  --green: #138a52;
  --green-soft: #e3f5ec;
  --red: #c8372d;
  --red-soft: #fbe9e7;
  --amber: #b26a00;
  --amber-soft: #fff3dc;
  --kiosk-bg: #0f1724;
  --kiosk-bg-2: #172235;
  --kiosk-text: #eef2f8;
  --kiosk-muted: #8d9bb0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: none; color: inherit; text-decoration: underline; padding: 0; }

/* ---------- Kiosk ---------- */
.kiosk {
  min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 600px at 50% 30%, var(--kiosk-bg-2), var(--kiosk-bg));
  color: var(--kiosk-text);
}
.k-top, .k-foot { display: flex; justify-content: space-between; align-items: center; padding: 20px 28px; gap: 12px; flex-wrap: wrap; }
.k-brand { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.k-pill { font-size: 13px; color: var(--kiosk-muted); border: 1px solid #2a3850; border-radius: 99px; padding: 5px 12px; display: inline-flex; gap: 8px; align-items: center; }
.k-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kiosk-muted); }
.k-pill .dot.on { background: #34d399; box-shadow: 0 0 8px #34d399; }
.k-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; gap: 8px; }
.clock { font-size: clamp(64px, 14vw, 140px); font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: -2px; line-height: 1; }
.clock span { color: var(--kiosk-muted); font-size: .45em; letter-spacing: 0; }
.k-date { font-size: 20px; color: var(--kiosk-muted); margin-bottom: 28px; }
.scan {
  width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: rgba(36, 87, 214, .15); border: 2px solid rgba(110, 150, 255, .45);
}
.scan::before, .scan::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid rgba(110, 150, 255, .5);
  animation: pulse 2.4s ease-out infinite;
}
.scan::after { animation-delay: 1.2s; }
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }
.scan svg { width: 64px; height: 64px; color: #9db8ff; }
.k-hint { font-size: 22px; margin: 22px 0 26px; }
.btn-xl {
  font-size: 20px; font-weight: 600; padding: 18px 36px; border-radius: 16px;
  background: #fff; color: var(--kiosk-bg); border: none;
}
.btn-xl:hover { filter: brightness(.95); }
.k-foot { color: var(--kiosk-muted); font-size: 14px; }
.k-foot .link { color: var(--kiosk-muted); }
.k-foot-actions { display: flex; gap: 18px; }

.demo-drawer { background: #0b111b; border-top: 1px solid #22304a; padding: 14px 28px 20px; }
.demo-drawer p { margin: 0 0 10px; color: var(--kiosk-muted); font-size: 13px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-chips button { background: #1b2840; color: var(--kiosk-text); border: 1px solid #2c3d5c; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.demo-chips button:hover { background: #243556; }

/* Employee picker / PIN */
.k-panel { width: min(760px, 100%); }
.k-panel h2 { font-weight: 500; font-size: 26px; margin-bottom: 22px; }
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.emp-tile {
  background: #1a263b; border: 1px solid #2a3a57; color: var(--kiosk-text); border-radius: 16px; padding: 18px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.emp-tile:hover { background: #22324d; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #fff; position: relative; flex-shrink: 0; }
.avatar .st { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #1a263b; background: #64748b; }
.avatar .st.in { background: #34d399; }
.emp-tile .nm { font-weight: 600; }
.emp-tile .sub { font-size: 12px; color: var(--kiosk-muted); }

.pin-box { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pin-dots { display: flex; gap: 14px; height: 22px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #7f8ea8; }
.pin-dots i.f { background: #fff; border-color: #fff; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 84px); gap: 14px; }
.pin-pad button { height: 84px; border-radius: 50%; border: 1px solid #2c3d5c; background: #1a263b; color: #fff; font-size: 28px; }
.pin-pad button:hover { background: #243556; }
.pin-pad button.fn { font-size: 16px; background: transparent; border-color: transparent; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pin-err { color: #fca5a5; min-height: 20px; font-size: 15px; }
.k-back { position: absolute; top: 20px; left: 24px; }
.k-back .btn { background: transparent; color: var(--kiosk-muted); border-color: #2a3850; }

/* ---------- Overlay (stamp confirmation) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; flex-direction: column;
  color: #fff; text-align: center; padding: 24px; gap: 10px; cursor: pointer;
}
.overlay.show { display: flex; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.overlay.in { background: #0f7a4a; }
.overlay.out { background: #1d4fc4; }
.overlay.warn { background: #a35f00; }
.overlay.err { background: #a8291f; }
.overlay .ic { width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .18); display: grid; place-items: center; margin-bottom: 14px; }
.overlay .ic svg { width: 60px; height: 60px; }
.overlay .t1 { font-size: clamp(28px, 5vw, 48px); font-weight: 600; }
.overlay .t2 { font-size: clamp(20px, 3vw, 28px); opacity: .92; }
.overlay .t3 { font-size: 18px; opacity: .8; margin-top: 6px; }
.overlay .ov-actions { margin-top: 26px; display: flex; gap: 12px; }
.overlay .ov-actions .btn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: #fff; font-size: 16px; padding: 12px 20px; }
.overlay .bar { position: absolute; left: 0; bottom: 0; height: 6px; background: rgba(255, 255, 255, .5); }

/* ---------- App shell (portal / admin) ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; position: sticky; top: 0; z-index: 10;
}
.topbar .avatar { width: 42px; height: 42px; font-size: 16px; }
.topbar .who { flex: 1; min-width: 160px; }
.topbar .who b { display: block; font-size: 17px; }
.topbar .who span { font-size: 13px; color: var(--muted); }
.idle { font-size: 13px; color: var(--amber); background: var(--amber-soft); padding: 4px 10px; border-radius: 99px; }
.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  border: none; background: none; padding: 14px 14px 12px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.content { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.kpi { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi.pos { color: var(--green); }
.kpi.neg { color: var(--red); }

.stamp-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 24px; }
.stamp-card .state { font-size: 15px; color: var(--muted); }
.stamp-card .state b { display: block; font-size: 24px; color: var(--text); margin-top: 4px; }
.stamp-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.stamp-btns .btn { font-size: 19px; padding: 18px 30px; border-radius: 14px; min-width: 200px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.off td { color: var(--muted); background: #fafbfc; }
tr.today td { background: var(--primary-soft); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.ev { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 6px; padding: 2px 4px 2px 8px; margin: 2px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ev.in { background: var(--green-soft); }
.ev.out { background: var(--primary-soft); }
.ev button { border: none; background: none; color: var(--muted); padding: 0 4px; font-size: 15px; line-height: 1; }
.ev button:hover { color: var(--red); }
.src { font-size: 10px; color: var(--muted); text-transform: uppercase; }

/* Week bars */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 130px; }
.week .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week .bar { width: 100%; max-width: 38px; background: var(--primary); border-radius: 6px 6px 3px 3px; min-height: 3px; position: relative; }
.week .bar.leave { background: #8fb0f2; }
.week .bar.empty { background: var(--surface-2); }
.week .lbl { font-size: 12px; color: var(--muted); }
.week .val { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Forms */
.form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; background: var(--surface); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field .row { display: flex; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; grid-column: 1 / -1; flex-wrap: wrap; }
.section-title { grid-column: 1 / -1; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); margin-top: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.month-nav { display: inline-flex; align-items: center; gap: 6px; }
.month-nav b { min-width: 140px; text-align: center; }
.list-empty { color: var(--muted); padding: 18px 0; text-align: center; font-size: 14px; }
.note { background: var(--amber-soft); color: #7a4a00; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.note.blue { background: var(--primary-soft); color: #1c3f99; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 36, .5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: min(720px, 100%); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(900px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-h h3 { font-size: 18px; }
.modal-b { padding: 20px 22px; }
.capture { border: 2px dashed var(--primary); background: var(--primary-soft); border-radius: 12px; padding: 16px; text-align: center; color: var(--primary); font-weight: 600; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 12px 20px; border-radius: 12px; z-index: 200; font-size: 14px; box-shadow: var(--shadow); animation: fadein .2s; max-width: calc(100% - 32px); }

/* Payslip */
.slip { font-size: 14px; }
.slip-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.slip-head h2 { font-size: 20px; }
.slip table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.slip .sum td { font-weight: 700; border-top: 2px solid var(--text); }
.slip .net td { font-size: 18px; font-weight: 800; background: var(--green-soft); }

@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .pin-pad { grid-template-columns: repeat(3, 72px); }
  .pin-pad button { height: 72px; }
  .stamp-btns .btn { min-width: 0; width: 100%; }
}

@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; padding: 20px; }
  .no-print { display: none !important; }
}

/* ===================== Handy-App ===================== */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% 0%, #dfe8fb, var(--bg)); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  width: min(400px, 100%); padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -8px 0 4px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto; background: var(--primary); color: #fff; display: grid; place-items: center; }
.login-logo svg { width: 34px; height: 34px; }
.login-card .note { text-align: left; }
.form.one { grid-template-columns: 1fr; text-align: left; }
.btn.big { padding: 14px; font-size: 17px; border-radius: 12px; width: 100%; }
.demo { color: var(--muted); text-align: left; }
.demo summary { cursor: pointer; }
.demo div { margin-top: 6px; line-height: 1.6; }

.stamp-card { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding: 22px; }
.stamp-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.stamp-state .dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa5b4; }
.stamp-state.in { color: var(--green); }
.stamp-state.in .dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.stamp-today { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.stamp-today small { font-size: 16px; color: var(--muted); font-weight: 500; }
.stamp-btns { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stamp-btns .btn { font-size: 19px; padding: 18px; border-radius: 14px; min-width: 0; }
.stamp-btns .btn svg { width: 22px; height: 22px; }
.stamp-hint { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stamp-hint svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--primary); }

.scan-wait { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px 0; text-align: center; }
.scan-wait .scan { background: var(--primary-soft); border-color: var(--primary); }
.scan-wait .scan svg { color: var(--primary); }

.door { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.door-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.door-url { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.door-url code { background: var(--surface-2); padding: 7px 10px; border-radius: 8px; font-size: 13px; word-break: break-all; flex: 1; min-width: 200px; }
.steps { margin: 0; padding-left: 20px; line-height: 1.6; }
.steps li { margin-bottom: 6px; }

/* untere Navigation auf dem Handy */
@media (max-width: 760px) {
  .shell.has-bottom { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .tabs.bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; border-top: 1px solid var(--border); border-bottom: none;
    padding: 4px 4px env(safe-area-inset-bottom); justify-content: space-around; gap: 0; }
  .tabs.bottom button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; font-size: 11px; border-bottom: none; flex: 1; position: relative; }
  .tabs.bottom button.on { border-bottom: none; }
  .topbar .who span { display: none; }
  .stamp-today { font-size: 38px; }
}
.tabs .ti { display: none; }
.tabs.bottom .ti { width: 22px; height: 22px; }
@media (max-width: 760px) { .tabs.bottom .ti { display: block; } }
.tabs .ti svg { width: 100%; height: 100%; }
@media (max-width: 760px) {
  .topbar { flex-wrap: nowrap; gap: 10px; }
  .topbar .who { min-width: 0; }
  .topbar .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
  .has-bottom .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .has-bottom .card { padding: 14px 16px; }
  .has-bottom .kpi { font-size: 24px; }
}

/* Buchungen direkt bearbeiten */
.ev { padding: 2px 4px; }
.ev .ev-type { border: none; background: none; padding: 0 3px; font-size: 14px; color: inherit; cursor: pointer; border-radius: 4px; }
.ev .ev-type:hover { background: rgba(0, 0, 0, .08); color: inherit; }
.ev-time { border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 1px 2px; font-size: 13px; font-variant-numeric: tabular-nums; width: 76px; }
.ev-time:hover { border-color: var(--border); background: #fff; }
.ev-time:focus { outline: none; border-color: var(--primary); background: #fff; }
.ev.edited { box-shadow: inset 0 0 0 1px var(--amber); }
.ev-time { width: 58px; }
.ev-time::-webkit-calendar-picker-indicator { display: none; }
