:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #d9e2ec;
  --text: #1f2937;
  --muted: #667085;
  --primary: #2463eb;
  --primary-dark: #1b4fc0;
  --sidebar: #0f172a;
  --danger: #c62828;
  --success-bg: #dff6e8;
  --success-text: #13663b;
  --error-bg: #fde7e7;
  --error-text: #8f1d1d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a, #172554);
  color: white;
  padding: 24px;
}

.brand { font-size: 26px; font-weight: 800; }
.brand-sub { color: rgba(255,255,255,.75); margin-top: 4px; font-size: 13px; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 32px;
}
.nav a {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
}
.nav a:hover { background: rgba(255,255,255,.14); }

.main { padding: 24px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.muted { color: var(--muted); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}
.tile {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  font-size: 28px;
  font-weight: 700;
  border-radius: 24px;
  box-shadow: 0 12px 28px rgba(37, 99, 235, .28);
}
.tile:hover { transform: translateY(-2px); }
.tile.disabled { opacity: .7; }

.btn {
  border: none;
  background: var(--primary);
  color: white;
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary { background: #64748b; }
.btn-small { padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.danger { background: var(--danger); }

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar input { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px;
}
.form-grid.single { grid-template-columns: 1fr; }
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field.full, .actions.full { grid-column: 1 / -1; }
label { font-size: 14px; font-weight: 600; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  background: white;
}
textarea { min-height: 130px; resize: vertical; }
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap { overflow: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.table th {
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.flash {
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
}
.flash.success { background: var(--success-bg); color: var(--success-text); }
.flash.error { background: var(--error-bg); color: var(--error-text); }

.login-wrap {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
}
.login-card {
  width: 100%;
  max-width: 520px;
}

.mt16 { margin-top: 16px; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}
.photo-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.photo-meta {
  padding: 12px;
  display: grid;
  gap: 8px;
}
.codeblock {
  white-space: pre-wrap;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 14px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

.table-gutachten tbody tr.gutachten-row {
  cursor: default;
  transition: background-color 0.12s ease-in-out;
}

.table-gutachten tbody tr.gutachten-row:hover {
  background-color: #f6a623;
}

.table-gutachten tbody tr.gutachten-row:hover td {
  color: #000000;
}

.table-gutachten tbody tr.gutachten-row td {
  user-select: none;
}

/* ADRESSEN TABELLE */

.table-adressen tbody tr.adresse-row {
  cursor: pointer;
  transition: background-color 0.12s ease-in-out;
}

/* Hover = orange */
.table-adressen tbody tr.adresse-row:hover {
  background-color: #f6a623;
}

/* Text bleibt schwarz */
.table-adressen tbody tr.adresse-row:hover td {
  color: #000000;
}

/* ausgewählte Zeile */
.table-adressen tbody tr.adresse-row.selected {
  background-color: #ffd27a;
}

.table-adressen tbody tr.adresse-row.selected td {
  color: #000000;
}

.vga-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  align-items: start;
}

.vga-left,
.vga-middle {
  display: grid;
  gap: 10px;
}

.vga-status-box {
  margin-top: 8px;
  margin-bottom: 14px;
}

.vga-tabs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.vga-tab {
  border: 1px solid var(--line);
  background: #f4f6f8;
  padding: 8px 12px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}

.vga-tab.active {
  background: white;
  font-weight: 700;
}

.vga-tab-panel {
  display: none;
  border: 1px solid var(--line);
  background: #f7f7f7;
  padding: 14px;
}

.vga-tab-panel.active {
  display: block;
}

.vga-subform {
  display: grid;
  gap: 10px;
}

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

.pga-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.65fr 0.9fr;
  gap: 16px;
  align-items: start;
}

.pga-left {
  display: grid;
  gap: 10px;
  grid-column: 1 / 2;
}

.pga-top-middle {
  grid-column: 2 / 3;
}

.pga-status {
  grid-column: 3 / 4;
}

.pga-wide {
  grid-column: 1 / 4;
  display: grid;
  gap: 10px;
}

.pga-wide-row {
  grid-template-columns: 150px 1fr;
}

.pga-dates {
  grid-column: 1 / 2;
  display: grid;
  gap: 10px;
}

.pga-costs {
  grid-column: 2 / 3;
  display: grid;
  gap: 10px;
}

.pga-object {
  grid-column: 3 / 4;
  display: grid;
  gap: 10px;
}

.pga-notes {
  grid-column: 1 / 4;
}

.pga-notes-row {
  grid-template-columns: 150px 1fr;
  align-items: start;
}

.pga-notes-row textarea {
  min-height: 360px;
}

.pga-ag-fields {
  grid-template-columns: 0.7fr 0.8fr 1fr 1fr auto;
}

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

  .pga-left,
  .pga-top-middle,
  .pga-status,
  .pga-wide,
  .pga-dates,
  .pga-costs,
  .pga-object,
  .pga-notes {
    grid-column: 1 / -1;
  }

  .pga-ag-fields {
    grid-template-columns: 1fr;
  }
}

.btg-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.9fr 0.9fr;
  gap: 16px;
  align-items: start;
}

.btg-left {
  display: grid;
  gap: 10px;
  grid-column: 1 / 2;
}

.btg-status {
  grid-column: 3 / 4;
}

.btg-wide {
  grid-column: 1 / 4;
  display: grid;
  gap: 10px;
}

.btg-wide-row {
  grid-template-columns: 150px 1fr;
}

.btg-dates {
  grid-column: 1 / 2;
  display: grid;
  gap: 10px;
}

.btg-object {
  grid-column: 2 / 3;
  display: grid;
  gap: 10px;
}

.btg-notes {
  grid-column: 1 / 4;
}

.btg-notes-row {
  grid-template-columns: 150px 1fr;
  align-items: start;
}

.btg-notes-row textarea {
  min-height: 120px;
}

.btg-ag-fields {
  grid-template-columns: 0.7fr 0.8fr 1fr 1fr auto;
}

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

  .btg-left,
  .btg-status,
  .btg-wide,
  .btg-dates,
  .btg-object,
  .btg-notes {
    grid-column: 1 / -1;
  }

  .btg-ag-fields {
    grid-template-columns: 1fr;
  }
}

.ga-tab-panel {
  display: none;
}

.ga-tab-panel.active {
  display: block;
}

.popup {
  position: fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background: rgba(0,0,0,0.4);
}

.popup.hidden {
  display:none;
}

.popup-content {
  background:white;
  margin:50px auto;
  padding:20px;
  width:600px;
}

.adress-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
}

.adress-popup.hidden {
  display: none !important;
}

.adress-popup-box {
  width: min(1100px, 94vw);
  height: min(800px, calc(100vh - 60px));
  max-height: min(800px, calc(100vh - 60px));
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.adress-popup-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.adress-popup-search {
  flex: 0 0 auto;
  width: 100%;
  margin: 12px 0;
}

.adress-popup .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: auto;
}

.table-adress-popup {
  width: 100%;
}

.table-adress-popup tbody tr {
  cursor: pointer;
}

.table-adress-popup tbody tr:hover,
.table-adress-popup tbody tr:hover td {
  background: #f6a623;
  color: #000;
}

/* FIX: Adress-Popup feste Höhe + scrollende Liste */
#adressPopup.adress-popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.45);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
}

