:root {
  --sea: #0588a6;
  --sea-dark: #06677d;
  --sand: #f3f1e9;
  --grass: #8bb361;
  --ink: #17333c;
  --muted: #62777e;
  --line: #d8e2e5;
  --card: #ffffff;
  --danger: #b42d2d;
  --shadow: 0 14px 40px rgba(18, 55, 65, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { background: var(--sand); }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef8fa 0, var(--sand) 340px);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; }
button { touch-action: manipulation; }
img { max-width: 100%; }
.wrap { width: min(1180px, calc(100% - 28px)); margin-inline: auto; }
.topbar { padding: 20px 0 8px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 58px; height: 58px; object-fit: contain; border-radius: 14px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 4vw, 2rem); line-height: 1.05; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
.eyebrow { margin-bottom: 4px; color: var(--sea-dark); text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; }
.main-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 20px; padding: 16px 0 44px; align-items: start; }
.panel { background: rgba(255,255,255,.94); border: 1px solid rgba(216,226,229,.9); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.form-panel { position: sticky; top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field > span { font-weight: 750; font-size: .92rem; }
.field small { color: var(--muted); font-weight: 650; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  min-height: 48px;
}
input:focus, textarea:focus, select:focus { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(5,136,166,.12); }
textarea { resize: vertical; }
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 2px 0 14px; }
.upload-card { position: relative; border: 1px dashed #a8bcc2; border-radius: 15px; padding: 14px; background: #f9fcfd; cursor: pointer; overflow: hidden; }
.upload-card input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-title { display: block; font-weight: 800; }
.upload-hint { display: block; margin-top: 3px; color: var(--muted); font-size: .82rem; }
.file-preview, .current-images { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.preview-thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.btn { border: 0; border-radius: 13px; min-height: 44px; padding: 10px 14px; font-weight: 800; cursor: pointer; }
.btn-primary { background: var(--sea); color: #fff; }
.btn-primary:hover { background: var(--sea-dark); }
.btn-large { width: 100%; min-height: 52px; }
.btn-ghost { background: #edf4f5; color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.status { min-height: 1.2em; margin: 10px 0 0; color: var(--muted); font-size: .9rem; }
.status.error { color: var(--danger); }
.status.success { color: #2e6e37; }
.list-head { margin-bottom: 14px; }
.badge { min-width: 36px; text-align: center; padding: 7px 10px; border-radius: 999px; background: #e9f4f6; color: var(--sea-dark); font-weight: 850; }
.toolbar { display: grid; grid-template-columns: 1fr 145px; gap: 10px; margin-bottom: 14px; }
.cards { display: grid; gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fff; }
.card.inactive { opacity: .65; background: #f5f6f6; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.place { font-size: 1.2rem; font-weight: 900; }
.state { font-size: .74rem; padding: 5px 8px; border-radius: 999px; background: #edf7e6; color: #49712f; font-weight: 800; }
.inactive .state { background: #e7e9ea; color: #59666a; }
.readings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.reading { background: #f5fafb; border-radius: 13px; padding: 11px 12px; }
.reading-label { display: block; color: var(--muted); font-size: .75rem; font-weight: 700; }
.reading-value { display: block; margin-top: 2px; font-size: 1.08rem; font-weight: 900; }
.note { margin: 10px 0; color: #3f555c; white-space: pre-wrap; word-break: break-word; }
.photos { display: flex; gap: 8px; margin-top: 11px; }
.photos a { display: block; }
.photos img { width: 66px; height: 66px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card-actions .btn { min-height: 39px; padding: 8px 11px; font-size: .86rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.dialog { width: min(420px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(12,31,37,.45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 820px) {
  .main-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
}
@media (max-width: 520px) {
  .wrap { width: min(100% - 18px, 1180px); }
  .panel { padding: 16px; border-radius: 16px; }
  .field-grid, .upload-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .toolbar { grid-template-columns: 1fr 122px; }
  .card-actions .btn { flex: 1 1 auto; }
}

/* V2.1 Historie */
.reading-meta { margin-top: 10px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.delta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -4px 0 12px; }
.delta { border: 1px solid #d9e7da; background: #f4faf1; border-radius: 12px; padding: 9px 11px; }
.delta span { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; }
.delta strong { display: block; margin-top: 2px; font-size: .94rem; color: #456b35; }
.previous { margin: 0 0 14px; padding: 11px 12px; border-radius: 12px; background: #edf7f9; color: var(--sea-dark); font-size: .88rem; font-weight: 750; }
.status.warning { color: #8a5a00; }
.history-dialog { width: min(720px, calc(100% - 24px)); max-height: 88vh; overflow: auto; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-head h3 { margin-bottom: 0; }
.history-content { display: grid; gap: 12px; }
.history-item { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.history-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-source { color: var(--muted); font-size: .74rem; font-weight: 750; }
.history-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.history-delta { margin: 8px 0; color: #456b35; font-size: .82rem; font-weight: 750; }
input[readonly] { background: #f1f5f6; color: #536970; }
@media (max-width: 520px) {
  .delta-row, .history-values { grid-template-columns: 1fr; }
  .history-item-head { align-items: flex-start; flex-direction: column; }
}

/* V2.2 Werkstatt/Rezeption */
.brand-copy { min-width: 0; }
.round-label { margin-top: 5px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.mode-switch { display: flex; gap: 8px; padding-top: 8px; }
.mode-btn { flex: 1; max-width: 220px; min-height: 46px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.86); color: var(--ink); font-weight: 850; cursor: pointer; }
.mode-btn.active { border-color: var(--sea); background: var(--sea); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; padding-top: 12px; }
.stat { padding: 11px 13px; border: 1px solid rgba(216,226,229,.9); border-radius: 14px; background: rgba(255,255,255,.86); }
.stat span { display: block; color: var(--muted); font-size: .72rem; font-weight: 750; }
.stat strong { display: block; margin-top: 2px; font-size: 1.25rem; }
.main-grid.single-column { grid-template-columns: 1fr; }
.main-grid.single-column .list-panel { max-width: 880px; width: 100%; margin-inline: auto; }
.list-help { margin: -6px 0 14px; color: var(--muted); font-size: .88rem; }
.state.state-open { background: #fff3d9; color: #8a5a00; }
.state.state-reception { background: #e7f3ff; color: #205f93; }
.state.state-done { background: #edf7e6; color: #49712f; }
.pms-meta { margin: 8px 0 0; color: #49712f; font-size: .82rem; font-weight: 750; }
@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .mode-btn { max-width: none; }
}


/* V2.2.2 Plausibilitaetswarnung */
.meter-warning { margin: 0 0 14px; padding: 12px 14px; border: 1px solid #e1b55c; border-radius: 12px; background: #fff7e6; color: #714900; }
.meter-warning strong { display: block; margin-bottom: 4px; }
.meter-warning p { margin: 0 0 6px; font-size: .86rem; }
.meter-warning ul { margin: 0; padding-left: 20px; font-size: .86rem; font-weight: 750; }

/* V2.3 Anmeldung */
.session-box{margin-left:auto;display:flex;align-items:center;gap:.75rem;font-weight:700}.login-page{min-height:100vh;display:grid;place-items:center;background:#f3f7f8}.login-shell{width:min(440px,calc(100% - 2rem));margin:auto}.login-card{padding:2rem}.login-logo{max-width:180px;max-height:70px;object-fit:contain;margin-bottom:1rem}.login-hint{color:#566;margin-top:-.5rem;margin-bottom:1.25rem}.login-card form{display:grid;gap:1rem}.login-card select{width:100%;padding:.8rem;border:1px solid #c9d5d8;border-radius:.65rem;background:#fff}.login-card textarea{width:100%;box-sizing:border-box}.topbar .brand{display:flex;align-items:center}.mode-switch:has(> :only-child){display:none}@media(max-width:650px){.session-box span{display:none}.session-box .btn{padding:.55rem .7rem}}

.inline-meter-warning { display: block; margin-top: 2px; padding: 7px 9px; border-radius: 8px; background: #fff7e6; color: #714900 !important; font-size: .82rem !important; font-weight: 750 !important; line-height: 1.35; }
.inline-meter-warning[hidden] { display: none; }
.field input.input-warning { border-color: #c58a16; background: #fffdf7; }

/* V2.3.3 Rezeption: Hinweis bei stark abweichendem Periodenverbrauch */
.reception-warning { margin: 10px 0 12px; padding: 11px 13px; border: 1px solid #e1b55c; border-radius: 12px; background: #fff7e6; color: #714900; }
.reception-warning strong { display: block; margin-bottom: 5px; font-size: .88rem; }
.reception-warning ul { margin: 0; padding-left: 19px; font-size: .82rem; line-height: 1.4; font-weight: 700; }

/* V2.4 */
.category-field{border:0;padding:0;margin:0}.category-field legend{font-weight:800;margin-bottom:8px}.category-chips{display:flex;flex-wrap:wrap;gap:8px}.category-chips label{cursor:pointer}.category-chips input{position:absolute;opacity:0;pointer-events:none}.category-chips span,.tag{display:inline-flex;align-items:center;border:1px solid #cfd7df;border-radius:999px;padding:7px 10px;font-size:.78rem;font-weight:800;background:#fff}.category-chips input:checked+span{border-color:#1d5d86;background:#eaf4fb}.tags{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}.recheck-box{margin:10px 0;padding:11px 13px;border-radius:12px;background:#eef5ff;border:1px solid #9dbce0}.recheck-box strong{display:block;margin-bottom:4px}.btn-warning{background:#fff4d6;border-color:#d8a533;color:#654700}.correction-old{font-size:.8rem;color:#5d6873}
