/* ENEBA UI-Optimierung 2026-07-24 */
:root {
  --ui-content-max: 1680px;
  --ui-panel-radius: 14px;
  --ui-soft-shadow: 0 10px 30px rgba(22, 50, 68, .07);
}

.page {
  max-width: var(--ui-content-max);
  padding: 34px clamp(22px, 3vw, 52px) 64px;
}

.page-head {
  margin-bottom: 28px;
}

.page-head > h1 {
  margin-bottom: 0;
}

/* Projektvorlagen */
#templates .page-head {
  align-items: flex-end;
}

#templates .page-head > button {
  min-height: 42px;
  padding-inline: 18px;
  box-shadow: 0 6px 16px rgba(18, 166, 105, .18);
}

#templateList.cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  align-items: stretch;
}

#templateList .template-card {
  height: 100%;
  padding: 22px;
  border-radius: var(--ui-panel-radius);
  border: 1px solid #dce6e9;
  box-shadow: var(--ui-soft-shadow);
  background: linear-gradient(180deg, #fff 0%, #fbfdfd 100%);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

#templateList .template-card:hover {
  transform: translateY(-2px);
  border-color: #bfd8d0;
  box-shadow: 0 14px 34px rgba(22, 50, 68, .11);
}

#templateList .template-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e5ecef;
}

#templateList .template-card-head h2 {
  font-size: 21px;
  line-height: 1.2;
  margin: 0 0 6px;
  border: 0;
  padding: 0;
}

#templateList .template-card-head .muted {
  margin: 0;
  font-size: 13px;
}

#templateList .template-actions {
  gap: 7px;
}

#templateList .template-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

#templateList .template-task-list {
  gap: 7px;
  max-height: 510px;
  overflow: auto;
  padding-right: 5px;
  scrollbar-width: thin;
}

#templateList .template-task-group,
#templateList .template-task-single {
  padding: 11px 13px;
  border-radius: 9px;
  background: #f6fbf9;
}

#templateList .template-task-child {
  margin-left: 15px;
  padding: 8px 8px 8px 14px;
  border-radius: 0 7px 7px 0;
}

#templateList .template-task-list strong {
  display: block;
  line-height: 1.38;
}

/* Textbausteine */
#textBlocks .page-head {
  margin-bottom: 18px;
}

#textBlocks .card {
  padding: 22px;
  border-radius: var(--ui-panel-radius);
  border: 1px solid #dce6e9;
  box-shadow: var(--ui-soft-shadow);
}

#textBlocks .isfp-textblocks-shell {
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 24px;
  min-height: 68vh;
}

#textBlocks .isfp-textblocks-sidebar {
  top: 22px;
  gap: 12px;
}

#textBlocks .isfp-textblocks-sidebar > h2 {
  font-size: 20px;
  margin-bottom: 0;
}

#textBlocks #isfpTextBlockSearch {
  min-height: 44px;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 15px;
  background: #fff;
}

#textBlocks #isfpTextBlockCount {
  display: inline-flex;
  width: fit-content;
  margin: -3px 0 0;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef6f3;
  color: #45645a;
  font-size: 12px;
  font-weight: 700;
}

#textBlocks .isfp-textblock-list {
  max-height: calc(100vh - 275px);
  min-height: 470px;
  padding: 8px;
  gap: 3px;
  border-radius: 12px;
  border-color: #dce6e9;
  background: #fbfdfd;
  scrollbar-width: thin;
}

#textBlocks .isfp-textblock-nav {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  transition: background-color .14s ease, color .14s ease, transform .14s ease;
}

#textBlocks .isfp-textblock-nav:hover {
  background: #eaf5f1;
  transform: translateX(2px);
}

#textBlocks .isfp-textblock-nav.active {
  background: #dff2ea;
  color: #075f3b;
  box-shadow: inset 3px 0 0 #12a669;
}

#textBlocks .isfp-textblock-nav.level-1 {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 800;
  text-transform: none;
}

#textBlocks .isfp-textblock-nav.structure-only {
  color: #284452;
}

#textBlocks .isfp-tree-toggle {
  color: #0f8e5b;
}

