/* Büro-Portal – BaustellenApp (HerTrixLine) */
:root {
  --navy: #0b2545; --navy2: #13315c; --tint: #1667b0; --sky: #e7f0fa;
  --green: #1f9d63; --amber: #c98507; --red: #d64545;
  --bg: #eef2f7; --card: #fff; --line: #dbe3ec; --text: #14213d; --muted: #5d6b82;
  --r: 16px; --shadow: 0 1px 2px rgb(11 37 69 / .06), 0 8px 24px rgb(11 37 69 / .06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; }
a { color: var(--tint); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% 0%, #1d4c86 0%, var(--navy) 55%, #061830 100%); }
.login-card { width: 100%; max-width: 420px; background: rgb(255 255 255 / .97); border-radius: 26px; padding: 32px;
  box-shadow: 0 30px 80px rgb(0 0 0 / .35); }
.login-card .brand { display: block; width: 240px; margin: 0 auto 18px; }
.login-card h1 { text-align: center; font-size: 22px; }
.login-card p { color: var(--muted); }
.login-card form { display: grid; gap: 14px; margin-top: 16px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 15px; letter-spacing: 1px; background: var(--sky);
  padding: 10px 12px; border-radius: 10px; text-align: center; word-break: break-all; }
.demo-hint { background: #fff4dc; color: #7a5200; border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* ---------- Grundlayout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--navy) 0%, #071a33 100%); color: #dbe6f5; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { width: 190px; margin: 4px 8px 18px; }
.side a { color: #dbe6f5; padding: 10px 12px; border-radius: 12px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side a:hover { background: rgb(255 255 255 / .08); text-decoration: none; }
.side a.on { background: rgb(255 255 255 / .16); color: #fff; }
.side .ico { width: 20px; text-align: center; }
.side .spacer { flex: 1; }
.side .who { font-size: 13px; color: #9fb3cf; padding: 8px 12px; }
.side button.link { color: #dbe6f5; }
.main { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Bausteine ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi .v { font-size: 30px; font-weight: 300; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

button, .btn { font: inherit; border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  background: var(--tint); color: #fff; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
button:disabled { opacity: .45; cursor: default; }
button.ghost, .btn.ghost { background: var(--sky); color: var(--tint); }
button.danger { background: var(--red); }
button.ok { background: var(--green); }
button.link { background: none; color: var(--tint); padding: 4px 6px; font-weight: 500; }
button.sm { padding: 5px 11px; font-size: 13px; }
button.big { padding: 12px 20px; font-size: 16px; }

label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); border: 1px solid var(--line); background: #f8fafc;
  border-radius: 10px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgb(22 103 176 / .35); border-color: var(--tint); background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: auto; }
.code-input { font-size: 26px; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.form { display: grid; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.err { color: var(--red); font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
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(--line); background: #f8fafc; position: sticky; top: 0; }
td { padding: 9px 10px; border-bottom: 1px solid #edf1f6; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f5f8fc; }
tr.sum td { font-weight: 700; background: #f8fafc; }
tr.daysum td { background: #fbfcfe; color: var(--muted); font-size: 13px; }
.tablewrap { overflow: auto; border-radius: var(--r); background: #fff; box-shadow: var(--shadow); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sky); color: var(--tint); }
.badge.green { background: #e2f5ec; color: var(--green); }
.badge.amber { background: #fff1d6; color: var(--amber); }
.badge.red { background: #fde6e6; color: var(--red); }
.badge.gray { background: #edf1f6; color: var(--muted); }
.badge.navy { background: var(--navy); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #edf1f6; color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--tint); color: #fff; }
.tabs { display: flex; gap: 4px; background: #e3e9f1; padding: 4px; border-radius: 999px; width: max-content; max-width: 100%; overflow: auto; }
.tabs button { background: none; color: var(--text); font-weight: 500; padding: 7px 14px; }
.tabs button.on { background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.list { display: grid; }
.list .item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #edf1f6; }
.list .item:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo { border-radius: 12px; overflow: hidden; background: #e7edf4; cursor: zoom-in; position: relative; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / .65)); }
.photo .pending { aspect-ratio: 4 / 3; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.sig { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; max-width: 420px; }
.sig svg { width: 100%; height: auto; display: block; }
.diary { border-left: 4px solid var(--tint); padding: 4px 0 4px 14px; }
.diary.mangel { border-color: var(--red); }
.diary.behinderung { border-color: var(--amber); }
.diary.nachtrag { border-color: #7a4fd6; }
.diary.abnahme { border-color: var(--green); }
.pre { white-space: pre-wrap; }

.big-code { font-family: ui-monospace, Menlo, monospace; font-size: 40px; letter-spacing: 6px; text-align: center; padding: 18px;
  background: var(--sky); border-radius: 14px; color: var(--navy); font-weight: 700; }

/* ---------- Dialog & Meldung ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgb(0 0 0 / .3); color: var(--text); }
dialog::backdrop { background: rgb(7 26 51 / .45); backdrop-filter: blur(3px); }
dialog .dh { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
dialog .db { padding: 20px; max-height: 70vh; overflow: auto; }
dialog .df { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafc; }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
dialog.viewer { background: #000; width: min(1200px, calc(100vw - 32px)); }
dialog.viewer img { width: 100%; max-height: 80vh; object-fit: contain; display: block; }
dialog.viewer .db { padding: 0; max-height: none; }
dialog.viewer .dh { color: #fff; border-color: #222; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(140%); background: var(--navy); color: #fff;
  padding: 11px 18px; border-radius: 999px; transition: transform .25s; z-index: 50; font-weight: 500; box-shadow: 0 10px 30px rgb(0 0 0 / .25); }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--red); }

/* ---------- Monatsausdruck ---------- */
.print-only { display: none; }
.sheet { background: #fff; padding: 28px 32px; border-radius: var(--r); box-shadow: var(--shadow); }
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--navy); padding-bottom: 12px; margin-bottom: 14px; }
.sheet .sheet-head img { width: 220px; }
.sheet table td, .sheet table th { padding: 5px 8px; font-size: 13px; }
.sheet .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.sheet .sign div { border-top: 1px solid var(--text); padding-top: 4px; font-size: 12px; color: var(--muted); }
.pagebreak { break-after: page; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .side, .head .actions, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .sheet { box-shadow: none; padding: 0; border-radius: 0; }
  .print-only { display: block; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .brand, .side .spacer, .side .who { display: none; }
  .main { padding: 18px 14px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form .two, .form .three { grid-template-columns: 1fr; }
}

/* Abstände & Kleinkram */
.mt { margin-top: 16px; }
.grow { flex: 1; }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { box-shadow: 0 0 0 2px rgb(22 103 176 / .25), var(--shadow); }
.list a.item { color: inherit; text-decoration: none; }
.list a.item:hover { background: #f5f8fc; }
.chip input { margin: 0 4px 0 0; }
button.item.chip { width: 100%; text-align: left; border-radius: 10px; margin-bottom: 4px; background: #f5f8fc; color: var(--text); font-weight: 500; }
button.item.chip.on { background: var(--tint); color: #fff; }
button.item.chip.on .muted { color: #dbe6f5; }
details summary { cursor: pointer; }
#toast { opacity: 0; transform: translateX(-50%) translateY(200%); }
#toast.show { opacity: 1; }
.list > * { min-width: 0; }
.head .actions input, .head .actions select { width: auto; }
.head .actions input[type=search] { width: 240px; }
