:root {
  --brand: #0b5cbf; --brand-2: #094a9a; --bg: #f4f6f9; --card: #fff; --text: #1b1f24; --muted: #6b7280;
  --line: #dde2e8; --weekend: #e9ebee; --weekend-text: #7a8089; --ok: #16794c; --warn: #b45309; --err: #b91c1c;
  --absence: #fff7e6;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Kopf */
.topbar { background: var(--card); border-bottom: 3px solid var(--brand); padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar .logo { height: 40px; max-width: 240px; object-fit: contain; }
.topbar .logo-ph { height: 44px; padding: 0 12px; display: flex; align-items: center; border: 2px dashed var(--line); color: var(--muted); border-radius: 6px; font-size: 13px; }
.topbar .who { margin-left: auto; text-align: right; }
.topbar .who .name { font-weight: 700; font-size: 17px; }
.topbar .who .company { color: var(--muted); font-size: 13px; }
.topbar .actions { display: flex; gap: 6px; }
nav.tabs { display: flex; gap: 4px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
nav.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }

.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--text); }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--brand-2); padding: 4px 6px; }
.btn:disabled { opacity: .55; cursor: default; }

/* Monatsauswahl */
.monthbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.monthbar h1 { margin: 0; font-size: 22px; min-width: 190px; text-align: center; }
.monthbar .spacer { flex: 1; }
.status { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: #eef2f7; color: var(--muted); }
.status.sent { background: #e7f6ee; color: var(--ok); }
.banner { background: #fff4d6; border: 1px solid #f3d27a; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }

/* Tabelle */
table.sheet { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sheet th { background: var(--brand); color: #fff; text-align: left; font-weight: 600; padding: 8px; font-size: 13px; }
.sheet td { border-top: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.sheet .c-date { width: 64px; font-weight: 600; white-space: nowrap; }
.sheet .c-wd { width: 44px; color: var(--muted); }
.sheet .c-abs { width: 230px; }
.sheet .c-total { width: 80px; text-align: right; font-weight: 700; white-space: nowrap; }
.sheet tr.weekend td, .sheet tr.holiday td { background: var(--weekend); color: var(--weekend-text); }
.sheet tr.weekend input, .sheet tr.weekend select, .sheet tr.holiday input, .sheet tr.holiday select { background: #f5f6f7; }
.sheet tr.today td.c-date { color: var(--brand-2); }
.sheet tr.today td:first-child { box-shadow: inset 4px 0 0 var(--brand-2); }
.sheet tr.has-abs td.c-abs { background: var(--absence); }
.holiday-label { font-size: 12px; color: var(--weekend-text); font-style: italic; margin-bottom: 4px; }
.entry { display: flex; gap: 6px; margin-bottom: 4px; }
.entry input.site { flex: 1; min-width: 0; }
.entry input.hours { width: 70px; text-align: right; }
.sheet input, .sheet select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; background: #fff; }
.sheet input:focus, .sheet select:focus { outline: 2px solid #9cc0ea; border-color: var(--brand-2); }
.entry .rm { flex: none; width: 22px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.entry .rm:hover { color: var(--err); }
.entry .rm-ph { width: 22px; flex: none; }
.entry .add { flex: none; width: 30px; border: 1px solid var(--line); background: #fff; color: var(--brand-2); border-radius: 6px; cursor: pointer; font-size: 18px; line-height: 1; }
.entry .add:hover { border-color: var(--brand-2); background: #eef4fb; }
.entry .add-ph { width: 30px; flex: none; }
.entry:last-child { margin-bottom: 0; }
.abs { display: flex; gap: 6px; }
.abs select { flex: 1; min-width: 0; }
.abs input { width: 64px; text-align: right; }
.saving { font-size: 11px; color: var(--muted); font-weight: 400; display: block; }
.saving.err { color: var(--err); }
.sheet tfoot td { background: #eef2f7; font-weight: 700; border-top: 2px solid var(--brand); }

/* Zusammenfassung */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.summary h3 { margin: 0 0 8px; font-size: 15px; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kv.total { font-weight: 700; border-bottom: 0; font-size: 16px; }
.submit-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 16px; }

/* Formulare */
.form { display: grid; gap: 12px; max-width: 520px; }
.form label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.form input, .form select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; color: var(--text); background: #fff; }
.form .hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
h2 { font-size: 18px; margin: 0 0 12px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; text-align: center; }
.login .logo { max-height: 70px; max-width: 240px; margin-bottom: 8px; }
.login h1 { font-size: 22px; margin: 6px 0 18px; }
.login .form { text-align: left; margin: 0 auto; }
.error { color: var(--err); font-size: 14px; min-height: 1.2em; }

table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.list th { font-size: 13px; color: var(--muted); font-weight: 600; }
.list tr.inactive td { color: var(--muted); text-decoration: line-through; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef2f7; }
.tag.ok { background: #e7f6ee; color: var(--ok); }
.tag.open { background: #fdf0e1; color: var(--warn); }

dialog { border: 0; border-radius: 12px; padding: 20px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog h2 { margin-top: 0; }
dialog .row { justify-content: flex-end; margin-top: 16px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: #1b1f24; color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); }

/* Handy: Zeilen als Karten */
@media (max-width: 760px) {
  main { padding: 10px; }
  .topbar .who { margin-left: 0; text-align: left; flex: 1; }
  .monthbar h1 { font-size: 19px; min-width: 0; flex: 1; white-space: nowrap; }
  .monthbar .spacer { display: none; }
  .monthbar .status { flex-basis: 100%; text-align: center; }
  .topbar .company { display: none; }
  .topbar .logo { height: 30px; max-width: 170px; }
  .topbar .who .name { font-size: 15px; }
  table.sheet, .sheet tbody, .sheet tr, .sheet td, .sheet tfoot { display: block; width: 100%; }
  .sheet thead { display: none; }
  table.sheet { border: 0; background: none; }
  .sheet tbody tr { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; display: grid; grid-template-columns: auto auto 1fr; padding: 8px; }
  .sheet tbody tr td { border: 0; padding: 3px 4px; background: none !important; }
  .sheet tbody tr.weekend, .sheet tbody tr.holiday { background: var(--weekend); }
  .sheet .c-date, .sheet .c-wd { width: auto; }
  .sheet .c-total { grid-column: 3; grid-row: 1; width: auto; }
  .sheet .c-sites, .sheet .c-abs { grid-column: 1 / -1; width: auto; }
  .sheet .c-abs::before { content: "Abwesenheit"; display: block; font-size: 12px; color: var(--muted); }
  .sheet tfoot tr { display: flex; justify-content: space-between; background: #eef2f7; border-radius: 10px; padding: 10px; }
  .sheet tfoot td { border: 0; background: none; }
  .sheet tfoot td:empty { display: none; }
  .list .hide-m { display: none; }
}

@media print {
  .topbar .actions, nav.tabs, .submit-row, .monthbar .btn { display: none; }
}
#toast:not(.show) { opacity: 0; pointer-events: none; }

/* Auswahl Arbeit / Urlaub / Krank */
.sheet .c-art { width: 112px; }
.sheet select.art { width: 100%; }
.sheet select.art[data-v="Urlaub"] { background: #e8f1fc; color: #0b5cbf; font-weight: 600; border-color: #9cc0ea; }
.sheet select.art[data-v="Krank"] { background: #fdecec; color: #b91c1c; font-weight: 600; border-color: #f0b4b4; }
.sheet tr.has-abs td.c-abs { background: none; }
.abs-label { color: var(--muted); font-style: italic; padding: 6px 2px; }
@media (max-width: 760px) {
  .sheet .c-art { grid-column: 1 / -1; width: auto; }
  .sheet .c-art::before { content: "Art"; display: block; font-size: 12px; color: var(--muted); }
}

.entry .rm { width: 30px; display: grid; place-items: center; border-radius: 6px; }
.entry .rm:hover { background: #fdecec; }
.entry .rm-ph { width: 30px; }

/* Baustellen-Auswahl */
.site-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.site-wrap input.site { flex: 1; min-width: 0; }
.suggest { position: absolute; z-index: 20; top: calc(100% + 2px); left: 0; right: 0; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 23, 42, .15); max-height: 280px; overflow-y: auto; }
.suggest li { padding: 8px 12px; cursor: pointer; color: var(--text); }
.suggest li.suggest-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: default; padding: 4px 12px; }
.suggest li[role=option]:hover, .suggest li.active { background: #e8f1fc; }
.site-hint { background: #fff7e0; border: 1px solid #f3d27a; border-radius: 8px; padding: 8px 10px; margin: 0 0 6px; font-size: 14px; color: var(--text); }
.site-hint .btn { margin-top: 4px; }

.dup { font-size: 12px; color: var(--warn); margin-top: 2px; }
.grow-input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-width: 0; }