#textBlocks .isfp-textblock-content {
  min-height: 100%;
  border: 1px solid #dce6e9;
  border-radius: 12px;
  background: #fff;
  padding: clamp(24px, 3vw, 42px);
}

#textBlocks .isfp-textblock-empty-state {
  min-height: 500px;
  border: 0;
  background: radial-gradient(circle at center, #f8fbfa 0%, #fff 68%);
}

#textBlocks .isfp-textblock-empty-state h2 {
  font-size: 23px;
}

#textBlocks .isfp-textblock-breadcrumb {
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.5;
}

#textBlocks .isfp-textblock-title-row {
  align-items: center;
  padding-bottom: 17px;
  margin-bottom: 24px;
}

#textBlocks .isfp-textblock-title-row h2 {
  font-size: clamp(22px, 2vw, 29px);
  line-height: 1.2;
}

#textBlocks .isfp-textblock-title-row #copyIsfpTextBlock {
  min-width: 142px;
  min-height: 40px;
  flex: 0 0 auto;
}

#textBlocks .isfp-textblock-article {
  max-width: 900px;
  font-size: 16px;
  line-height: 1.72;
  color: #243640;
}

#textBlocks .isfp-textblock-article p {
  margin-bottom: 1.1em;
}

#textBlocks .isfp-search-highlight {
  background: #ffe66d;
  box-shadow: 0 0 0 2px #ffe66d;
  border-radius: 3px;
}

@media (min-width: 1800px) {
  #templateList.cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  #templateList.cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #textBlocks .isfp-textblocks-shell {
    grid-template-columns: minmax(320px, 38%) minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .page {
    padding: 24px 16px 46px;
  }
  #templateList.cards {
    grid-template-columns: 1fr;
  }
  #templateList .template-task-list {
    max-height: none;
  }
  #textBlocks .isfp-textblocks-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  #textBlocks .isfp-textblocks-sidebar {
    position: static;
  }
  #textBlocks .isfp-textblock-list {
    min-height: 0;
    max-height: 360px;
  }
  #textBlocks .isfp-textblock-content {
    padding: 22px 18px;
  }
  #textBlocks .isfp-textblock-title-row {
    align-items: stretch;
    flex-direction: column;
  }
  #textBlocks .isfp-textblock-title-row #copyIsfpTextBlock {
    width: 100%;
  }
}

/* ENEBA UI-Feinschliff 2026-07-24 v2 */
:root {
  --ui-content-max: 2040px;
}

/* Seitenbreite besser ausnutzen, ohne Inhalte an die Bildschirmkante zu drücken */
.page {
  width: min(calc(100% - 48px), var(--ui-content-max));
  max-width: none;
  margin-inline: auto;
  padding-inline: 0;
}

/* Projektvorlagen: ruhiges 3-Spalten-Raster statt 4+1-Ausreißer */
#templates .page-head,
#templates #templateList {
  width: 100%;
}

#templateList.cards {
  grid-template-columns: repeat(3, minmax(320px, 1fr));
  gap: 24px;
}

#templateList .template-card {
  min-width: 0;
  padding: 24px;
}

#templateList .template-card-head {
  align-items: start;
}

#templateList .template-card-head h2 {
  font-size: 22px;
  overflow-wrap: anywhere;
}

#templateList .template-actions {
  display: grid;
  grid-template-columns: 1fr;
  min-width: 104px;
}

#templateList .template-actions button {
  width: 100%;
  white-space: nowrap;
}

#templateList .template-task-list {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

/* Textbausteine: mehr Raum für Navigation und Lesetext */
#textBlocks .card {
  padding: 24px;
}

#textBlocks .isfp-textblocks-shell {
  grid-template-columns: clamp(380px, 27vw, 500px) minmax(0, 1fr);
  gap: 28px;
  min-height: calc(100vh - 205px);
}

#textBlocks .isfp-textblocks-sidebar {
  align-self: start;
}

#textBlocks .isfp-textblock-list {
  max-height: calc(100vh - 300px);
  min-height: 560px;
}

