.anbot-edit-bar {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--vs-warn-bg);
  border: 1px solid #ead7a8;
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
}
.anbot-edit-bar[hidden] {
  display: none !important;
}
.anbot-edit-bar p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--vs-ink);
  flex: 1 1 16rem;
}

/* VistaSquare Design – Mietanbot */
:root {
  --vs-navy: #1d3570;
  --vs-navy-deep: #152650;
  --vs-coral: #eb5843;
  --vs-coral-dark: #d44733;
  --vs-beige: #f3f1ef;
  --vs-sand: #ddd7d2;
  --vs-muted: #665d56;
  --vs-ink: #1a1410;
  --vs-white: #ffffff;
  --vs-success: #1f7a4c;
  --vs-success-bg: #e8f6ee;
  --vs-danger: #b42318;
  --vs-warn: #9a6b00;
  --vs-warn-bg: #fff8eb;
  --shadow: 0 8px 32px rgba(29, 53, 112, 0.1);
  --radius: 18px;
  --radius-sm: 12px;

  /* aliases used in template */
  --bg: var(--vs-beige);
  --panel: var(--vs-white);
  --ink: var(--vs-ink);
  --muted: var(--vs-muted);
  --line: var(--vs-sand);
  --accent: var(--vs-navy);
  --accent2: #2f4f9a;
  --ok: var(--vs-success);
  --warn: var(--vs-warn);
  --danger: var(--vs-danger);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--vs-ink);
  background: linear-gradient(180deg, #f8f6f4 0%, var(--vs-beige) 120px, #ece8e4 100%);
  line-height: 1.45;
}

.muted { color: var(--vs-muted); }
.small { font-size: 0.8rem; }

.mieter-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
.mieter-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border-bottom: 1px solid var(--vs-sand);
}
.mieter-top img { height: 40px; width: auto; }
.mieter-top p { margin: 0.1rem 0 0; }
.mieter-card {
  width: min(760px, 100%);
  max-width: 100%;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 2.5rem;
}
.mieter-card h1, .mieter-card h2 {
  color: var(--vs-navy);
  margin: 1.35rem 0 0.45rem;
}
.mieter-card h2 { font-size: 1.05rem; }
.mieter-card .full { grid-column: 1 / -1; }
.mieter-guide {
  margin: 0 0 1.25rem;
  padding: 1.05rem 1.1rem 1.15rem;
  background: #fff;
  border: 1px solid var(--vs-sand);
  border-radius: 14px;
}
.mieter-guide h1 {
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
}
.mieter-guide > p {
  margin: 0 0 0.85rem;
}
.mieter-guide h2 {
  margin: 1.15rem 0 0.35rem;
  font-size: 1rem;
}
.mieter-guide ol {
  margin: 0.65rem 0 0;
  padding-left: 1.25rem;
}
.mieter-guide li {
  margin: 0.4rem 0;
  line-height: 1.45;
}
.mieter-guide-note {
  padding: 0.75rem 0.9rem;
  background: var(--vs-warn-bg);
  border: 1px solid #ead7a8;
  border-radius: 12px;
  color: #7a5400;
}
.mieter-prep {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}
.mieter-prep li {
  margin: 0.28rem 0;
}
.mieter-steps {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.mieter-steps li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.7rem;
  align-items: start;
  margin: 0;
  padding: 0.75rem 0.8rem;
  background: var(--vs-beige);
  border-radius: 12px;
}
.mieter-steps .n {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--vs-navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.05rem;
}
.mieter-steps p {
  margin: 0.2rem 0 0;
  color: var(--vs-muted);
  font-size: 0.9rem;
}
.mieter-guide-contact {
  margin: 1.1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--vs-sand);
  font-size: 0.9rem;
  color: var(--vs-muted);
}
.mieter-guide-contact a {
  color: var(--vs-navy);
  font-weight: 600;
  text-decoration: none;
}
.mieter-guide-compact ol {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
.mieter-guide-compact > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--vs-navy);
}
.mieter-guide-compact > summary::-webkit-details-marker {
  display: none;
}
.mieter-guide-compact > summary::after {
  content: "Anzeigen";
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--vs-coral);
  border: 1px solid #f0c4bc;
  background: #fff6f4;
  border-radius: 999px;
  padding: 0.18rem 0.65rem;
}
.mieter-guide-compact[open] > summary::after {
  content: "Schließen";
}
.mieter-guide-compact > summary + p {
  margin-top: 0.75rem;
}
.mieter-panel {
  background: #fff;
  border: 1px solid var(--vs-sand);
  border-radius: 14px;
  padding: 1.05rem 1.1rem 1.2rem;
  margin: 0 0 1.15rem;
}
.mieter-panel-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vs-coral);
}
.mieter-panel-title {
  margin: 0 0 0.4rem !important;
  font-size: 1.2rem !important;
}
.mieter-data .mieter-panel-title + .muted {
  margin-top: 0;
}
.mieter-docs {
  background: #eef1f8;
  border-color: #cfd7e8;
}
.mieter-docs-sub {
  margin: 1.1rem 0 0.15rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--vs-navy);
}
.mieter-upload {
  display: block;
  margin-top: 0.7rem;
  padding: 0.85rem;
  background: #fff;
  border: 1px solid #d9e0ee;
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mieter-drop-hint {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .mieter-drop-hint {
    display: block;
    margin: 0 0 0.5rem;
    padding: 0.85rem 0.75rem;
    border: 1.5px dashed #b7c2d8;
    border-radius: 10px;
    background: #f6f8fc;
    color: var(--vs-muted);
    font-size: 0.85rem;
    text-align: center;
  }
  .mieter-upload.is-drop {
    border-color: var(--vs-navy);
    background: #f4f7fd;
    box-shadow: 0 0 0 3px rgba(29, 53, 112, 0.14);
  }
  .mieter-upload.is-drop .mieter-drop-hint {
    border-color: var(--vs-navy);
    background: #e8eefc;
    color: var(--vs-navy);
    font-weight: 650;
  }
}
.mieter-upload strong {
  display: block;
  color: var(--vs-navy);
  font-size: 0.95rem;
}
.mieter-upload .muted {
  margin: 0.2rem 0 0.55rem;
}
.mieter-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 0.7rem;
  min-width: 0;
}
.mieter-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  border-radius: 10px;
  background: var(--vs-beige);
  border: 1px dashed var(--vs-sand);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mieter-thumb.has-file {
  border-style: solid;
  border-color: #9dceb3;
  background: #fff;
}
.mieter-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.mieter-thumb a {
  display: block;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.mieter-thumb-empty {
  font-size: 0.68rem;
  line-height: 1.25;
  color: var(--vs-muted);
  text-align: center;
  padding: 0.3rem;
}
.mieter-thumb-pdf {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.15rem;
  font-weight: 750;
  font-size: 0.82rem;
  color: var(--vs-navy);
  background: #f3f5fb;
}
.mieter-thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--vs-danger);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.mieter-thumb-del:hover,
.mieter-thumb-del:focus {
  background: #8f1c14;
}
.mieter-submit .btn {
  width: 100%;
  margin-top: 0.35rem;
  min-height: 48px;
  font-size: 1.05rem;
}
.mieter-submit .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.mieter-missing {
  margin: 0.35rem 0 0.65rem;
  padding-left: 1.15rem;
  color: var(--vs-danger);
  font-size: 0.88rem;
}
.mieter-missing[hidden] {
  display: none;
}
.mieter-submit-done {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  background: var(--vs-success-bg);
  color: var(--vs-success);
  border-radius: 12px;
  font-weight: 650;
}
.mieter-submit-done[hidden] {
  display: none;
}
.mieter-page .grid-2,
.mieter-page label,
.mieter-upload > div {
  min-width: 0;
  max-width: 100%;
}
.mieter-page input,
.mieter-page select,
.mieter-page textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.mieter-pick {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.15rem 0 0;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--vs-navy);
  background: var(--vs-navy);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}
