/* Ablesetool – schlichtes Layout */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #dde3e9;
  --accent: #1f6feb;
  --accent-dark: #1858c4;
  --strom: #c27c0e;
  --wasser: #1a7fb5;
  --ok-bg: #e8f6ee; --ok-line: #9fd9b5; --ok-text: #17603a;
  --err-bg: #fdecec; --err-line: #f2b1b1; --err-text: #9b1c1c;
  --warn-bg: #fff6e0; --warn-line: #f0d18a; --warn-text: #7a5300;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { margin: 0 0 10px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 40px; }

/* Kopfzeile */
.top { background: #1f2933; color: #fff; }
.top-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding-top: 10px; padding-bottom: 10px; }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: #cfd6dd; padding: 6px 10px; border-radius: 6px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }

/* Boxen */
.box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Meldungen */
.msg { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.msg.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-text); }
.msg.error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-text); }
.msg.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }

/* Formulare */
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px;
  border: 1px solid #c5ced7; border-radius: 8px; background: #fff;
  font: inherit; color: inherit;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,235,.35); border-color: var(--accent); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7785' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.check input { width: 18px; height: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.inline { display: inline; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 9px 16px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.light { background: #fff; color: var(--accent); }
.btn.light:hover { background: #eef4ff; }
.btn.danger { background: #fff; color: #b42318; border-color: #e6a19b; }
.btn.danger:hover { background: #fdecec; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: .9rem; }
.btn.block { width: 100%; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f7f9fb; font-size: .88rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.inactive td { color: var(--muted); }
tfoot td { font-weight: 700; background: #f7f9fb; }

/* Kennzeichnung Zählerart */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.tag.strom { background: #fdf1dc; color: var(--strom); }
.tag.wasser { background: #e2f1fa; color: var(--wasser); }
.tag.grey { background: #eceff2; color: var(--muted); }

/* Gebäudeliste (Kacheln) */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; color: inherit; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }

/* Ablesen: ein Block pro Zähler */
.meter { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fff; }
.meter.strom { border-left-color: var(--strom); }
.meter.wasser { border-left-color: var(--wasser); }
.meter-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; }
.meter-head strong { font-size: 1.05rem; }
.meter-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.input-unit { position: relative; }
.input-unit input { padding-right: 48px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.hint { font-size: .85rem; margin-top: 4px; min-height: 1.2em; }
.hint.bad { color: var(--err-text); font-weight: 600; }
.hint.good { color: var(--ok-text); }
.foto-link {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; vertical-align: middle;
  padding: 3px 9px; border: 1px solid var(--accent); border-radius: 6px; background: #fff;
  color: var(--accent); font-size: .82rem; font-weight: 600; line-height: 1.4;
}
.foto-link:hover { background: #eef4ff; text-decoration: none; }
.ico { width: 16px; height: 16px; vertical-align: -3px; }

/* Bildansicht */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(15, 20, 25, .97); display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; color: #fff; font-size: .95rem; }
.lightbox-actions { display: flex; align-items: center; gap: 14px; }
.lightbox-actions a { color: #cfe0ff; }
.lightbox-actions button { background: none; border: 0; color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.lightbox img { flex: 1; min-height: 0; width: 100%; object-fit: contain; padding: 0 12px 16px; cursor: zoom-out; }

/* Foto-Vorschau beim Ablesen */
.foto-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; font-size: .85rem; color: var(--ok-text); }
.link-danger { background: none; border: 0; color: var(--err-text); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
input[type=file] { width: 100%; font: inherit; font-size: .9rem; color: var(--muted); }
input[type=file]::file-selector-button {
  min-height: 40px; margin-right: 10px; padding: 7px 14px; border: 1px solid var(--accent);
  border-radius: 8px; background: #fff; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}

/* Gebäude-Zuordnung in der Benutzerverwaltung */
.geb-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 14px 0 0; }
.geb-box legend { font-weight: 600; padding: 0 6px; font-size: .95rem; }
.geb-list { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.geb-list .check, .geb-box .check { margin: 0; }

/* Login */
.login { max-width: 380px; margin: 40px auto; }

@media (max-width: 600px) {
  h1 { font-size: 1.25rem; }
  .box { padding: 14px; }
  .meter-row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
