:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e2e5ea;
  --line-strong: #c9ced6;
  --text: #1d232b;
  --muted: #687280;
  --accent: #e87d0d;
  --accent-soft: #fdf0e1;
  --accent-text: #a35400;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fff4dd;
  --err: #c0262d;
  --err-soft: #fde8e8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 20px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 54px; background: #20262e; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 20px; width: auto; display: block; }
.brand span { color: #cfd5dd; font-weight: 500; letter-spacing: .02em; padding-left: 12px; border-left: 1px solid #47505c; }
.printhead { display: none; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid #ccc; }
.printhead img { height: 36px; }
.printhead span { font-size: 10px; color: #666; }
#nav { display: flex; gap: 2px; overflow-x: auto; }
#nav a { color: #cfd5dd; padding: 8px 12px; border-radius: 6px; white-space: nowrap; }
#nav a:hover { background: #2f3741; color: #fff; text-decoration: none; }
#nav a.active { background: var(--accent); color: #fff; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* Anmeldung */
body.abgemeldet #nav, body.abgemeldet #usermenu { display: none; }
.loginbox { max-width: 400px; margin: 48px auto; padding: 28px; }
.loginbox h1 { margin: 18px 0 10px; }
.loginbox .loginlogo { width: 100%; max-width: 300px; display: block; }
.loginbox input { font-size: 15px; padding: 8px 10px; }
.loginbox .btn.primary { justify-content: center; padding: 9px; font-size: 15px; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.usermenu .uname { color: #cfd5dd; font-size: 13px; margin-right: 6px; }
.usermenu .btn.ghost { color: #cfd5dd; }
.usermenu .btn.ghost:hover { background: #2f3741; color: #fff; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead h1 { margin-right: auto; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel > .ph { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel > .ph h2 { margin: 0; margin-right: auto; }
.panel > .pb { padding: 16px; }
.panel > .pb.flush { padding: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-strong); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

/* Formulare */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=time], input[type=search], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 8px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f6b26b; outline-offset: -1px; border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { font-size: 14px; color: var(--text); }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #d06f08; }
.btn.danger { color: var(--err); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef0f3; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 10px; cursor: pointer; border-right: 1px solid var(--line-strong); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.formgrid .wide { grid-column: 1 / -1; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { background: #f8f9fb; font-weight: 600; font-size: 12px; color: var(--muted); position: sticky; top: 0; white-space: nowrap; }
table.t th.sortable { cursor: pointer; }
table.t th.sortable:hover { color: var(--text); }
table.t tbody tr:hover td { background: #fafbfc; }
table.t tr.click { cursor: pointer; }
table.t tfoot td { font-weight: 650; background: #f8f9fb; border-top: 2px solid var(--line-strong); }
table.t td.sub { color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.dot.ar { background: #d9eadf; }
.dot.we { background: #eceef1; }
table.kal { border-collapse: separate; border-spacing: 2px; margin: 8px 12px; }
table.kal th { font-size: 11px; color: var(--muted); font-weight: 500; padding: 0 2px; text-align: center; }
table.kal tbody th { text-align: right; padding-right: 8px; white-space: nowrap; }
table.kal td.kt { width: 22px; min-width: 22px; height: 22px; border-radius: 4px; background: #f6f7f9; }
table.kal td.kt.we { background: #eceef1; }
table.kal td.kt.ar { background: #d9eadf; }
table.kal td.kt.leer { background: transparent; }
table.kal td.kt.teil { opacity: .55; }
@media print { table.kal td.kt { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
table.t tr.aus td { opacity: .42; }
table.t tr.aus td:first-child { opacity: 1; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.acc { background: var(--accent-soft); color: var(--accent-text); }
.pos { color: var(--err); }
.neg { color: var(--ok); }
.bar { height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); }

.hint { background: var(--blue-soft); color: #1e3a8a; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.hint.warn { background: var(--warn-soft); color: #78350f; }

/* Wochenerfassung */
.erf { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.malist { position: sticky; top: 74px; max-height: calc(100vh - 94px); display: flex; flex-direction: column; }
.malist .pb { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.malist ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-top: 1px solid var(--line); }
.malist li a { display: flex; align-items: center; gap: 8px; padding: 7px 12px; color: var(--text); border-bottom: 1px solid #f0f1f3; }
.malist li a:hover { background: #f7f8fa; text-decoration: none; }
.malist li a.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.malist li .pnr { color: var(--muted); font-size: 12px; width: 36px; }
.malist li .h { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.malist li .h.done { color: var(--ok); font-weight: 600; }
.malist li .h.none { color: #b5bbc4; }

.sheethead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 54px; background: #fff; z-index: 5; border-radius: var(--radius) var(--radius) 0 0; }
.sheethead .who { font-size: 18px; font-weight: 650; margin-right: auto; }
.sheethead .who small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav .kw { font-weight: 600; min-width: 190px; text-align: center; }
.dirty-dot { color: var(--accent); font-size: 12px; font-weight: 600; }

.day { border-bottom: 1px solid var(--line); }
.day:last-of-type { border-bottom: 0; }
.dayhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: #f8f9fb; }
.dayhead .dn { width: 92px; font-weight: 650; }
.dayhead .dn small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.dayhead .zeiten { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.dayhead .zeiten input { width: 62px; padding: 3px 6px; text-align: center; }
.dayhead .zeiten input.invalid { border-color: var(--err); background: var(--err-soft); }
.dayhead .zeiten input.pause { width: 58px; }
.dayhead .anw { font-size: 12px; }
.dayhead .sum { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; }
.dayhead .quick { display: flex; gap: 4px; }
.day.weekend .dayhead { background: #f2f3f6; }
.day.feiertag .dayhead .dn { color: var(--accent-text); }

table.entry { width: 100%; border-collapse: collapse; }
table.entry td { padding: 3px 4px; border-bottom: 1px solid #f1f2f4; }
table.entry td:first-child { padding-left: 16px; }
table.entry td:last-child { padding-right: 12px; width: 34px; }
table.entry input, table.entry select { width: 100%; padding: 5px 7px; border-color: #dfe2e7; }
table.entry .c-za { width: 140px; }
table.entry .c-za select { color: var(--muted); }
table.entry tr.nonwork .c-za select { color: var(--text); font-weight: 600; }
table.entry .c-le { width: 34%; }
table.entry .c-pr { width: 28%; }
table.entry .c-h { width: 80px; }
table.entry .c-h input { text-align: right; }
table.entry tr.empty input, table.entry tr.empty select { background: #fcfcfd; border-style: dashed; }
table.entry tr.empty .del { visibility: hidden; }
table.entry input.invalid { border-color: var(--err); background: var(--err-soft); }
table.entry tr.nonwork td { background: #fbfaf4; }
.del { border: 0; background: transparent; color: #a0a7b1; cursor: pointer; font-size: 16px; line-height: 1; padding: 4px 6px; border-radius: 4px; }
.del:hover { color: var(--err); background: var(--err-soft); }
.sheetfoot { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); background: #f8f9fb; }
.keys { padding: 8px 16px 12px; background: #f8f9fb; border-radius: 0 0 var(--radius) var(--radius); }
.sheetbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 16px; border-bottom: 1px solid var(--line); background: #fcfcfd; min-height: 40px; }
.sheetbar select { padding: 3px 6px; font-size: 12px; }
.statusbox { display: inline-flex; gap: 8px; align-items: center; }
.badge.blau { background: var(--blue-soft); color: var(--blue); }
.st-eingereicht { color: var(--blue); font-weight: 600; }
.stm { margin-right: 5px; font-weight: 700; }
.stm.frei { color: var(--ok); }
.stm.ein { color: var(--blue); }
.stm.rf { color: var(--warn); }
.sheetfoot .total { font-size: 16px; font-weight: 650; }

/* Dialog & Toast */
dialog { border: 0; border-radius: 10px; padding: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 25, 32, .45); }
dialog .dh { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 16px; }
dialog .db { padding: 18px; max-height: 70vh; overflow-y: auto; }
dialog .df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #f8f9fb; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #20262e; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: 90vw; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

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

@media (max-width: 900px) {
  .erf { grid-template-columns: 1fr; }
  .malist { position: static; max-height: 260px; }
  main { padding: 12px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
  table.entry .c-za { width: 110px; }
}

@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .noprint, .tabs, .btn, .malist, dialog, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .panel, .kpi { box-shadow: none; border-color: #bbb; }
  table.t th { position: static; }
  .printonly { display: block !important; }
  .printhead.printonly { display: flex !important; }
  a { color: inherit; }
}
.printonly { display: none; }

/* ---------- Mein Stundenzettel (Mitarbeiter, Handy) ---------- */
body.ma #nav { display: none; }
body.ma main { padding: 10px 10px 96px; max-width: 640px; }
body.ma .brand span { display: none; }
body.ma .topbar { padding: 0 10px; gap: 8px; }
body.ma .usermenu .uname { display: none; }
.ms { display: flex; flex-direction: column; gap: 10px; }
.ms-kopf { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.ms-name { font-weight: 650; font-size: 16px; margin-bottom: 6px; }
.ms-nav { display: flex; align-items: center; gap: 8px; }
.ms-nav .btn { padding: 10px 16px; font-size: 16px; }
.ms-kw { flex: 1; text-align: center; line-height: 1.25; }
.ms-kw b { display: block; font-size: 17px; }
.ms-kw span { color: var(--muted); font-size: 13px; }
.ms-wochen { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; scrollbar-width: none; }
.ms-wochen button { flex: none; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 12px; line-height: 1.2; cursor: pointer; }
.ms-wochen button small { display: block; color: var(--muted); }
.ms-wochen button.on { border-color: var(--accent); background: var(--accent-soft); }
.ms-wochen button.st-freigegeben small { color: var(--ok); }
.ms-wochen button.st-eingereicht small { color: var(--blue); }
.ms-wochen button.st-rueckfrage small { color: var(--warn); font-weight: 700; }
.ms-tag { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.ms-tag.heute { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ms-tag.we { background: #fafafb; }
.ms-tagkopf { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 15px; }
.ms-tagsum { font-weight: 650; font-variant-numeric: tabular-nums; }
.ms-zeiten { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.ms-zeiten label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.ms-zeiten input, .ms-zeiten select { font-size: 16px; padding: 8px 6px; width: 100%; color: var(--text); }
.ms-warn { color: var(--warn); font-weight: 600; }
.ms-zeile { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 10px; margin-top: 6px; cursor: pointer; font: inherit; color: inherit; }
.ms-zeile:disabled { cursor: default; background: #fafafb; }
.ms-zeile.abw { background: #fbfaf4; border-color: #eadfbf; }
.ms-ztext { flex: 1; min-width: 0; }
.ms-ztext b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-ztext small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-zstd { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-aktionen { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ms-aktionen .btn { padding: 10px 14px; font-size: 15px; }
.ms-fuss { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line-strong); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 15; box-shadow: 0 -4px 14px rgba(16, 24, 40, .08); }
.ms-fuss .btn { padding: 12px 16px; font-size: 15px; }
.ms-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-save { margin-left: 6px; }
.ms-save.ok { color: var(--ok); }
.ms-ed .db { max-height: 72vh; }
.ms-lab { font-size: 12px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.ms-lab:first-child { margin-top: 0; }
.ms-ed input[type=search], .ms-ed #ms-bem { width: 100%; font-size: 16px; padding: 10px; margin: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip.acc { background: var(--accent-soft); border-color: #f1c58f; color: var(--accent-text); }
.ms-std { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.ms-std .btn { font-size: 22px; padding: 6px 22px; }
.ms-std input { flex: 1; font-size: 26px; font-weight: 650; text-align: center; padding: 6px; min-width: 0; }
.ms-liste { display: flex; flex-direction: column; gap: 8px; }
.ms-liste .btn { padding: 13px; font-size: 16px; justify-content: center; }
body.ma dialog { width: min(560px, calc(100vw - 16px)); }

/* Abwesenheits-Zeilen (Urlaub, Krank …): Leistung/Projekt optisch zurücknehmen */
table.entry tr.nonwork .c-le input::placeholder, table.entry tr.nonwork .c-pr input::placeholder { color: transparent; }
table.entry tr.nonwork .c-le input, table.entry tr.nonwork .c-pr input { background: transparent; border-color: #ece7d6; }
.ms-lab2 { font-size: 11px; color: var(--muted); margin: 10px 0 4px; }
body.ma .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