#textBlocks .isfp-textblock-nav {
  min-height: 40px;
  padding-block: 9px;
  font-size: 13.5px;
}

#textBlocks .isfp-textblock-content {
  min-height: calc(100vh - 255px);
  padding: clamp(30px, 3vw, 52px);
}

#textBlocks .isfp-textblock-article {
  max-width: 1040px;
  font-size: 16.5px;
  line-height: 1.76;
}

#textBlocks .isfp-textblock-title-row {
  gap: 22px;
}

#textBlocks .isfp-textblock-title-row h2 {
  max-width: 900px;
}

#textBlocks .isfp-textblock-title-row #copyIsfpTextBlock {
  position: sticky;
  top: 18px;
}

/* Suchmarkierung etwas klarer, aber nicht grell */
#textBlocks .isfp-search-highlight {
  background: #fff1a8;
  box-shadow: inset 0 -2px 0 #e1b900;
  padding: 0 .08em;
}

@media (min-width: 2100px) {
  #templateList.cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .page {
    width: min(calc(100% - 36px), var(--ui-content-max));
  }

  #templateList.cards {
    grid-template-columns: repeat(2, minmax(300px, 1fr));
  }

  #textBlocks .isfp-textblocks-shell {
    grid-template-columns: minmax(330px, 40%) minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .page {
    width: calc(100% - 24px);
  }

  #templateList.cards {
    grid-template-columns: 1fr;
  }

  #templateList .template-actions {
    display: flex;
    min-width: 0;
  }

  #templateList .template-actions button {
    width: auto;
  }

  #textBlocks .isfp-textblocks-shell {
    min-height: 0;
  }

  #textBlocks .isfp-textblock-list {
    min-height: 0;
  }

  #textBlocks .isfp-textblock-content {
    min-height: 420px;
  }

  #textBlocks .isfp-textblock-title-row #copyIsfpTextBlock {
    position: static;
  }
}

