:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #00305d;
  --accent-dark: #001f3d;
  --accent-soft: #e6edf4;
  --ok: #e7f6ec;
  --ok-line: #9ed5ae;
  --warn: #fff6e0;
  --warn-line: #f0cf7a;
  --err: #fdecec;
  --err-line: #eaa1a1;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: #1d5a94; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .4rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }

/* Kopfzeile */
.topbar { background: #fff; border-bottom: 3px solid var(--accent); }
.topbar-inner { display: flex; align-items: center; gap: 28px; min-height: 70px; flex-wrap: wrap; }
.brand { color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }
.brand img { height: 58px; width: auto; display: block; }
.brand-sub { font-weight: 600; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.mainnav { display: flex; gap: 4px; }
.mainnav a { color: var(--accent); padding: 7px 14px; border-radius: 6px; font-weight: 500; }
.mainnav a:hover { background: var(--accent-soft); text-decoration: none; }
.mainnav a.on { background: var(--accent); color: #fff; }
.usermenu { position: relative; margin-left: auto; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--accent);
  background: var(--accent); color: #fff; font: 700 .85rem/1 inherit; letter-spacing: .04em;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.avatar:hover, .avatar[aria-expanded=true] { box-shadow: 0 0 0 3px var(--accent-soft); }
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 220px;
  background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column;
}
.usermenu-panel[hidden] { display: none; }
.usermenu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu-panel a, .usermenu-panel button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  color: var(--text); background: none; border: 0; font: inherit; cursor: pointer;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: #f1f3f6; text-decoration: none; }
.usermenu-panel form { margin: 0; }
.usermenu-panel button { color: #b42318; }

/* Karten */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.login { margin-top: 8vh; }
.login-logo { text-align: center; margin: 4px 0 6px; }
.login-logo img { width: 240px; max-width: 80%; height: auto; }
.login-title { text-align: center; font-size: 1rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 18px; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }

/* Formulare */
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 6px; align-self: center; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid #cfd4db; border-radius: 7px;
  padding: 8px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0,48,93,.2); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 0 1 auto; }
.row > .grow { flex: 1 1 200px; }
.row > .time { flex: 0 0 96px; }
.entryform { display: flex; flex-direction: column; gap: 12px; }
.entryform .js-kunde-neu { margin-top: 6px; }
.formfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.js-dauer.bad { color: #b42318; }
.inline { display: inline; margin: 0; }
.filterbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.filterbar label { flex: 0 0 auto; }
.quick { display: flex; gap: 12px; font-size: .9rem; padding-bottom: 9px; }
.deleteform { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: 9px 16px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-light { background: #eef1f5; color: var(--text); }
.btn-light:hover { background: #e2e6ec; }
.btn-danger { background: #fff; color: #b42318; border: 1px solid var(--err-line); }
.btn-danger:hover { background: var(--err); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: #1d5a94; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.danger { color: #b42318; }

/* Tagesnavigation */
.dayhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.dayhead h1 { margin: 0 0 0 10px; }
.daypick input { width: auto; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.list tfoot th { border-bottom: 0; border-top: 2px solid var(--line); }
table.list tr.inactive td { color: var(--muted); }
table.list tr.editrow td { background: #f8fafc; }
table.list tbody.daygroup tr:last-child td { border-bottom: 1px solid #cfd4db; }
table.list tr.daysum td { font-size: .9rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; min-width: 220px; }
.actions { text-align: right; white-space: nowrap; }
.actions > * + * { margin-left: 10px; }

/* Wochenansicht */
.h1sub { font-size: 1rem; font-weight: 500; margin-left: 6px; }
table.matrix td:first-child, table.matrix th:first-child { min-width: 160px; }
table.matrix .num { min-width: 70px; }
table.matrix th a { color: inherit; }
table.matrix .today { background: var(--accent-soft); }
.strong { font-weight: 700; }
.mt { margin-top: 20px; }
.w-zeit { width: 110px; }
.w-dauer { width: 60px; }
.w-kunde { width: 230px; }

.sums { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 16px; }
.sums > div { min-width: 220px; }
.sumrow { display: flex; justify-content: space-between; gap: 20px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: #eef1f5; color: var(--muted); vertical-align: middle; }

/* Meldungen */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-ok { background: var(--ok); border-color: var(--ok-line); }
.flash-warn { background: var(--warn); border-color: var(--warn-line); }
.flash-err { background: var(--err); border-color: var(--err-line); }

.printonly { display: none; }

@media (max-width: 640px) {
  .topbar-inner { gap: 8px; padding: 8px 0; }
  .brand img { height: 38px; }
  .brand-sub { display: none; }
  .mainnav { order: 3; flex-basis: 100%; }
  .usermenu { order: 2; }
  .dayhead h1 { flex-basis: 100%; margin: 8px 0 0; font-size: 1.2rem; }
  .card { padding: 14px; }
  .row > .time { flex: 1 1 40%; }
  table.list th, table.list td { padding: 7px 6px; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .noprint, .flash { display: none !important; }
  .printonly { display: block; }
  .card { border: 0; padding: 0; }
  a { color: inherit; }
}

/* Wochenansicht: Summenzeile, Personen-Block, Tageslisten */
table.matrix tbody.totals th { border-top: 2px solid var(--line); border-bottom: 0; }
table.matrix tr.subhead th { padding-top: 22px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.daylist { table-layout: fixed; }
.w-person { width: 120px; }
.w-actions { width: 100px; }

/* Kundenakte & Projekte */
.akte h1 { margin-bottom: 4px; }
.aktegrid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 8px; }
dl.facts { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .85rem; padding-top: 1px; }
dl.facts dd { margin: 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis > div { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; display: flex; flex-direction: column; }
.kpis strong { font-size: 1.35rem; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpis span { font-size: .8rem; color: var(--muted); }
.btnrow { display: flex; gap: 8px; align-items: center; }
.statusform select { width: auto; padding: 7px 10px; }

.chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; vertical-align: middle; white-space: nowrap; }
.chip-aktiv { background: #e3f3e8; color: #1e6b3a; }
.chip-anfrage { background: #fff3d6; color: #8a5a00; }
.chip-ruhend { background: #eef1f5; color: #5b6472; }
.chip-abgeschlossen { background: #e6edf4; color: var(--accent); }
.chip-lph { background: var(--accent); color: #fff; min-width: 22px; text-align: center; margin-right: 4px; padding: 2px 7px; }
h1 .chip { font-size: .8rem; margin-left: 6px; }

table.buchungen tbody tr[data-href] { cursor: pointer; }
table.buchungen tbody tr[data-href]:hover td { background: #f6f8fb; }
tr.internrow td { background: #fafbfc; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--accent); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: #eef1f5; font-size: .75rem; text-align: center; margin-left: 2px; }
.tabs a.on .count { background: var(--accent); color: #fff; }

details.card > summary, details.subform > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker, details.subform > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { display: inline; }
details.card > summary::before, details.subform > summary::before { content: '+ '; color: var(--accent); font-weight: 700; }
details[open].card > summary::before, details[open].subform > summary::before { content: '– '; }
details.card[open] > summary { margin-bottom: 14px; }
details.subform { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
details.subform > summary { font-weight: 600; color: var(--accent); margin-bottom: 12px; }

fieldset.lphbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 16px; }
fieldset.lphbox legend { font-size: .85rem; color: var(--muted); font-weight: 500; padding: 0 4px; }
fieldset.lphbox label.check { align-self: auto; font-weight: 400; }

.entryform .js-projekt-neu { margin-top: 6px; }
.js-abrechnung { padding: 10px 12px; background: #f7f9fb; border-radius: 8px; }
.js-abrechnung[hidden] { display: none; }
select option[hidden] { display: none; }

@media (max-width: 760px) {
  .aktegrid { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 110px 1fr; }
}

/* Tagesliste auf dem Handy als Karten statt breiter Tabelle */
@media (max-width: 640px) {
  table.stack-mobile thead { display: none; }
  table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tfoot { display: block; }
  table.stack-mobile tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack-mobile tbody td { border: 0; padding: 0; min-width: 0; }
  table.stack-mobile tbody td.pre { grid-column: 1 / -1; }
  table.stack-mobile tbody td.actions { text-align: left; }
  table.stack-mobile tfoot tr { display: flex; gap: 12px; padding-top: 8px; }
  table.stack-mobile tfoot th { border: 0; padding: 0; }
}
