:root {
  color-scheme: light;
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-alt: #f0f3f2;
  --line: #d9dfdc;
  --line-strong: #b9c4bf;
  --text: #1f2925;
  --muted: #66736d;
  --primary: #174f43;
  --primary-2: #0f766e;
  --danger: #b42318;
  --warning: #b7791f;
  --success: #1f7a4d;
  --info: #2463a6;
  --neutral: #6b7280;
  --shadow: 0 18px 55px rgba(28, 39, 35, 0.15);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary-2);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px;
  background: linear-gradient(180deg, #eef2ef 0%, #f9faf8 100%);
}

.login-panel {
  width: 430px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h2,
.drawer h3 {
  margin: 4px 0 10px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  color: var(--primary-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #17211d;
  color: #f9faf8;
  border-right: 1px solid #26352f;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 22px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  background: #e6eee9;
  color: #16211d;
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #b8c5bf;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #dfe8e3;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #24342e;
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 26px 30px 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: 28px;
}

.topbar-actions,
.view-actions,
.row-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.view-actions {
  justify-content: flex-end;
  min-height: 40px;
  margin-bottom: 16px;
}

.user-badge {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.content {
  display: grid;
  gap: 18px;
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

.section-body {
  padding: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  min-height: 112px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kpi-card small {
  color: var(--muted);
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 12px;
  font-size: 24px;
  letter-spacing: 0;
}

.kpi-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f7f8f6;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.primary,
.secondary,
.ghost,
.danger,
.icon-button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 36px;
  padding: 8px 12px;
  font-weight: 700;
}

.primary {
  background: var(--primary);
  color: white;
}

.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.sidebar .ghost {
  border-color: #33433d;
  color: #e9f0ec;
}

.danger {
  background: #fff5f5;
  border-color: #f2b8b5;
  color: var(--danger);
}

.icon-button {
  width: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--text);
  font-size: 20px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  width: 460px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 160ms ease;
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 20px;
  overflow: auto;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(20, 28, 25, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #17211d;
  color: white;
  box-shadow: var(--shadow);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.status-vermietet {
  background: #e9f7ef;
  color: var(--success);
}

.status-leerstehend {
  background: #fff0ef;
  color: var(--danger);
}

.status-sanierungsbedarf {
  background: #fff7df;
  color: var(--warning);
}

.status-entwicklungspotenzial {
  background: #edf5ff;
  color: var(--info);
}

.status-nicht_zugeordnet,
.status-normal,
.status-offen {
  background: #f2f4f5;
  color: var(--neutral);
}

.status-erledigt {
  background: #e9f7ef;
  color: var(--success);
}

.status-aktiv,
.status-uebernommen,
.status-analyse_abgeschlossen {
  background: #e9f7ef;
  color: var(--success);
}

.status-pruefung_erforderlich,
.status-wird_analysiert,
.status-lauft_aus,
.status-verlangert {
  background: #fff7df;
  color: var(--warning);
}

.status-fehler,
.status-verworfen,
.status-gekuendigt,
.status-gekundigt {
  background: #fff0ef;
  color: var(--danger);
}

.status-entwurf,
.status-hochgeladen {
  background: #f2f4f5;
  color: var(--neutral);
}

.drop-zone {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 118px;
  margin-bottom: 14px;
  padding: 18px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f7f9f8;
  color: var(--muted);
  text-align: center;
}

.drop-zone strong {
  color: var(--text);
}

.drop-zone.drag-over {
  border-color: var(--primary-2);
  background: #eef8f6;
}

.import-note {
  margin-bottom: 12px;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 800;
}

.confidence-high {
  background: #e9f7ef;
  color: var(--success);
}

.confidence-medium {
  background: #fff7df;
  color: var(--warning);
}

.confidence-low {
  background: #fff0ef;
  color: var(--danger);
}

.needs-review input,
.needs-review select,
.needs-review textarea {
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.12);
}

.plan-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.plan-stage {
  position: relative;
  min-height: 620px;
  max-height: calc(100vh - 230px);
  padding: 16px;
  background: #e5e9e6;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: auto;
  overscroll-behavior: contain;
}

.plan-stage.compact {
  min-height: 420px;
  max-height: 460px;
  padding: 12px;
}

.plan-canvas {
  --plan-aspect: 1.414;
  position: relative;
  width: 100%;
  min-width: 100%;
  aspect-ratio: var(--plan-aspect);
  background: #f8faf9;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(31, 41, 37, 0.18);
}

.plan-stage.compact .plan-canvas {
  width: 100%;
}

.plan-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border: 0;
  background: #f8faf9;
  pointer-events: none;
}

.plan-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}

.plan-zone {
  cursor: pointer;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  transition: opacity 120ms ease, stroke-width 120ms ease;
}

.plan-zone:hover {
  opacity: 0.9;
  stroke-width: 6;
}

.zone-vermietet {
  fill: rgba(31, 122, 77, 0.24);
  stroke: #1f7a4d;
}

.swatch.zone-vermietet {
  background: rgba(31, 122, 77, 0.24);
  border-color: #1f7a4d;
}

.zone-leerstehend {
  fill: rgba(180, 35, 24, 0.22);
  stroke: #b42318;
}

.swatch.zone-leerstehend {
  background: rgba(180, 35, 24, 0.22);
  border-color: #b42318;
}

.zone-sanierungsbedarf {
  fill: rgba(183, 121, 31, 0.24);
  stroke: #b7791f;
}

.swatch.zone-sanierungsbedarf {
  background: rgba(183, 121, 31, 0.24);
  border-color: #b7791f;
}

.zone-entwicklungspotenzial {
  fill: rgba(36, 99, 166, 0.22);
  stroke: #2463a6;
}

.swatch.zone-entwicklungspotenzial {
  background: rgba(36, 99, 166, 0.22);
  border-color: #2463a6;
}

.zone-nicht_zugeordnet {
  fill: rgba(107, 114, 128, 0.2);
  stroke: #6b7280;
}

.swatch.zone-nicht_zugeordnet {
  background: rgba(107, 114, 128, 0.2);
  border-color: #6b7280;
}

.draft-zone {
  fill: rgba(15, 118, 110, 0.18);
  stroke: #0f766e;
  stroke-width: 4;
  stroke-dasharray: 10 8;
  vector-effect: non-scaling-stroke;
}

.plan-side {
  display: grid;
  align-content: start;
  gap: 12px;
}

.plan-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.plan-zoom-controls .icon-button {
  font-size: 18px;
  font-weight: 800;
}

.zoom-value {
  min-width: 54px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid currentColor;
}

.details-list {
  display: grid;
  gap: 10px;
}

.details-list div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.details-list dt {
  color: var(--muted);
  font-weight: 700;
}

.details-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subtle-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split-grid,
  .plan-shell {
    grid-template-columns: 1fr;
  }
}
