/* ==========================================================================
   Einrichtungsatlas – Design-System
   Petrol/Bewertungs-Ästhetik: ruhige Flächen, Mono-Zahlen für Datenpunkte,
   der Score-Ring als wiederkehrendes Signature-Element.
   ========================================================================== */

:root {
  --bg: #F5F7F3;
  --surface: #FFFFFF;
  --surface-alt: #EEF1EA;
  --ink: #1E2A24;
  --ink-muted: #5C6B62;
  --border: #DCE2D6;
  --accent: #2C6B7A;
  --accent-strong: #1D4E59;
  --accent-soft: #E4EEF0;
  --gold: #B8863C;
  --gruen: #3C8C5C;
  --gelb: #D2A23A;
  --rot: #C1503E;
  --grau: #9AA39B;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow-card: 0 1px 2px rgba(30,42,36,0.06), 0 4px 16px rgba(30,42,36,0.05);
  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 .5em;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.mono { font-family: var(--font-mono); }

/* ---------- Layout ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--accent); display: flex; }
.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-s);
}
.topnav a:hover { background: var(--surface-alt); text-decoration: none; color: var(--ink); }
.topnav a.active { background: var(--accent-soft); color: var(--accent-strong); }

.content {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-muted);
  margin-bottom: 4px;
  display: block;
}
.page-head h1 { font-size: 26px; }
.page-head .sub { color: var(--ink-muted); font-size: 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-alt); }
.btn-danger { background: transparent; color: var(--rot); border-color: var(--rot); }
.btn-danger:hover { background: #FBEAE7; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- Cards & surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 22px 24px; }

/* ---------- Filter bar ---------- */

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

.search-row {
  position: relative;
  margin-bottom: 14px;
}
.search-row input[type="search"] {
  width: 100%;
  font-size: 16px;
  padding: 12px 16px 12px 42px;
  border-radius: var(--radius-m);
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-body);
}
.search-row input[type="search"]:focus { background: var(--surface); }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--surface-alt); }
.autocomplete-item .ac-ort { color: var(--ink-muted); font-size: 13px; }
.autocomplete-item mark { background: #FCE9C7; color: var(--ink); border-radius: 2px; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.filter-field select,
.filter-field input[type="number"] {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 10px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--bg);
}
.ampel-checks { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px;}
.ampel-check { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.ampel-check input { accent-color: var(--accent); }

.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.result-count { font-size: 13px; color: var(--ink-muted); }
.result-count strong { color: var(--ink); font-family: var(--font-mono); }

/* ---------- Columns popover ---------- */

.columns-wrap { position: relative; }
.columns-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 12px 14px;
  width: 220px;
  z-index: 45;
  display: none;
}
.columns-popover.open { display: block; }
.columns-popover label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}

/* ---------- Table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.data-table thead th:hover { color: var(--ink); }
.data-table thead th .sort-arrow { font-size: 10px; margin-left: 4px; opacity: .5; }
.data-table thead th.sorted .sort-arrow { opacity: 1; color: var(--accent); }
.data-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td {
  padding: 10px 14px;
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table td.col-name { font-weight: 600; white-space: normal; min-width: 180px; }
.data-table td.num, .data-table th.num { font-family: var(--font-mono); }
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--ink-muted);
}
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Score ring ---------- */

.score-ring { display: block; }
.score-ring-text {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  fill: var(--ink);
}
.score-ring-lg .score-ring-text { font-size: 20px; }

.ampel-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
}
.ampel-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
}

/* ---------- Detail page ---------- */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-title-block { display: flex; gap: 18px; align-items: center; }
.detail-title-block h1 { font-size: 24px; margin-bottom: 4px; }
.detail-title-block .traeger { color: var(--ink-muted); font-size: 14px; }
.detail-title-block .ort-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 18px;
}
@media (max-width: 880px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.detail-section { margin-bottom: 18px; }
.detail-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; gap: 10px; font-size: 14px; }
.kv-row .k { width: 130px; flex-shrink: 0; color: var(--ink-muted); }
.kv-row .v { font-weight: 500; }
.kv-row .v a { font-weight: 600; }

.criteria-list { display: flex; flex-direction: column; gap: 12px; }
.criteria-row { display: flex; align-items: center; gap: 12px; }
.criteria-row .label { width: 170px; flex-shrink: 0; font-size: 13px; color: var(--ink-muted); }
.criteria-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.criteria-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.criteria-row .val { font-family: var(--font-mono); font-size: 13px; width: 36px; text-align: right; }

.notes-box {
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.map-embed {
  width: 100%;
  aspect-ratio: 16/10;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.map-embed iframe { width: 100%; height: 100%; border: 0; }

.meta-footer {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.form-field input, .form-field select, .form-field textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 11px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
}
.form-field textarea { min-height: 110px; resize: vertical; font-family: var(--font-body); }
.form-field .hint { font-size: 12px; color: var(--ink-muted); }
fieldset { border: none; padding: 0; margin: 0 0 22px; }
fieldset legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

/* ---------- Upload page ---------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-l);
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { color: var(--accent); margin-bottom: 12px; }
.dropzone .file-name { margin-top: 14px; font-weight: 600; font-family: var(--font-mono); font-size: 14px; }

.report-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 18px 0;
}
.stat-pill {
  flex: 1;
  min-width: 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  text-align: center;
}
.stat-pill .num { font-family: var(--font-mono); font-size: 26px; font-weight: 600; display: block; }
.stat-pill .lbl { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-pill.neu .num { color: var(--gruen); }
.stat-pill.akt .num { color: var(--gold); }
.stat-pill.unv .num { color: var(--ink-muted); }

.diff-list { font-size: 13px; }
.diff-list details { border: 1px solid var(--border); border-radius: var(--radius-s); margin-bottom: 8px; padding: 8px 12px; background: var(--surface); }
.diff-list summary { cursor: pointer; font-weight: 600; }
.diff-field { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; }
.diff-field:first-of-type { border-top: none; }
.diff-field .fname { width: 140px; flex-shrink: 0; color: var(--ink-muted); }
.diff-old { color: var(--rot); text-decoration: line-through; }
.diff-new { color: var(--gruen); }

.warning-box {
  background: #FCF3E3;
  border: 1px solid #E8CE99;
  color: #7A5A1E;
  border-radius: var(--radius-m);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}
.error-box {
  background: #FBEAE7;
  border: 1px solid #E3B3AA;
  color: #8C2E1E;
  border-radius: var(--radius-m);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}
.success-box {
  background: #E7F3EA;
  border: 1px solid #B9DCC1;
  color: #225A36;
  border-radius: var(--radius-m);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- Logs page ---------- */

.log-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.log-entry .when { font-size: 12px; color: var(--ink-muted); font-family: var(--font-mono); }

/* ---------- Misc ---------- */

.back-link { font-size: 13px; margin-bottom: 14px; display: inline-block; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .content { padding: 16px 14px 48px; }
  .topbar { padding: 12px 16px; }
  .data-table { font-size: 13px; }
}

/* ---------- Print ---------- */

@media print {
  .topbar, .no-print, .filter-bar, .back-link { display: none !important; }
  body { background: #fff; }
  .content { max-width: 100%; padding: 0; margin: 0; }
  @page { size: A4; margin: 16mm 14mm; }
  .card { box-shadow: none; border: none; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .map-embed { display: none; }
  a { color: var(--ink); text-decoration: none; }
}