/* Projektanlage-Wizard */
.project-wizard{display:block}
.project-wizard-progress{display:grid;grid-template-columns:auto 1fr auto 1fr auto;align-items:center;gap:12px;margin:0 0 22px;padding:14px 16px;border:1px solid #dce6e9;border-radius:12px;background:#f8fbfa}
.project-wizard-tab{display:flex;align-items:center;gap:8px;border:0;background:transparent;color:#6b7b83;padding:0;font-weight:700;box-shadow:none}
.project-wizard-tab:hover{background:transparent;color:#0f8e5b}
.project-wizard-tab span{display:grid;place-items:center;width:28px;height:28px;border-radius:50%;border:2px solid #cbd7dc;background:#fff;font-size:13px}
.project-wizard-tab.active{color:#123b2e}
.project-wizard-tab.active span,.project-wizard-tab.complete span{border-color:#12a669;background:#12a669;color:#fff}
.project-wizard-line{height:2px;background:#dce6e9}
.project-wizard-step{display:none}
.project-wizard-step.active{display:block}
.project-wizard-actions{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-top:18px;padding-top:16px;border-top:1px solid #e4ecef}
.project-section{margin:0 0 16px;padding:18px;border:1px solid #dce6e9;border-radius:12px;background:#fff}
.project-section legend{padding:0 8px;font-weight:800;color:#173c31}
.project-section .span-2{grid-column:1/-1}
.project-wizard textarea{min-height:90px}
@media (max-width:760px){.project-wizard-progress{grid-template-columns:1fr;gap:8px}.project-wizard-line{display:none}.project-wizard-tab{justify-content:flex-start}.project-section{padding:14px}}

/* Projektanlage: Flächennutzung und Pflichtfeldführung */
#modalRoot .modal-card:has(.project-wizard) {
  width: min(1240px, 96vw);
  max-width: 1240px;
  max-height: 94vh;
}
#modalRoot .modal-card:has(.project-wizard) .modal-body,
#modalRoot .modal-card:has(.project-wizard) form {
  min-width: 0;
}
.project-wizard-progress {
  max-width: none;
  margin-bottom: 18px;
}
.project-wizard-step.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.project-wizard-step .project-section {
  width: 100%;
  margin: 0;
}
.project-wizard-step[data-project-step="1"] .form-grid,
.project-wizard-step[data-project-step="2"] .form-grid,
.project-wizard-step[data-project-step="3"] .form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(1) { grid-column: span 7; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(2) { grid-column: span 2; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(3) { grid-column: span 3; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(4) { grid-column: span 6; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(5),
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(6),
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(7) { grid-column: span 2; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(8) { grid-column: span 6; }
.project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(9) { grid-column: span 6; }
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(1),
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(2) { grid-column: span 4; }
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(3) { grid-column: span 4; }
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(4),
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(5),
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(6) { grid-column: span 4; }
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(7) { grid-column: span 5; }
.project-wizard-step[data-project-step="2"] .form-grid > label:nth-child(8) { grid-column: span 7; }
.project-wizard-step[data-project-step="3"] .form-grid > label { grid-column: span 6; }
.project-wizard-step[data-project-step="3"] .gs-integration .form-grid > label:first-child { grid-column: span 4; }
.project-wizard-step[data-project-step="3"] .gs-integration .form-grid > label:nth-child(2) { grid-column: span 8; }
.project-wizard-step[data-project-step="3"] .gs-integration .form-grid > label:nth-child(3) { grid-column: 1 / -1; }
.project-wizard label:has(input[required])::after,
.project-wizard label:has(select[required])::after,
.project-wizard label:has(textarea[required])::after {
  content: " *";
  color: #c53d3d;
  font-weight: 800;
}
.project-wizard input.field-invalid,
.project-wizard select.field-invalid,
.project-wizard textarea.field-invalid {
  border-color: #cf4c4c;
  box-shadow: 0 0 0 3px rgba(207, 76, 76, .10);
}
.project-wizard-actions {
  grid-column: 1 / -1;
  position: sticky;
  bottom: -1px;
  z-index: 3;
  margin-top: 2px;
  padding: 14px 2px 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0), #fff 28%);
}
.project-wizard-actions button[disabled],
.project-wizard-tab[disabled] {
  opacity: .45;
  cursor: not-allowed;
}
.project-wizard-actions .primary {
  min-width: 118px;
}
@media (max-width: 900px) {
  .project-wizard-step[data-project-step] .form-grid > label { grid-column: 1 / -1 !important; }
  #modalRoot .modal-card:has(.project-wizard) { width: min(760px, 96vw); }
}

/* Projektwizard: echte Dialogbreite und Pflichtstern direkt im Feldnamen */
#modal.project-wizard-modal {
  width: min(1240px, calc(100vw - 40px)) !important;
  max-width: 1240px !important;
  height: auto;
  max-height: 94vh;
  padding: 0;
}
#modal.project-wizard-modal #modalForm {
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  box-sizing: border-box;
}
#modal.project-wizard-modal #modalBody {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
#modal.project-wizard-modal .project-wizard {
  width: 100%;
}
#modal.project-wizard-modal .project-wizard-step.active {
  width: 100%;
}
#modal.project-wizard-modal .project-section {
  box-sizing: border-box;
}

/* Alte, am Labelende erscheinende Pseudosterne abschalten. */
.project-wizard label:has(input[required])::after,
.project-wizard label:has(select[required])::after,
.project-wizard label:has(textarea[required])::after {
  content: none !important;
}
.project-wizard .field-caption {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  margin-bottom: 6px;
  line-height: 1.25;
}
.project-wizard .required-marker {
  color: #c53d3d;
  font-weight: 800;
}

@media (max-width: 900px) {
  #modal.project-wizard-modal {
    width: min(760px, calc(100vw - 24px)) !important;
  }
}

/* Projektwizard: #modalBody ist im Basistheme zweispaltig. Der Wizard muss die gesamte Breite belegen. */
#modal.project-wizard-modal #modalBody {
  display: block !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}
#modal.project-wizard-modal #modalBody > .project-wizard {
  display: block;
  width: 100% !important;
  max-width: none !important;
  grid-column: 1 / -1 !important;
}
#modal.project-wizard-modal .project-wizard-progress,
#modal.project-wizard-modal .project-wizard-step,
#modal.project-wizard-modal .project-wizard-step.active,
#modal.project-wizard-modal .project-section,
#modal.project-wizard-modal .project-section > .form-grid {
  width: 100% !important;
  max-width: none !important;
}
#modal.project-wizard-modal .project-wizard-step.active {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Projektwizard – Gebäude kompakt in logisch gruppierten Zeilen */
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid {
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}

/* Zeile 1: Straße + Hausnummer */
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(1) {
  grid-column: span 13;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(2) {
  grid-column: span 3;
}

/* Zeile 2: PLZ + Ort */
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(3) {
  grid-column: span 3;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(4) {
  grid-column: span 13;
}

/* Zeile 3: Baujahr, Geschosse, Einheiten, Typ und Art */
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(5),
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(6),
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(7) {
  grid-column: span 2;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(8),
#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(9) {
  grid-column: span 5;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="1"] input[type="number"] {
  max-width: none;
}

@media (max-width: 1100px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(1) { grid-column: span 9; }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(2) { grid-column: span 3; }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(3) { grid-column: span 3; }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(4) { grid-column: span 9; }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(5),
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(6),
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(7) { grid-column: span 2; }
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(8),
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label:nth-child(9) { grid-column: span 3; }
}

@media (max-width: 900px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="1"] .form-grid > label {
    grid-column: 1 / -1 !important;
  }
}

/* Projektwizard: Dialoghöhe folgt wieder dem tatsächlichen Inhalt. */
#modal.project-wizard-modal {
  height: fit-content !important;
  min-height: 0 !important;
  max-height: calc(100vh - 32px) !important;
  margin-block: auto !important;
  overflow: hidden !important;
}

#modal.project-wizard-modal #modalForm {
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100vh - 32px) !important;
  overflow: hidden !important;
}

#modal.project-wizard-modal #modalBody {
  flex: 0 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: calc(100vh - 112px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

#modal.project-wizard-modal .project-wizard,
#modal.project-wizard-modal .project-wizard-step,
#modal.project-wizard-modal .project-wizard-step.active,
#modal.project-wizard-modal .project-section {
  height: auto !important;
  min-height: 0 !important;
}

#modal.project-wizard-modal .project-wizard-actions {
  position: static !important;
  margin-top: 16px !important;
  padding-top: 14px !important;
}