.mieter-pick input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  min-height: 0 !important;
}
@media (max-width: 520px) {
  .mieter-card {
    padding: 0.85rem 0.7rem 2rem;
  }
  .mieter-panel,
  .mieter-guide {
    padding: 0.85rem 0.8rem 1rem;
  }
  .mieter-upload {
    padding: 0.7rem;
  }
  .mieter-thumb {
    width: 72px;
    height: 72px;
    flex-basis: 72px;
  }
  .mieter-page .btn-row .btn {
    flex: 1 1 100%;
  }
  .mieter-guide-compact > summary {
    font-size: 1.02rem;
  }
}

.mail-test-banner {
  background: #fff8eb;
  color: #7a5400;
  border-bottom: 1px solid #ead7a8;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 550;
}
.mail-test-banner[hidden] {
  display: none !important;
}
.mail-test-banner strong {
  letter-spacing: 0.02em;
}

.impersonate-bar {
  background: #fff8eb;
  color: #7a5400;
  border-bottom: 1px solid #f0d9a0;
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  font-size: 0.88rem;
  font-weight: 550;
}

/* Header and mobile Gesamtmiete stick together so the pill does not slide under the bar. */
.app-sticky {
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-sticky > .topbar {
  position: relative;
  top: auto;
}

/* ---------- Topbar ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid rgba(221, 215, 210, 0.9);
  box-shadow: 0 4px 20px rgba(29, 53, 112, 0.06);
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.35rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand img.brand-logo {
  height: 40px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
}

.brand strong {
  display: block;
  color: var(--vs-navy);
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.brand .muted {
  font-size: 0.78rem;
  color: var(--vs-muted);
}

.brand-kicker {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--vs-coral);
}

.topnav {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #faf9f8;
  border: 1px solid var(--vs-sand);
  color: var(--vs-muted);
}

.badge[data-ok="1"] {
  background: var(--vs-success-bg);
  border-color: #c7e7d4;
  color: var(--vs-success);
}

.badge[data-ok="0"] {
  background: var(--vs-warn-bg);
  border-color: #f0d9a0;
  color: var(--vs-warn);
}

/* Settings dropdown */
.menu { position: relative; }

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: #fff;
  color: var(--vs-ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--vs-sand);
  padding: 0.35rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-panel[hidden] { display: none !important; }

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--vs-ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
}

.menu-item:hover {
  background: #f3f6fb;
  color: var(--vs-navy);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.user-avatar {
  width: 2.35rem;
  height: 2.35rem;
  min-width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  border: 2px solid var(--vs-navy);
  border-radius: 50%;
  background: var(--vs-navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}
.user-avatar:hover,
.user-avatar[aria-expanded="true"] {
  border-color: var(--vs-coral);
  background: var(--vs-navy-deep);
}
.user-avatar-lg {
  width: 3.1rem;
  height: 3.1rem;
  min-width: 3.1rem;
  min-height: 3.1rem;
}
.user-avatar-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-avatar.has-photo .user-avatar-img {
  display: block;
}
.user-avatar.has-photo .user-avatar-initials {
  display: none;
}
.user-avatar-initials {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}
.user-avatar-lg .user-avatar-initials {
  font-size: 0.95rem;
}
.user-menu-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem 0.7rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--vs-sand);
}
.user-menu-who {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 0;
}
.user-menu-who strong {
  color: var(--vs-navy);
  font-size: 0.92rem;
}
.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  min-width: 2.35rem;
  min-height: 2.35rem;
  padding: 0;
  border: 1px solid var(--vs-sand);
  border-radius: 50%;
  background: #fff;
  color: var(--vs-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover {
  border-color: var(--vs-coral);
  color: var(--vs-coral);
  background: #fff6f4;
}
.icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1.15rem;
  padding: 1.25rem 1.35rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--vs-white);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(23, 14, 11, 0.04);
  border: 1px solid var(--vs-sand);
  padding: 1.15rem 1.2rem;
}

.panel-head h1,
.panel-head h2 {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
  color: var(--vs-navy);
  letter-spacing: -0.02em;
}

.panel-head h1 { font-size: 1.45rem; }