#adressPopup.adress-popup.hidden {
  display: none !important;
}

#adressPopup .adress-popup-box {
  width: min(760px, 94vw);
  height: 800px;
  max-height: calc(100vh - 80px);
  background: #fff;
  padding: 18px;
  border-radius: 0;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
}

#adressPopup .adress-popup-head {
  flex: 0 0 auto;
}

#adressPopup .adress-popup-search {
  flex: 0 0 auto;
  margin: 12px 0;
}

#adressPopup .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden;
}

#adressPopup table {
  margin-bottom: 0;
}

.dashboard-page {
  min-height: calc(100vh - 80px);
  padding: 70px 80px;
}

.dashboard-tiles {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 340px);
  gap: 55px 70px;
  justify-content: center;
}

.dashboard-tiles .tile {
  width: 340px;
  height: 270px;
  aspect-ratio: auto;
  background: #168fc4;
  color: #fff;
  font-size: 46px;
  font-weight: 300;
  border-radius: 0;
  border: 1px solid #6b7280;
  box-shadow: none;
}

.dashboard-tiles .tile:hover {
  background: #0f82b5;
  transform: none;
}

@media (max-width: 1200px) {
  .dashboard-tiles {
    grid-template-columns: repeat(2, 340px);
  }
}

@media (max-width: 760px) {
  .dashboard-page {
    padding: 30px 20px;
  }

  .dashboard-tiles {
    grid-template-columns: 1fr;
  }

  .dashboard-tiles .tile {
    width: 100%;
    height: 220px;
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: white;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-box.small {
  width: 420px;
}

.dialog-form {
  margin-top: 20px;
}

.dialog-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  margin-bottom: 12px;
}

.dialog-row label {
  font-weight: 500;
}

.dialog-row input,
.dialog-row select {
  border: 1px solid #ccc;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}

.doc-edit-form {
  background: #f8fafc;
  border: 1px solid #cfd8e3;
  padding: 14px;
  border-radius: 12px;
}

.doc-edit-grid {
  display: grid;
  grid-template-columns: 130px 1fr 130px 1fr;
  gap: 10px;
  align-items: center;
}

.doc-edit-grid input,
.doc-edit-grid textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
}

.doc-edit-grid textarea {
  grid-column: span 3;
  min-height: 80px;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.75);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.preview-window {
  width: min(1200px, 96vw);
  height: min(850px, 92vh);
  background: white;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-head {
  padding: 12px 16px;
  border-bottom: 1px solid #cfd8e3;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-body {
  flex: 1;
  overflow: auto;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.dropzone {
  display: block;
  border: 3px dashed #168fc4 !important;
  border-radius: 18px !important;
  padding: 38px !important;
  text-align: center;
  background: #f8fbff !important;
  color: #168fc4 !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  cursor: pointer;
  margin-top: 14px;
  min-height: 90px;
}

.dropzone.drag {
  background: #dbeffd !important;
  transform: scale(1.01);
}

.click-row:hover {
  background: #eaf4ff;
}

.gga-layout {
  display: grid;
  grid-template-columns: 420px 430px 1fr;
  gap: 24px;
  align-items: start;
}

.form-row {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.form-row label {
  font-size: 14px;
  color: #111827;
}

.form-row input,
.form-row select {
  height: 30px;
  max-width: 360px;
  padding: 4px 8px;
  border: 1px solid #bfc9d5;
  border-radius: 4px;
  background: #fff;
}

.form-row.short input {
  max-width: 140px;
}

.form-row.three {
  grid-template-columns: 145px 70px 100px 1fr;
}

.form-row.three input:first-of-type {
  max-width: 65px;
}

.form-row.three input:nth-of-type(2) {
  max-width: 95px;
}

.form-row.area {
  align-items: start;
  grid-template-columns: 145px 1fr;
  margin-top: 54px;
}

.form-row.area textarea {
  width: 100%;
  height: 350px;
  border: 1px solid #bfc9d5;
  border-radius: 4px;
  padding: 8px;
  resize: vertical;
}

.check-row {
  margin: 28px 0 0 145px;
}

.gga-status {
  border: 1px solid #9fb6d8;
  background: #f8fafc;
  min-height: 310px;
}

.gga-status h3 {
  margin: 0;
  padding: 8px 10px;
  background: #eef3f8;
  font-size: 14px;
}

.status-add {
  display: flex;
  gap: 6px;
  padding: 8px;
}

.status-add select {
  flex: 1;
  height: 30px;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.status-table th,
.status-table td {
  border: 1px solid #1f2937;
  padding: 6px;
  font-size: 13px;
  text-align: left;
}

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

.adr-form {
  width: 100%;
}

.adr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.adr-section {
  background: #fff;
  border: 1px solid #dbe3ec;
  border-radius: 14px;
  padding: 16px;
}

.adr-section h3 {
  margin: 0 0 14px 0;
  font-size: 16px;
}

.adr-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.adr-row label {
  font-size: 14px;
  color: #111827;
}

.adr-row input {
  height: 30px;
  max-width: 330px;
  padding: 4px 8px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
}

.adr-row.short input {
  max-width: 150px;
}

.adr-plzort {
  grid-template-columns: 120px 90px 1fr;
}

.adr-plzort input:first-of-type {
  max-width: 90px;
}

.adr-plzort input:last-of-type {
  max-width: 230px;
}

.adr-notes {
  margin-top: 18px;
}

.adr-notes textarea {
  width: 100%;
  min-height: 150px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

.small-select {
  width: 90px !important;
  max-width: 90px !important;
  height: 30px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  padding: 4px 6px;
  background: #fff;
}

/* VGA Statusbox größer darstellen */
.vga-status-box,
.gga-status {
  min-height: 340px;
}

.gga-status .status-table {
  width: 100%;
  min-height: 140px;
}

.gga-status .status-table tbody tr {
  height: 34px;
}

.gga-status .status-table td,
.gga-status .status-table th {
  padding: 8px 10px;
  font-size: 14px;
}

.gga-status .status-add {
  margin-bottom: 12px;
}


.ga-tab-panel {
  display: none;
}

.ga-tab-panel.active {
  display: block;
}

.ga-iframe-panel {
  margin-top: 14px;
}

.ga-module-frame {
  width: 100%;
  height: 850px;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

.foto-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 14px;
  background: #f8fafc;
  padding: 28px;
  text-align: center;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  margin-top: 14px;
}

.foto-dropzone:hover,
.foto-dropzone.drag {
  background: #e0f2fe;
  border-color: #0284c7;
  color: #075985;
}

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