@media (max-height: 760px) {
  #modal.project-wizard-modal {
    max-height: calc(100vh - 16px) !important;
  }
  #modal.project-wizard-modal #modalForm {
    max-height: calc(100vh - 16px) !important;
  }
  #modal.project-wizard-modal #modalBody {
    max-height: calc(100vh - 92px) !important;
  }
}

/* Projektwizard – Kontaktseite kompakt und zeilenweise */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}

/* 1. Zeile: Kontakttyp */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(1) {
  grid-column: 1 / span 4;
}

/* 2. Zeile: Anrede & Titel */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(2) {
  grid-column: 1 / span 3;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(3) {
  grid-column: 4 / span 4;
}

/* 3. Zeile: Nachname, Vorname(n) */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(4) {
  grid-column: 1 / span 6;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(5) {
  grid-column: 7 / span 6;
}

/* 4. Zeile: Firmenname */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(6) {
  grid-column: 1 / -1;
}

/* 5. Zeile: Kontaktoptionen */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(7),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(8),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(9) {
  grid-column: span 4;
}

/* 6. Zeile: Grundsteine-Kontakt-ID */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(10) {
  grid-column: 1 / -1;
}

/* 7. Zeile: Beschreibung */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:nth-child(11) {
  grid-column: 1 / -1;
}
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout textarea {
  min-height: 96px;
}

@media (max-width: 900px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label {
    grid-column: 1 / -1 !important;
  }
}

/* Projektwizard – Schritt 3 als kompakte Zweispaltenansicht */
#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns-single {
  grid-template-columns: minmax(0, 1fr);
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-planning-section,
#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-grundsteine-section {
  margin: 0;
  height: 100%;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns .form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-grundsteine-section .gs-fields {
  display: grid;
  gap: 12px;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-grundsteine-section textarea {
  min-height: 92px;
}

@media (max-width: 980px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns .form-grid.two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Projektwizard – Grundsteine in Schritt 3 verbindlich in der rechten Spalte */
#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-planning-section,
#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-grundsteine-section {
  grid-column: auto !important;
  width: auto !important;
  min-width: 0;
  max-width: none;
  align-self: stretch;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-grundsteine-section {
  grid-column: 2 !important;
  grid-row: 1;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-planning-section {
  grid-column: 1 !important;
  grid-row: 1;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-grundsteine-section .form-grid.two-col {
  grid-template-columns: minmax(0, 1fr);
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-grundsteine-section .form-grid.two-col > label {
  grid-column: 1 / -1 !important;
}

@media (max-width: 980px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-planning-section,
  #modal.project-wizard-modal .project-wizard-step[data-project-step="3"] .project-step3-columns > .project-grundsteine-section {
    grid-column: 1 !important;
    grid-row: auto;
  }
}


/* Grundsteine V2 Zusatzdaten und Geokodierung */
.project-wizard-modal .building-coordinates {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .65rem 1rem;
    align-items: end;
    padding: .75rem;
    border: 1px dashed #cbdcd6;
    border-radius: .55rem;
    background: #f8fbfa;
}
.project-wizard-modal .coordinate-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}
.project-wizard-modal .building-coordinates small { grid-column: 1 / -1; }
.project-wizard-modal .contact-address-toggle { grid-column: 1 / -1; }
.project-wizard-modal .contact-address-fields {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(7rem, 1fr) minmax(7rem, 1fr) minmax(0, 2fr);
    gap: .75rem;
    padding: .85rem;
    border: 1px solid #d9e5e1;
    border-radius: .55rem;
    background: #fafcfb;
}
.project-wizard-modal .contact-address-fields.hidden,
.project-wizard-modal label.hidden { display: none !important; }
.grundsteine-conflict { display: grid; gap: .75rem; }
.conflict-contact-option {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .8rem;
    border: 1px solid #d8e3df;
    border-radius: .5rem;
}
.conflict-contact-option small { display: block; margin-top: .2rem; color: #66756f; }
@media (max-width: 760px) {
    .project-wizard-modal .building-coordinates,
    .project-wizard-modal .contact-address-fields,
    .project-wizard-modal .coordinate-fields { grid-template-columns: 1fr; }
}

/* Projektwizard – robuste Feldanordnung nach Feldnamen statt DOM-Position */
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label {
  grid-column: 1 / -1 !important;
  min-width: 0;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerContactType"]) {
  grid-column: 1 / span 4 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerSalutation"]) {
  grid-column: 1 / span 3 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerTitle"]) {
  grid-column: 4 / span 4 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerLastName"]) {
  grid-column: 1 / span 6 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerFirstName"]) {
  grid-column: 7 / span 6 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerEmail"]),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerPhone"]),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerMobile"]) {
  grid-column: span 4 !important;
}

#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="customerReference"]),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label:has([name="grundsteineContactId"]),
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > .contact-address-toggle,
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > .contact-address-fields,
#modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > .contact-description {
  grid-column: 1 / -1 !important;
}

/* Koordinaten: Breitengrad, Längengrad und Aktion in einer Zeile */
#modal.project-wizard-modal .building-coordinates {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto !important;
  align-items: end;
}

#modal.project-wizard-modal .building-coordinates .coordinate-fields {
  display: contents;
}

#modal.project-wizard-modal .building-coordinates .geocode-address-button {
  white-space: nowrap;
  min-height: 42px;
}