.row-between {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.summary-pill {
  background: var(--vs-success-bg);
  color: var(--vs-success);
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #c7e7d4;
  white-space: nowrap;
  font-size: 0.88rem;
}

/* ---------- Justimmo sidebar ---------- */
.search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.search-row input[type="search"],
.search-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.search-row .narrow { flex: 0 0 100px; }

.ji-market {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.ji-market-btn {
  appearance: none;
  border: 1px solid var(--vs-sand);
  background: #fff;
  color: var(--vs-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 2.4rem;
}
.ji-market-btn.is-on {
  border-color: var(--vs-navy);
  background: var(--vs-navy);
  color: #fff;
}
.ji-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.65rem;
  overflow: auto;
  max-height: 70vh;
  -webkit-overflow-scrolling: touch;
}

.ji-card {
  border: 1px solid var(--vs-sand);
  border-left: 3px solid var(--vs-coral);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: 0.15s border, 0.15s box-shadow;
  background: #faf9f8;
}

.ji-card:hover {
  border-color: rgba(29, 53, 112, 0.35);
  box-shadow: 0 4px 14px rgba(29, 53, 112, 0.08);
}

.ji-card strong {
  display: block;
  font-size: 0.92rem;
  color: var(--vs-navy);
}

.ji-card .meta {
  font-size: 0.78rem;
  color: var(--vs-muted);
  margin-top: 2px;
}

.ji-card .price {
  color: var(--vs-coral);
  font-weight: 700;
  margin-top: 0.3rem;
  font-size: 0.88rem;
}

.ji-load-btn {
  margin-top: 0.55rem;
  width: 100%;
  font-size: 0.85rem;
  padding: 0.5rem;
}

.info-box {
  margin-top: 0.9rem;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: #f3f6fb;
  border: 1px solid #d5e0f0;
  font-size: 0.82rem;
  color: var(--vs-muted);
  line-height: 1.45;
}

.info-box strong {
  color: var(--vs-navy);
  display: block;
  margin-bottom: 0.35rem;
}

.info-box p { margin: 0.5rem 0 0; }

.info-box.warn {
  background: var(--vs-warn-bg);
  border-color: #f0d9a0;
  color: #5c4a1f;
}

.info-box.warn strong { color: var(--vs-warn); }

/* ---------- Form ---------- */
fieldset {
  border: 1px solid var(--vs-sand);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  padding: 0.95rem 1rem 1.05rem;
  background: #faf9f8;
}

legend {
  font-weight: 700;
  color: var(--vs-navy);
  padding: 0 0.5rem;
  font-size: 0.92rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--vs-navy);
}
.check-inline input {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
}

@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--vs-navy);
}

label.full,
.full { grid-column: 1 / -1; }

label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--vs-ink);
  min-height: 2.4rem;
}

.optin-box {
  grid-column: 1 / -1;
  margin-top: 0.15rem;
  padding: 0.85rem 0.95rem 0.95rem;
  border: 1px dashed rgba(29, 53, 112, 0.28);
  border-radius: var(--radius-sm);
  background: #fff;
}

.optin-box .check {
  font-weight: 650;
  color: var(--vs-navy);
}

.optin-box[hidden],
#parkplatzFields[hidden] {
  display: none !important;
}

#parkplatzFields {
  margin-top: 0.65rem;
}

#parkplatzFields .grid-2 {
  margin-top: 0.15rem;
}

input,
select,
textarea {
  font: inherit;
  font-weight: 400;
  color: var(--vs-ink);
  border: 1px solid var(--vs-sand);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: #faf9f8;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s, background 0.15s;
}

input:focus,
select:focus {
  border-color: rgba(29, 53, 112, 0.45);
  box-shadow: 0 0 0 3px rgba(29, 53, 112, 0.12);
  background: #fff;
}

input.auto { background: #f7f8fa; }

input.overridden {
  border-color: #e0b84a !important;
  background: #fffdf5 !important;
}

.tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: #eef2f9;
  color: var(--vs-navy);
  padding: 1px 6px;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 3px;
  letter-spacing: 0.01em;
}



.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.65rem 1.05rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s, border-color 0.15s;
  background: #f0ece8;
  color: var(--vs-navy);
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:hover { filter: brightness(0.98); }

.btn.primary,
.btn-primary {
  background: var(--vs-navy);
  color: #fff;
  border-color: var(--vs-navy);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--vs-navy) 28%, transparent);
}

.btn.primary:hover,
.btn-primary:hover:not(:disabled) {
  background: var(--vs-navy-deep);
  filter: none;
}

.btn.accent,
.btn-accent {
  background: var(--vs-coral);
  color: #fff;
  border-color: var(--vs-coral);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--vs-coral) 32%, transparent);
}

.btn.accent:hover,
.btn-accent:hover:not(:disabled) {
  background: var(--vs-coral-dark);
  filter: none;
}

.btn.ghost,
.btn-ghost {
  background: transparent;
  color: var(--vs-navy);
  border: 1px solid var(--vs-sand);
}

.btn.ghost:hover,
.btn-ghost:hover:not(:disabled) {
  background: #fff;
  filter: none;
}

.btn.large {
  padding: 0.8rem 1.25rem;
  font-size: 1rem;
}

.btn.danger {
  background: #fff0ed;
  color: var(--vs-danger);
  border: 1px solid #f0c4be;
}

.btn.danger:hover {
  background: #ffe4df;
  filter: none;
}

.btn-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-row .btn { margin: 0; }

.status-line {
  min-height: 1.2em;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.status-line.ok { color: var(--vs-success); }
.status-line.err { color: var(--vs-danger); }
.status-line.warn { color: var(--vs-warn); }
.status-line .btn {
  margin-left: 0.45rem;
  vertical-align: middle;
}

/* ---------- PDF Kosten-Import ---------- */
.pdf-import-box {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(29, 53, 112, 0.28);
  background: linear-gradient(180deg, #f7f9fc 0%, #f3f1ef 100%);
}

.pdf-import-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.65rem;
}

.pdf-import-head strong {
  color: var(--vs-navy);
  font-size: 0.95rem;
}

.pdf-import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.pdf-import-row input[type="file"] {
  flex: 1 1 180px;
  min-width: 0;
  font-size: 0.85rem;
}

.pdf-import-check {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  margin: 0.55rem 0 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--vs-muted);
  cursor: pointer;
  width: 100%;
}

.pdf-import-check input {
  width: auto;
  margin: 0;
}

.pdf-import-preview {
  margin-top: 0.65rem;
  overflow-x: auto;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #fff;
}

.pdf-import-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.pdf-import-preview th,
.pdf-import-preview td {
  padding: 0.4rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--vs-sand);
}

.pdf-import-preview th {
  background: #f0f3f9;
  color: var(--vs-navy);
  font-weight: 600;
}

.pdf-import-preview tr:last-child td {
  border-bottom: none;
}

.pdf-import-preview .miss {
  color: var(--vs-warn);
  font-style: italic;
}

.pdf-import-preview .ok-map {
  color: var(--vs-success);
  font-weight: 600;
}

/* ---------- Provision ---------- */
.provision-fieldset {
  background: #fff;
  border-color: rgba(29, 53, 112, 0.15);
}

