/* FM Portal – Grundstil (DBK-Farben) */
:root {
  --brand: #9B0A2E;
  --brand-dark: #6E0720;
  --brand-tint: #FBEFF2;
  --ink: #1C2430;
  --muted: #5B6573;
  --line: #DDE1E6;
  --line-strong: #C9CFD6;
  --bg: #F4F5F7;
  --white: #FFFFFF;
  --ok: #1E6B36; --ok-bg: #E6F4EA;
  --bald: #6B4E00; --bald-bg: #FFF3C4;
  --faellig: #8A3B00; --faellig-bg: #FFE6D2;
  --bad: #B42318; --bad-bg: #FDECEA;
  --grey-btn: #6C757D;
  --radius: 4px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Arial, sans-serif; font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.35rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.req { color: var(--bad); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .25rem 0; }

/* Kopfleiste */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; min-height: 56px; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand:hover { color: #fff; }
.brand img { height: 30px; width: auto; display: block; }
.topbar-user { font-size: .85rem; opacity: .9; text-align: right; }
.mainnav { background: var(--white); border-bottom: 1px solid var(--line); display: flex; gap: .25rem; padding: 0 .5rem; overflow-x: auto; align-items: center; }
.mainnav a, .mainnav button { display: inline-flex; align-items: center; gap: .35rem; padding: .8rem .75rem; color: var(--ink); text-decoration: none; font-size: .95rem; white-space: nowrap; border-bottom: 3px solid transparent; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; cursor: pointer; }
.mainnav a.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.nav-logout { margin-left: auto; }
.badge { background: var(--brand); color: #fff; border-radius: 10px; padding: 0 .45rem; font-size: .75rem; font-weight: 600; }

.wrap { max-width: 920px; margin: 0 auto; padding: 1rem; }
.guest-main { max-width: 480px; margin: 2rem auto; padding: 0 1rem; }

/* Seitenkopf */
.page-head { display: flex; align-items: center; gap: .75rem; margin: .25rem 0 1rem; flex-wrap: wrap; }
.page-head > h1, .page-head > div { flex: 1 1 auto; min-width: 0; }
.page-head.sub { margin-top: 1.5rem; }
.page-head.sub h2 { flex: 1; margin: 0; }
.back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; font-size: 1.8rem; text-decoration: none; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); flex: 0 0 auto; }
.section-title { font-size: .95rem; color: var(--muted); margin: 1.25rem 0 .5rem; }

/* Karten & Listen */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; margin-bottom: .75rem; }
.card.narrow { max-width: 480px; margin: 0 auto; }
.card.success { border-color: #9CC9A8; background: var(--ok-bg); }
.card.is-disabled { background: #ECEEF1; border-style: dashed; color: var(--muted); }
details.card > summary, details > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item { display: flex; align-items: center; gap: .75rem; background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: .75rem .9rem; color: var(--ink); text-decoration: none; min-height: 56px; }
a.list-item:hover { border-color: var(--brand); color: var(--ink); }
.li-main { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; gap: .1rem; overflow-wrap: anywhere; hyphens: auto; }
.li-main .muted { font-size: .85rem; }
.li-side { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex: 0 0 auto; }
.pos-nr { width: 38px; height: 38px; border-radius: var(--radius); background: #EEF0F2; color: #4A525D; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .9rem; flex: 0 0 auto; }
.pos-nr.nr-ok { background: var(--ok-bg); color: var(--ok); }
.pos-nr.nr-bad { background: var(--bad-bg); color: var(--bad); }
.pos-nr.nr-warn { background: var(--bald-bg); color: var(--bald); }
.star { color: #C98A00; font-size: 1.2rem; }
.star-btn { background: none; border: 1px solid var(--line); border-radius: var(--radius); width: 44px; height: 44px; font-size: 1.4rem; cursor: pointer; color: #9AA3AD; }
.star-btn.on { color: #C98A00; }
.big-link { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; padding: 1rem 1.1rem; border-radius: 6px; text-decoration: none; margin-bottom: .75rem; font-size: 1.4rem; }
.big-link:hover { color: #fff; background: var(--brand-dark); }
.big-link span span { display: block; font-size: .9rem; opacity: .9; }
.big-link strong { display: block; font-size: 1.1rem; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem 1rem; margin: 0; }
.kv3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv dt { font-size: .8rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.wa-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.wa-head h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.wa-head .chip, .li-side .chip { flex-shrink: 0; }
.note { background: var(--brand-tint); color: var(--brand-dark); border-radius: var(--radius); padding: .6rem .75rem; font-size: .9rem; margin: .5rem 0; }

/* Chips */
.chip { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: var(--radius); padding: .2rem .5rem; white-space: nowrap; }
.chip-ok { color: var(--ok); background: var(--ok-bg); }
.chip-bald { color: var(--bald); background: var(--bald-bg); }
.chip-faellig { color: var(--faellig); background: var(--faellig-bg); }
.chip-ueber { color: #fff; background: var(--bad); }
.chip-ueber::before { content: "! "; }
.chip-ueber-soft { color: var(--bad); background: var(--bad-bg); }
.chip-grau { color: #4A525D; background: #E3E7EB; }
.legend { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0; }

/* Formulare */
.form label, .label { display: block; font-size: .9rem; font-weight: 600; margin: .75rem 0 .3rem; }
.form label.check, label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .4rem 0; }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .55rem .7rem; font: inherit; color: var(--ink); background: var(--white);
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[aria-invalid=true], textarea:invalid:not(:placeholder-shown) { border-color: var(--bad); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); }
input[type=color] { width: 80px; height: 44px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
input.num { max-width: 110px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: .75rem 0; padding: .5rem .9rem .9rem; }
legend { font-weight: 600; padding: 0 .3rem; }
.field-error { color: var(--bad); font-size: .9rem; margin: .3rem 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .9rem; }
.grid5 { display: grid; grid-template-columns: 2fr 1fr 1fr 1.6fr 80px; gap: .4rem; margin-top: .4rem; }
.grid-anm { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem; margin-bottom: .5rem; }
.search { display: flex; gap: .5rem; margin-bottom: .5rem; }
.search input { flex: 1; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { color: var(--ink); border-color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-secondary { background: var(--grey-btn); border-color: var(--grey-btn); color: #fff; }
.btn-secondary:hover { background: #545B62; border-color: #545B62; color: #fff; }
.btn-danger { background: var(--white); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-dashed { border: 1.5px dashed var(--brand); color: var(--brand); background: transparent; }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn[disabled], button[disabled] { background: #C9CFD6; border-color: #C9CFD6; color: #4A525D; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; align-items: center; }
form.inline { display: inline; margin: 0; }
.links { margin-top: 1rem; font-size: .9rem; }

/* Segment-Auswahl (Radio als Buttons) */
.seg { display: flex; gap: .4rem; flex-wrap: wrap; margin: .4rem 0; }
.seg label { margin: 0; font-weight: 400; display: block; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 64px; padding: .4rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); font-weight: 600; cursor: pointer; text-align: center; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg input:checked + span { background: #4A525D; border-color: #4A525D; color: #fff; }
.seg input:checked + span.ok { background: var(--ok); border-color: var(--ok); }
.seg input:checked + span.bad { background: var(--bad); border-color: var(--bad); }
.seg-wrap span { font-weight: 500; }
.seg-wrap input:checked + span { background: var(--brand); border-color: var(--brand); }

/* Wartung */
.tabs { display: flex; gap: .3rem; overflow-x: auto; margin-bottom: .75rem; }
.tabs a { padding: .55rem .8rem; border: 1px solid var(--line); background: var(--white); border-radius: var(--radius); text-decoration: none; color: var(--ink); white-space: nowrap; font-weight: 600; font-size: .9rem; }
.tabs a.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.sticky-tabs { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .4rem 0; }
.karte h2 { margin: 1.25rem 0 .5rem; }
.zeile.is-defect { border-color: var(--bad); }
.zeile .taet { margin: 0 0 .2rem; }
.notiz { margin-top: .5rem; }
.notiz summary { font-weight: 500; color: var(--brand); font-size: .9rem; }
.notiz .when-defect { display: none; color: var(--bad); }
.zeile.is-defect .notiz .when-defect { display: inline; }
.zeile.is-defect .notiz .when-ok { display: none; }
.fotos { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.fotos figure { margin: 0; }
.fotos img { width: 110px; height: 82px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.file-btn { display: inline-flex !important; align-items: center; min-height: 44px; padding: .4rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); font-weight: 600 !important; cursor: pointer; margin-top: .5rem !important; }
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-btn.has-files { border-color: var(--ok); color: var(--ok); }
.vorjahr { background: #FFF8E6; border-color: #E8C46A; }
.sticky-foot { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); margin-top: 1rem; z-index: 5; }
.sticky-foot .btn-block { margin-top: 0; }
.progress-head { display: flex; justify-content: space-between; margin-bottom: .4rem; }
progress { width: 100%; height: 10px; accent-color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: .8rem; display: flex; flex-direction: column; }
.stat strong { font-size: 1.6rem; }
.stat span { font-size: .85rem; color: var(--muted); }
.sig-preview { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: .5rem; display: flex; justify-content: center; background: var(--white); }
.sig-preview img { max-height: 90px; max-width: 100%; }
.sig-canvas { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--white); touch-action: none; display: block; margin-top: .5rem; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; border-bottom: 1px solid var(--line); padding: .6rem 0; }

/* Meldungen */
.flash { border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: .75rem; border: 1px solid; }
.flash-ok { background: #E8F3EC; border-color: #A6D2B3; color: #1E5631; }
.flash-err { background: var(--bad-bg); border-color: #F1B4AE; color: #7A1A12; }
.flash-warn { background: #FFF3D6; border-color: #E8C46A; color: #6B4E00; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; background: var(--white); }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); }
.table.compact td, .table.compact th { padding: .35rem .5rem; font-size: .88rem; }
.table th.center, .table td.center { text-align: center; }
.table-scroll { overflow-x: auto; }
.row-bad td { background: #FDF6F5; }
.row-warn td { background: #FFF8E6; }
.row-muted td { color: var(--muted); }
td.details { font-family: ui-monospace, Consolas, monospace; font-size: .75rem; word-break: break-all; }

/* Admin */
.admin-layout { display: flex; flex-wrap: wrap; min-height: calc(100vh - 110px); }
.admin-nav { flex: 1 1 220px; max-width: 260px; background: var(--white); border-right: 1px solid var(--line); padding: 1rem .5rem; display: flex; flex-direction: column; gap: .15rem; }
.admin-nav a { padding: .6rem .8rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; font-size: .95rem; }
.admin-nav a.is-active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.admin-main { flex: 999 1 560px; min-width: 0; padding: 1.25rem; max-width: 1100px; }
.admin-main h1 { margin-bottom: 1rem; }
.zeile-edit { background: #FAFBFC; }
.logo-previews { display: flex; gap: 1rem; flex-wrap: wrap; margin: .75rem 0; }
.logo-previews > div { padding: 1rem 1.5rem; border-radius: var(--radius); border: 1px solid var(--line); }
.logo-dark { background: var(--brand); }
.logo-light { background: var(--white); }
.logo-previews img { height: 40px; width: auto; display: block; }

@media (max-width: 720px) {
  .topbar-user { display: none; }
  .mainnav a, .mainnav button { padding: .8rem .55rem; font-size: .9rem; }
  .list-item { gap: .6rem; padding: .7rem; }
  .grid2, .grid5, .grid-anm { grid-template-columns: 1fr; }
  .kv3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-nav { max-width: none; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .4rem; }
  .admin-nav a { white-space: nowrap; }
  .admin-main { padding: 1rem; }
  .table { font-size: .9rem; }
}
.ausfuehrung { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: .5rem 0; flex-wrap: wrap; }
.ausfuehrung .label { margin: 0 0 .1rem; }
.mieter-row { display: flex; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mieter-row > input, .mieter-row > span { flex: 1 1 220px; }
.mieter-row > select { flex: 0 1 260px; }
.wa-mieter { display: block; font-size: .85rem; font-weight: 500; color: var(--brand); }