#modal.project-wizard-modal .building-coordinates small {
  grid-column: 1 / -1 !important;
}

@media (max-width: 900px) {
  #modal.project-wizard-modal .project-wizard-step[data-project-step="2"] .contact-layout > label {
    grid-column: 1 / -1 !important;
  }
}

@media (max-width: 760px) {
  #modal.project-wizard-modal .building-coordinates {
    grid-template-columns: 1fr !important;
  }
  #modal.project-wizard-modal .building-coordinates .coordinate-fields {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Projektwizard – Koordinaten und abweichende Kontaktadresse robust gruppieren */
#modal.project-wizard-modal .building-coordinates {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto !important;
  gap: .75rem !important;
  align-items: end !important;
}

#modal.project-wizard-modal .building-coordinates > label {
  min-width: 0;
  margin: 0;
}

#modal.project-wizard-modal .building-coordinates > .geocode-address-button {
  width: auto;
  min-width: 13rem;
  min-height: 42px;
  white-space: nowrap;
  align-self: end;
}

#modal.project-wizard-modal .building-coordinates > small {
  grid-column: 1 / -1 !important;
}

#modal.project-wizard-modal .contact-address-fields {
  display: grid !important;
  grid-template-columns: minmax(0, 9fr) minmax(7rem, 3fr) !important;
  gap: .75rem 1rem !important;
  align-items: end;
}