.provision-intro {
  margin: 0 0 0.75rem;
  line-height: 1.45;
}

.provision-calc { margin-top: 0.25rem; }

.provision-summary {
  margin-top: 0.85rem;
  padding: 0.7rem 0.95rem;
  border-radius: 12px;
  background: var(--vs-success-bg);
  color: var(--vs-success);
  font-weight: 700;
  border: 1px solid #c7e7d4;
  font-size: 0.88rem;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 20, 16, 0.4);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}

.modal[hidden] { display: none !important; }

.modal-card {
  background: #fff;
  border-radius: 20px;
  padding: 1.4rem 1.35rem;
  width: min(480px, 100%);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--vs-sand);
}

.modal-card.modal-wide {
  width: min(820px, 100%);
  max-width: 100%;
}

.modal-card.modal-xl {
  width: min(1600px, calc(100vw - 2.5rem));
  max-height: calc(100vh - 2.5rem);
}

#historyModal {
  padding: 1.15rem 1.35rem;
  place-items: stretch center;
  align-items: center;
}

#historyModal .modal-card {
  width: min(1600px, calc(100vw - 2.5rem));
  max-height: calc(100vh - 2.5rem);
  height: calc(100vh - 2.5rem);
  overflow: hidden;
}

#historyModal #historyBody {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 10rem;
  padding-right: 0.15rem;
}

.modal-card h3 {
  margin: 0;
  color: var(--vs-navy);
  font-size: 1.2rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-head h3 {
  margin: 0;
}

.modal-head .btn {
  flex-shrink: 0;
  width: auto;
  margin: 0;
}

.result-groups {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-group {
  padding: 0.75rem 0.85rem;
  background: #f7f5f3;
  border: 1px solid var(--vs-sand);
  border-radius: 14px;
}

.result-group h4 {
  margin: 0 0 0.5rem;
  color: var(--vs-navy);
  font-size: 0.88rem;
}

.result-group .btn-row {
  margin-top: 0;
}

.settings-h {
  margin: 1.1rem 0 0.4rem;
  color: var(--vs-navy);
  font-size: 1rem;
}

.signer-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
}

.signer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #faf9f8;
}

.signer-row span {
  min-width: 0;
  font-size: 0.88rem;
}

.signer-row .btn {
  flex-shrink: 0;
  width: auto;
}

.mail-test-box {
  margin: 0.7rem 0 0.35rem;
  padding: 0.75rem 0.9rem 0.85rem;
  border: 1px solid var(--vs-sand);
  background: #faf9f8;
  border-radius: 10px;
}
.mail-test-box.is-on {
  border-color: #ead7a8;
  background: var(--vs-warn-bg);
}
.mail-test-box > label:not(.check) {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 0.45rem;
}
#mailTestTo {
  width: 100%;
  min-height: 2.85rem;
  font-size: 1rem;
  box-sizing: border-box;
}
.mail-test-box .muted {
  margin: 0.4rem 0 0;
}

.mail-tpl-legend {
  margin: 0.55rem 0 0.85rem;
  padding: 0.7rem 0.85rem 0.75rem;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #faf9f8;
}
.mail-tpl-legend > strong {
  display: block;
  font-size: 0.82rem;
  color: var(--vs-navy);
  margin-bottom: 0.15rem;
}
.mail-tpl-legend > p {
  margin: 0 0 0.55rem;
}
.mail-tpl-legend dl {
  margin: 0;
  display: grid;
  gap: 0.28rem 0.75rem;
}
.mail-tpl-legend dl > div {
  display: grid;
  grid-template-columns: 6.2rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.82rem;
}
.mail-tpl-legend dt {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  color: var(--vs-navy);
}
.mail-tpl-legend dd {
  margin: 0;
  color: var(--vs-muted);
}

.mail-tpl-design {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.85rem 1.1rem;
  align-items: end;
  margin: 0.35rem 0 0.75rem;
}
.mail-tpl-design input[type="color"] {
  width: 3.4rem;
  height: 2.4rem;
  padding: 0.15rem;
  cursor: pointer;
}
.mail-tpl-text-colors {
  margin: 0.15rem 0 0.85rem;
}
.mail-tpl-text-colors > strong {
  display: block;
  font-size: 0.82rem;
  color: var(--vs-navy);
  margin-bottom: 0.1rem;
}
.mail-tpl-text-colors > p {
  margin: 0 0 0.45rem;
}
.mail-tpl-text-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.2rem, 1fr));
  gap: 0.55rem 0.75rem;
}
.mail-tpl-text-color-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}
.mail-tpl-text-color-grid input[type="color"] {
  width: 3.4rem;
  height: 2.4rem;
  padding: 0.15rem;
  cursor: pointer;
}
.mail-tpl-preview {
  min-height: 3.2rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.look-preview {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 4.2rem;
  margin: 0.2rem 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--vs-sand);
  border-radius: 14px;
  background: #fff;
}
.look-preview img {
  height: 42px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}
.look-preview strong {
  color: var(--vs-navy);
}
.look-colors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.35rem 0 0.9rem;
}
.look-colors input[type="color"] {
  width: 100%;
  height: 3.4rem;
  padding: 0.2rem;
  border-radius: 12px;
  cursor: pointer;
}
.mail-tpl-preview img {
  height: 36px;
  width: auto;
  max-width: 180px;
  display: block;
}
#invLogoPreview img {
  height: 48px;
  max-width: 220px;
}
@media (max-width: 700px) {
  .mail-tpl-design { grid-template-columns: 1fr 1fr; }
  .mail-tpl-preview { grid-column: 1 / -1; }
}

.mail-tpl-live {
  margin: 1rem 0 0.35rem;
  border: 1px solid var(--vs-sand);
  border-radius: 12px;
  overflow: hidden;
  background: #f3f1ef;
}
.mail-tpl-live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  padding: 0.55rem 0.8rem;
  background: #fff;
  border-bottom: 1px solid var(--vs-sand);
}
.mail-tpl-live-bar select {
  width: auto;
  min-width: 13rem;
  padding: 0.35rem 0.55rem;
  min-height: 2.2rem;
}
.mail-tpl-live-subject {
  margin: 0;
  padding: 0.4rem 0.8rem 0.5rem;
  font-size: 0.8rem;
  color: var(--vs-muted);
  background: #fff;
  border-bottom: 1px solid var(--vs-sand);
  word-break: break-word;
}
.mail-tpl-kind-preview {
  margin-top: 0.85rem;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  overflow: hidden;
  background: #f3f1ef;
}
.mail-tpl-kind-subject {
  margin: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  color: var(--vs-muted);
  background: #fff;
  border-bottom: 1px solid var(--vs-sand);
}
.mail-tpl-kind-frame {
  display: block;
  width: 100%;
  height: 22rem;
  border: 0;
  background: #f3f1ef;
}

.mail-sent-meta {
  margin: 0.45rem 0 0.55rem;
  font-size: 0.82rem;
  color: var(--vs-muted);
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-line;
}
.mail-sent-frame {
  display: block;
  width: 100%;
  height: min(28rem, 55vh);
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #fff;
}

.mail-cat-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.15rem 0 0;
}

.mail-cat {
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #faf9f8;
  padding: 0;
  margin: 0;
}

.mail-cat > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.55rem 0.8rem;
  font-weight: 700;
  color: var(--vs-navy);
}

.mail-cat > summary::-webkit-details-marker { display: none; }

.mail-cat > summary::after {
  content: "▸";
  float: right;
  color: var(--vs-muted);
}

.mail-cat[open] > summary::after {
  content: "▾";
}

.mail-cat-body {
  padding: 0.95rem 0.9rem 1.05rem;
  border-top: 1px solid var(--vs-sand);
}

.history-contact-select {
  max-width: 100%;
  min-width: 12rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
}

.modal-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.modal-actions a.btn {
  text-decoration: none;
  display: inline-block;
}

/* Abgeber */
.abgeber-form {
  margin: 0.4rem 0 0.75rem;
  padding: 0.95rem;
  background: #faf9f8;
  border: 1px solid var(--vs-sand);
  border-radius: var(--radius-sm);
}

.abgeber-form .btn-row {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.nr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.nr-preview {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  color: var(--vs-navy);
  background: #fff;
  border: 1px dashed var(--vs-sand);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin-top: 0.55rem;
}

.nr-next {
  margin-top: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: #fff;
  border: 1px solid var(--vs-navy);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nr-next strong {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  color: var(--vs-navy);
  letter-spacing: 0.02em;
}

#nrApNextWarn,
#nrPrNextWarn {
  margin-top: 0.35rem;
  font-weight: 600;
}

.nr-pay {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--vs-sand);
}

.nr-pay select,
#nrApPayDaysVal,
#nrPrPayDaysVal {
  min-width: 8rem;
  padding: 0.35rem 0.55rem;
}

@media (max-width: 720px) {
  .nr-grid { grid-template-columns: 1fr; }
}

.abgeber-form .btn-row .btn {
  width: auto;
  display: inline-flex;
}

/* Liste: 3 Spalten nebeneinander */
.abgeber-list-head,
.abgeber-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 180px;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
}

.abgeber-list-head {
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vs-muted);
  border-bottom: 1px solid var(--vs-sand);
  margin-top: 0.35rem;
}