#modal.project-wizard-modal .contact-address-fields > label {
  min-width: 0;
  margin: 0;
}

#modal.project-wizard-modal .contact-address-fields > .contact-address-street {
  grid-column: 1;
}

#modal.project-wizard-modal .contact-address-fields > .contact-address-house-number {
  grid-column: 2;
}

#modal.project-wizard-modal .contact-address-fields > .contact-address-zip {
  grid-column: 1;
  width: min(100%, 13rem);
}

#modal.project-wizard-modal .contact-address-fields > .contact-address-city {
  grid-column: 2;
}

@media (max-width: 760px) {
  #modal.project-wizard-modal .building-coordinates,
  #modal.project-wizard-modal .contact-address-fields {
    grid-template-columns: 1fr !important;
  }

  #modal.project-wizard-modal .building-coordinates > .geocode-address-button,
  #modal.project-wizard-modal .contact-address-fields > label {
    grid-column: 1 !important;
    width: 100%;
  }
}


/* Projektwizard – finale robuste Einzeilen-Strukturen (2026-07-24 v9) */
#modal.project-wizard-modal .building-coordinates {
  display: block !important;
}

#modal.project-wizard-modal .building-coordinates .coordinate-input-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) max-content !important;
  gap: .75rem 1rem !important;
  align-items: end !important;
  width: 100%;
}

#modal.project-wizard-modal .building-coordinates .coordinate-input-row > label {
  min-width: 0;
  margin: 0;
}

#modal.project-wizard-modal .building-coordinates .coordinate-input-row > .geocode-address-button {
  width: auto !important;
  min-width: 13rem;
  min-height: 42px;
  white-space: nowrap;
  margin: 0;
}

#modal.project-wizard-modal .building-coordinates > small {
  display: block;
  margin-top: .65rem;
}

#modal.project-wizard-modal .contact-address-fields {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: .75rem !important;
}

#modal.project-wizard-modal .contact-address-fields .contact-address-row {
  display: grid !important;
  gap: .75rem 1rem !important;
  align-items: end;
  width: 100%;
}

#modal.project-wizard-modal .contact-address-fields .contact-address-row-street {
  grid-template-columns: minmax(0, 9fr) minmax(9rem, 2fr) !important;
}

#modal.project-wizard-modal .contact-address-fields .contact-address-row-city {
  grid-template-columns: minmax(9rem, 2fr) minmax(0, 9fr) !important;
}

#modal.project-wizard-modal .contact-address-fields .contact-address-row > label {
  min-width: 0;
  width: 100% !important;
  margin: 0;
  grid-column: auto !important;
}

@media (max-width: 760px) {
  #modal.project-wizard-modal .building-coordinates .coordinate-input-row,
  #modal.project-wizard-modal .contact-address-fields .contact-address-row {
    grid-template-columns: 1fr !important;
  }

  #modal.project-wizard-modal .building-coordinates .coordinate-input-row > .geocode-address-button {
    width: 100% !important;
  }
}


/* Projektwizard: abweichende Kontaktadresse über Checkbox ein-/ausblenden */
#modal.project-wizard-modal .contact-address-fields.hidden {
  display: none !important;
}

#modal.project-wizard-modal .contact-address-toggle {
  cursor: pointer;
  user-select: none;
}