.abgeber-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.7rem;
  align-items: center;
  margin: 0.35rem 0 0.15rem;
}
.abgeber-toolbar input[type="search"] {
  flex: 1 1 14rem;
  min-width: 10rem;
  margin: 0;
}
.abgeber-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.abgeber-filter {
  appearance: none;
  border: 1px solid var(--vs-sand);
  background: #fff;
  color: var(--vs-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}
.abgeber-filter.is-on {
  border-color: var(--vs-navy);
  background: var(--vs-navy);
  color: #fff;
}
.abgeber-group-h {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.7rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vs-navy);
}
.abgeber-group-h:first-child {
  margin-top: 0.15rem;
}
.abg-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
  background: #eef2f9;
  color: var(--vs-navy);
}
.abg-badge-wa { background: var(--vs-navy); color: #fff; }
.abg-badge-prowert { background: var(--vs-coral); color: #fff; }
.abg-badge-synro { background: var(--vs-success); color: #fff; }
.abg-badge-rwz { background: #9a6b00; color: #fff; }
.abg-badge-hv { background: #eef2f9; color: var(--vs-navy); }
.abg-badge-modell { background: var(--vs-sand); color: var(--vs-muted); }
.abg-badge-x0 { background: #2f4f9a; color: #fff; }
.abg-badge-x1 { background: #0f766e; color: #fff; }
.abg-badge-x2 { background: #7c3aed; color: #fff; }
.abg-badge-x3 { background: #b45309; color: #fff; }
.abg-badge-x4 { background: #be185d; color: #fff; }

.abgeber-badges-box {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--vs-sand);
  flex-shrink: 0;
}
.abgeber-badges-box > summary {
  cursor: pointer;
  color: var(--vs-muted);
  font-size: 0.8rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}
.abgeber-badges-box > summary::-webkit-details-marker { display: none; }
.abgeber-badges-box > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-top: -0.1rem;
}
.abgeber-badges-box[open] > summary {
  color: var(--vs-navy);
}
.abgeber-badges-box[open] > summary::before {
  transform: rotate(45deg);
  margin-top: -0.2rem;
}
.abgeber-badge-admin {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.abg-badge-row {
  display: grid;
  grid-template-columns: minmax(5.5rem, auto) auto minmax(10rem, 1fr) auto auto;
  gap: 0.5rem 0.65rem;
  align-items: center;
  padding: 0.45rem 0.55rem;
  background: #faf9f8;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
}
.abg-badge-row .muted {
  font-size: 0.78rem;
  white-space: nowrap;
}
.abg-badge-row input[type="email"] {
  margin: 0;
  min-width: 0;
}
.abgeber-badge-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}
.abgeber-badge-add input {
  flex: 1 1 10rem;
  margin: 0;
}
@media (max-width: 720px) {
  .abg-badge-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .abg-badge-row input[type="email"] {
    grid-column: 1 / -1;
  }
}
.abgeber-row-titlewrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.abgeber-chip.hk-open {
  background: var(--vs-warn-bg);
  color: var(--vs-warn);
}

#abgeberModal .modal-card {
  max-height: 92vh;
}
#abgeberModal .abgeber-list-head {
  position: sticky;
  top: -0.15rem;
  z-index: 2;
  background: #fff;
}
.abgeber-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.5rem;
  flex: 0 0 auto;
}

.abgeber-row {
  padding: 0.7rem 0.75rem;
  background: #faf9f8;
  border: 1px solid var(--vs-sand);
  border-radius: 12px;
}

.abgeber-item {
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.abgeber-item.editing {
  cursor: default;
}

.abgeber-item.editing .abgeber-row {
  background: #fff;
  border-color: var(--vs-navy);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.inline-edit-panel {
  padding: 0.85rem 0.95rem 0.95rem;
  background: #fff;
  border: 1px solid var(--vs-navy);
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.inline-edit-panel .abgeber-form {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.abgeber-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.abgeber-row-title {
  color: var(--vs-navy);
  font-size: 0.95rem;
  line-height: 1.25;
}

.abgeber-row-detail {
  font-size: 0.78rem;
  color: var(--vs-muted);
  font-weight: 400;
  line-height: 1.3;
}

button.abgeber-missing {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0.1rem 0 0;
  text-align: left;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--vs-warn);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.abgeber-row-meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.abgeber-chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #eef2f9;
  color: var(--vs-navy);
  white-space: nowrap;
}

.abgeber-chip.hk-on {
  background: #fff0ed;
  color: var(--vs-coral);
}

.abgeber-chip.hk-off {
  background: #f0ece8;
  color: var(--vs-muted);
}

.abgeber-row-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-items: center;
}

#usersModal .abgeber-list-head,
#usersModal .abgeber-row {
  grid-template-columns: minmax(0, 1.2fr) 110px minmax(210px, auto);
}
#usersModal .abgeber-row-actions {
  flex-wrap: wrap;
}

.history-section {
  margin-top: 1.1rem;
}

.history-section h4 {
  margin: 0 0 0.45rem;
  color: var(--vs-navy);
  font-size: 0.92rem;
}

.history-object {
  padding: 0.95rem 1rem 1.05rem;
  background: #f7f5f3;
  border: 1px solid var(--vs-sand);
  border-radius: 14px;
  min-width: 0;
  max-width: 100%;
}

.history-object h4 {
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.history-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.history-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

.history-card {
  background: #fff;
  border: 1px solid var(--vs-sand);
  border-radius: 12px;
  padding: 0.95rem 1rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
  max-width: 100%;
}

.history-card-head {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) auto;
  grid-template-areas:
    "top titles tools"
    "top details details";
  align-items: start;
  column-gap: 0.7rem;
  row-gap: 0.4rem;
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.history-card-top {
  grid-area: top;
  align-self: start;
  width: 4.6rem;
  min-height: 1.35em;
  padding-top: 0.12rem;
  font-weight: 700;
  color: var(--vs-navy);
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-card-top.is-empty,
.history-card-title.is-empty,
.history-card-user.is-empty {
  color: var(--vs-muted);
  font-weight: 500;
}

.history-card-tools {
  grid-area: tools;
  margin-left: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  justify-self: end;
  align-self: start;
}

.history-card-del {
  margin-left: 0;
}

.history-card-toggle {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--vs-sand);
  border-radius: 8px;
  background: #fff;
  color: var(--vs-navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.history-card-toggle::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -0.15rem;
  transition: transform 0.15s ease;
}

.history-card.is-collapsed .history-card-toggle::before {
  transform: rotate(-45deg);
  margin-top: 0;
}

.history-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-top: 0.15rem;
}

.history-card.is-collapsed .history-card-body {
  display: none;
}

.history-search-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.65rem 0 0.15rem;
}

.history-search-row input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.75rem;
}

.history-sort {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: 0 0 auto;
  width: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--vs-muted);
  white-space: nowrap;
}

.history-sort select {
  min-width: 11rem;
  width: auto;
  height: 2.75rem;
  padding: 0 0.75rem;
}

.history-card-titles {
  grid-area: titles;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.history-card-details {
  grid-area: details;
  display: grid;
  grid-template-columns: 7rem 7.6rem 9.6rem 1.7rem auto;
  column-gap: 0.55rem;
  row-gap: 0.3rem;
  align-items: center;
  min-width: 0;
}

.history-card-head .typ-chip {
  width: 7rem;
  max-width: 7rem;
  min-height: 1.55rem;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.history-card-when {
  width: 7.6rem;
  max-width: 7.6rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.08rem;
  min-height: 2.05rem;
}

.history-card-user {
  font-size: 0.72rem;
  color: var(--vs-muted);
  width: 100%;
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.history-card-tenant {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 9.6rem;
  max-width: 9.6rem;
  min-height: 1.55rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.history-card-head .hist-sent-flags {
  justify-self: start;
}

.history-upload {
  position: relative;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: help;
}
.history-upload.is-on {
  background: var(--vs-success-bg);
  color: var(--vs-success);
}
.history-upload.is-off {
  background: #eceff1;
  color: #9aa3a8;
}
.history-upload svg {
  width: 0.95rem;
  height: 0.95rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.history-upload .history-tip {
  left: 50%;
  transform: translateX(-50%);
  min-width: 14rem;
  text-align: left;
  white-space: pre-wrap;
}
.history-upload:hover .history-tip,
.history-upload:focus-within .history-tip {
  display: block;
}

.history-card-object {
  color: var(--vs-navy);
  font-size: 0.82rem;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: break-word;
}

.history-card-title {
  color: var(--vs-navy);
  font-size: 0.95rem;
  max-width: 100%;
  min-height: 1.35em;
  overflow-wrap: break-word;
}

.history-card-meta {
  color: var(--vs-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.result-meta #resultMsg {
  margin: 0;
}

.typ-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #e8eef8;
  color: var(--vs-navy);
  white-space: nowrap;
}

.typ-chip.typ-geschaeftslokal {
  background: #fff0e6;
  color: #9a4a12;
}

.typ-chip.typ-tiefgarage {
  background: #eceff1;
  color: #37474f;
}

.history-chip {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.history-chip.ok {
  background: var(--vs-success-bg);
  color: var(--vs-success);
}

.history-chip.warn {
  background: var(--vs-warn-bg);
  color: var(--vs-warn);
}

.history-chip.info {
  background: #e8eef8;
  color: var(--vs-navy);
}

.history-edited {
  position: relative;
  display: inline-flex;
  cursor: help;
}

.history-edited .history-chip {
  max-width: 16rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-tip {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 16rem;
  max-width: min(28rem, 80vw);
  padding: 0.65rem 0.75rem;
  background: #1a1410;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: pre-wrap;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.history-edited:hover .history-tip,
.history-edited:focus-within .history-tip,
.history-created:hover .history-tip,
.history-created:focus-within .history-tip {
  display: block;
}

.history-created {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
  cursor: help;
}
.history-created .history-card-meta {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.history-card-when .history-edited {
  max-width: 100%;
}
.history-card-when .history-edited .history-chip {
  max-width: 100%;
}

.history-card-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 0.55rem 0.75rem;
  align-items: start;
}

.history-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vs-muted);
  padding-top: 0.4rem;
}

.history-card-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.history-card-btns .hist-anbot-edit {
  margin-left: auto;
}

.history-sent {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--vs-muted);
  line-height: 1.4;
}

.history-block {
  padding: 0.8rem 0.9rem 0.85rem;
  border: 1px solid var(--vs-sand);
  border-radius: 10px;
  background: #faf9f8;
}

.history-block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--vs-navy);
  margin-bottom: 0.55rem;
}

.sent-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  flex: 0 0 auto;
  position: relative;
  box-sizing: border-box;
}
.sent-mark::after {
  content: "";
  display: block;
  width: 0.26rem;
  height: 0.46rem;
  margin: -0.12rem 0 0 0.02rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}
.sent-mark.is-sent {
  color: #fff;
  background: var(--vs-success);
}
.sent-mark.is-open {
  color: #c4bbb4;
  background: #efecea;
  border: 1px solid var(--vs-sand);
}

.hist-sent-flags {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1;
}
.hist-sent-flag {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.28rem;
  height: 1.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--vs-muted);
  line-height: 1;
  cursor: help;
}
.hist-sent-flag .history-tip {
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
  white-space: nowrap;
  text-align: center;
}
.hist-sent-flag:hover .history-tip,
.hist-sent-flag:focus-within .history-tip {
  display: block;
}
.hist-sent-flag.is-sent {
  color: var(--vs-success);
}
.hist-sent-flag .sent-mark {
  width: 1.05rem;
  height: 1.05rem;
}
.hist-sent-flag-lab {
  display: inline-block;
  width: 1.35em;
  line-height: 1;
}

label.check.hist-bh {
  min-height: 0;
  font-size: 0.78rem;
  gap: 0.35rem;
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .history-card-head {
    grid-template-columns: 4.6rem minmax(0, 1fr);
    grid-template-areas:
      "top titles"
      "top details"
      "tools tools";
  }
  .history-card-tools {
    justify-self: stretch;
    justify-content: flex-end;
    width: 100%;
  }
  .history-card-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
  }
  .history-card-head .typ-chip {
    flex: 0 0 7rem;
    width: 7rem;
    max-width: 7rem;
  }
  .history-card-when {
    flex: 0 0 7.6rem;
    width: 7.6rem;
  }
  .history-card-tenant {
    flex: 0 0 9.6rem;
    width: 9.6rem;
  }
  .history-card-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .history-card-label { padding-top: 0; }
}

.history-empty {
  margin: 0.35rem 0 0;
  color: var(--vs-muted);
  font-size: 0.88rem;
}

.abgeber-row-actions .btn,
.btn.btn-sm {
  width: auto !important;
  display: inline-flex !important;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .abgeber-list-head { display: none; }
  .history-row,
  .abgeber-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .abgeber-row-actions { justify-content: flex-start; }
}

/* Footer accent strip under page */
body::after {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--vs-navy) 0%, var(--vs-coral) 100%);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  pointer-events: none;
}

/* Desktop: Justimmo details always open look */
.mobile-collapse {
  border: none;
}
.mobile-collapse > summary {
  list-style: none;
  cursor: default;
}
.mobile-collapse > summary::-webkit-details-marker { display: none; }
.mobile-collapse-sum {
  display: none;
}
.ji-hint { margin: 0 0 0.65rem; }

.summary-bar {
  display: none;
}

.nav-toggle {
  display: none;
}

/* ---------- Mobile / tablet ---------- */
@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
    overflow-x: clip;
  }

  body::after {
    height: 3px;
  }

  .topbar {
    padding: 0.55rem 0.85rem;
    padding-top: max(0.55rem, env(safe-area-inset-top));
    gap: 0.5rem;
    flex-wrap: nowrap;
    align-items: center;
  }

  .brand { gap: 0.55rem; min-width: 0; flex: 1; }
  .brand img.brand-logo { height: 32px; max-width: 42vw; object-fit: contain; object-position: left center; }
  .brand-text { min-width: 0; flex: 1 1 auto; }
  .brand-text strong {
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub { display: none; }
  .brand-kicker { font-size: 0.62rem; }

  /* Hamburger */
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--vs-sand);
    border-radius: 12px;
    background: #faf9f8;
    cursor: pointer;
    flex-shrink: 0;
  }
  .nav-toggle span {
    display: block;
    height: 2px;
    background: var(--vs-navy);
    border-radius: 2px;
    transition: 0.2s;
  }
  body.nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .topnav {
    display: none;
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: calc(100% + 6px);
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid var(--vs-sand);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 50;
  }
  .topbar { position: sticky; }
  body.nav-open .topnav {
    display: flex;
  }
  .topnav .btn,
  .topnav .badge,
  .topnav a.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    min-height: 44px;
  }
  .topnav .menu { display: contents; }
  .topnav .user-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    width: 100%;
    gap: 0.35rem 0.55rem;
    padding-top: 0.15rem;
  }
  .topnav #btnSettingsMenu {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  .topnav #btnLogout {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
  .topnav .user-avatar,
  .topnav .icon-btn {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
  .topnav .user-menu-head .user-avatar {
    width: 3.1rem;
    height: 3.1rem;
    min-width: 3.1rem;
    min-height: 3.1rem;
  }
  .topnav .menu-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static;
    width: auto;
    min-width: 0;
    max-width: 100%;
    box-shadow: none;
    border: 1px solid var(--vs-sand);
    margin-top: 0.15rem;
  }
  .topnav .user-menu-head,
  .topnav .user-menu-who {
    min-width: 0;
  }
  .topnav .user-menu-who { flex: 1; }
  .topnav .user-menu-who strong { overflow-wrap: anywhere; }
  .topnav .user-menu-who .btn {
    width: auto;
    align-self: flex-start;
    min-height: 36px;
  }

  /* Sticky Gesamtmiete under header */
  .summary-bar {
    display: flex;
    justify-content: center;
    padding: 0.45rem 0.85rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--vs-sand);
    position: static;
    top: auto;
    z-index: 1;
  }
  .summary-pill {
    white-space: normal;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.3;
    max-width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    padding: 0.75rem 0.75rem 1rem;
  }

  .panel {
    padding: 0.9rem 0.85rem;
    border-radius: 14px;
  }

  .panel-head h1 { font-size: 1.2rem; }
  .panel-head h2 { font-size: 1.05rem; }

  /* Justimmo collapsible on mobile */
  .justimmo-panel { padding: 0.55rem 0.65rem; }
  .mobile-collapse-sum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    list-style: none;
    cursor: pointer;
    padding: 0.55rem 0.35rem;
    min-height: 48px;
  }
  .mobile-collapse-sum::-webkit-details-marker { display: none; }
  .mobile-collapse-sum::after {
    content: "▾";
    color: var(--vs-navy);
    font-size: 1.1rem;
    transition: transform 0.2s;
  }
  details.mobile-collapse:not([open]) > .mobile-collapse-sum::after {
    transform: rotate(-90deg);
  }
  .mobile-collapse-sum strong {
    display: block;
    color: var(--vs-navy);
    font-size: 0.98rem;
  }
  .mobile-collapse-body { padding: 0 0.25rem 0.65rem; }
  .ji-hint { display: none; }

  .search-row {
    flex-wrap: wrap;
  }
  .justimmo-panel .search-row:not(.search-row-actions) {
    flex-direction: column;
    align-items: stretch;
  }
  .justimmo-panel .search-row .narrow {
    flex: 1 1 auto;
    width: 100%;
  }
  .history-search-row {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .history-search-row input[type="search"] {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  .history-sort {
    flex: 1 1 100%;
    width: 100%;
    white-space: normal;
  }
  .history-sort select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .search-row .narrow {
    flex: 1 1 40%;
    min-width: 0;
  }
  .search-row-actions {
    justify-content: space-between;
  }
  .search-row-actions .btn {
    flex: 1;
    min-height: 44px;
  }

  .ji-market-btn { min-height: 44px; }
  .ji-card { padding: 0.85rem; }
  .ji-load-btn { min-height: 44px; }

  /* Forms: single column, large taps, no iOS zoom */
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  fieldset {
    margin: 0.75rem 0;
    padding: 0.75rem 0.7rem 0.85rem;
  }

  label {
    font-size: 0.84rem;
  }

  input,
  select,
  textarea {
    font-size: 16px !important; /* verhindert iOS-Zoom */
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
  }

  input[type="checkbox"] {
    min-height: 20px;
    width: 20px;
    height: 20px;
  }

  label.check {
    min-height: 44px;
    gap: 0.65rem;
  }

  .btn {
    min-height: 44px;
    padding: 0.7rem 1rem;
  }

  .btn.large {
    min-height: 48px;
    font-size: 1rem;
  }

  .row-between {
    flex-direction: column;
    align-items: stretch;
  }

  #btnResetProvision {
    width: 100%;
  }

  /* Sticky submit bar */
  .form-actions-sticky {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 28;
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--vs-sand);
    box-shadow: 0 -6px 20px rgba(29, 53, 112, 0.08);
  }
  .form-actions-sticky #btnClear {
    flex: 0 0 auto;
  }
  .form-actions-sticky #btnSubmit {
    flex: 1;
  }

  .form-panel .status-line {
    margin-bottom: 0.5rem;
  }

  /* Modals almost full screen */
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-card,
  .modal-card.modal-wide,
  .modal-card.modal-xl {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }

  #historyModal {
    padding: 0;
    place-items: end stretch;
    align-items: end;
  }
  #historyModal .modal-card {
    width: 100%;
    height: auto;
    max-height: 92vh;
  }

  .abgeber-list-head { display: none; }
  .abgeber-row,
  #usersModal .abgeber-list-head,
  #usersModal .abgeber-row {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .abgeber-row-actions,
  #usersModal .abgeber-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .abgeber-row-actions .btn,
  #usersModal .abgeber-row-actions .btn {
    flex: 1 1 6.5rem;
    min-width: 0;
    justify-content: center;
    white-space: normal;
  }

  .layout,
  .panel,
  fieldset,
  .grid-2,
  .grid-2 > *,
  .row-between,
  .row-between > *,
  label,
  .form-panel,
  .justimmo-panel,
  .optin-box,
  .pdf-import-box,
  .pdf-import-row,
  .anbot-edit-bar,
  .anbot-edit-bar p,
  .modal-card,
  .history-card,
  .history-card-head,
  .history-object {
    min-width: 0;
    max-width: 100%;
  }
  .row-between { align-items: stretch !important; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .pdf-import-row input[type="file"] {
    flex: 1 1 100%;
    width: 100%;
  }
  .pdf-import-row .btn { flex: 1 1 auto; max-width: 100%; }
  .ji-card strong,
  .ji-card .meta,
  .abgeber-row-title,
  .abgeber-row-detail,
  legend {
    overflow-wrap: anywhere;
  }
  .abgeber-toolbar input[type="search"] {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }
  .mail-tpl-live-bar { align-items: stretch; }
  .mail-tpl-live-bar select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .modal-head {
    flex-wrap: nowrap;
    align-items: center;
  }
  .modal-head h3 {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-card-head {
    grid-template-columns: 4.6rem minmax(0, 1fr);
    grid-template-areas:
      "top titles"
      "top details"
      "tools tools";
  }
  .history-card-tools {
    justify-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
  }
  .history-card-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.55rem;
    min-width: 0;
    max-width: 100%;
  }
  .history-card-head .typ-chip,
  .history-card-when,
  .history-card-tenant {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
  }

  .provision-intro { font-size: 0.82rem; }
  .tag { font-size: 0.6rem; }
}

/* Small phones */
@media (max-width: 380px) {
  .brand-text strong { font-size: 0.85rem; }
  .summary-pill { font-size: 0.78rem; padding: 0.45rem 0.7rem; }
}

/* Desktop: keep details always expanded / hide summary chrome */
@media (min-width: 901px) {
  .mobile-collapse-sum { display: none; }
  .mobile-collapse-body { display: block !important; }
  details.mobile-collapse { display: block; }
  .justimmo-panel {
    position: sticky;
    top: 5rem;
    align-self: start;
  }
  .justimmo-panel .ji-results {
    max-height: calc(100dvh - 14rem);
    overflow: auto;
  }
  details.mobile-collapse[open] > .mobile-collapse-body,
  details.mobile-collapse > .mobile-collapse-body {
    display: block;
  }
  .justimmo-panel .panel-head { /* content is inside details now */
  }
  .summary-bar { display: none; }
}
