/* ============ CSS RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root[data-theme="dark"] {
  --bg: #052028;
  --bg-elevated: #0a2e38;
  --bg-card: #0e3843;
  --bg-hover: #14454f;
  --border: #1c5562;
  --text: #e8f3f5;
  --text-muted: #91b3bb;
  --text-dim: #5f828b;
  --accent: #08aed6;
  --accent-2: #0883a8;
  --accent-hover: #34c3e6;
  --accent-glow: rgba(8, 174, 214, 0.18);
  --gold: #e0bd4e;
  --gold-deep: #b58033;
  --gold-glow: rgba(224, 189, 78, 0.20);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

:root[data-theme="light"] {
  --bg: #f1f9fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #e6f4f8;
  --border: #d0e6ec;
  --text: #06303b;
  --text-muted: #557b84;
  --text-dim: #8aa6ad;
  --accent: #009fc3;
  --accent-2: #007a96;
  --accent-hover: #08aed6;
  --accent-glow: rgba(0, 159, 195, 0.14);
  --gold: #b58033;
  --gold-deep: #946726;
  --gold-glow: rgba(181, 128, 51, 0.16);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 16px 40px -8px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

html, body { height: 100%; font-family: 'Inter', -apple-system, system-ui, sans-serif; }
body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ============ ICONS ============ */
.ico { width: 18px; height: 18px; flex-shrink: 0; }

/* ============ LOGIN ============ */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at top left, var(--accent-glow), transparent 50%),
              radial-gradient(circle at bottom right, var(--gold-glow), transparent 50%),
              var(--bg);
  z-index: 100;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-mark {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: #05242c;
  box-shadow: 0 12px 32px var(--gold-glow);
}
.login-logo h1 { font-size: 24px; margin-bottom: 4px; }
.login-logo p { color: var(--text-muted); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.hint { color: var(--text-dim); font-size: 12px; text-align: center; }

/* ============ FIELDS / BUTTONS ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.field input, .field select, .field textarea, input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #dc2626; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }
.menu-toggle { display: none; }

/* ============ APP LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: 100vh;
  grid-template-rows: 100dvh;
  height: 100vh;
  height: 100dvh;
}
.sidebar, .main { min-height: 0; }
.main { min-width: 0; }   /* verhindert, dass breite Inhalte (Tabellen/Code) die Spalte aufblähen */

/* ============ SIDEBAR ============ */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #05242c;
}
.brand-text strong { font-size: 15px; display: block; }
.brand-text span { font-size: 12px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.nav::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.sidebar-footer { flex-shrink: 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item .ico, .theme-toggle .ico, .logout .ico { width: 17px; height: 17px; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-hover);
}
.nav-item .badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-muted);
}

.sidebar-footer { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border); }
.theme-toggle, .logout {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 11px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
}
.theme-toggle:hover, .logout:hover { background: var(--bg-hover); color: var(--text); }

/* ============ MAIN AREA ============ */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 16px;
  background: var(--bg);
}
.search-wrap {
  flex: 1; max-width: 480px;
  position: relative;
}
.search-wrap .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-wrap input { padding-left: 38px; }

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
}
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: white;
}
.user-info strong { font-size: 13px; display: block; }
.user-info span { font-size: 11px; color: var(--text-muted); }

.view-container {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;   /* kein horizontales Seiten-Scrollen; breite Inhalte scrollen in sich */
  padding: 24px;
}

/* ============ VIEWS ============ */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-header h1 { font-size: 28px; font-weight: 700; }
.view-actions { display: flex; align-items: center; gap: 8px; }
.view-mode {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-mode .seg {
  padding: 8px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}
.view-mode .seg.active { background: var(--accent); color: white; }

/* ============ STAT CARDS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: white;
}
.stat-icon .ico { width: 22px; height: 22px; }
.stat-body { flex: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; display: block; }
.stat-trend { font-size: 12px; color: var(--text-muted); }
.stat-trend.positive { color: var(--success); }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  min-width: 0;   /* Karten dürfen in Grids schrumpfen statt zu überlaufen */
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 { font-size: 16px; font-weight: 600; }
.card .link { color: var(--accent); font-size: 13px; font-weight: 500; }
.card .link:hover { text-decoration: underline; }

.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 980px) { .dash-row { grid-template-columns: 1fr; } }

.recent-list, .activity-feed { display: flex; flex-direction: column; gap: 12px; }

.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.recent-item:hover { background: var(--bg-hover); }
.recent-thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-size: 18px;
  overflow: hidden;
  flex-shrink: 0;
}
.recent-thumb.has-photo { background: #111827; }
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-info { flex: 1; }
.recent-info strong { font-size: 14px; display: block; }
.recent-info span { font-size: 12px; color: var(--text-muted); }
.recent-price { font-weight: 700; font-size: 14px; color: var(--success); }

.activity-item {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
}
.activity-item p { font-size: 13px; margin-bottom: 2px; }
.activity-item .time { font-size: 11px; color: var(--text-muted); }



/* ============ QUALITY MONITOR ============ */
.quality-monitor {
  margin: -4px 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.quality-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.quality-head strong { display: block; font-size: 15px; }
.quality-head span { display: block; color: var(--text-muted); font-size: 12px; }
.quality-score { text-align: right; }
.quality-score strong { color: var(--success); font-size: 20px; line-height: 1; }
.quality-items {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.quality-item {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.quality-item:hover { transform: translateY(-1px); background: var(--bg-hover); border-color: var(--accent); }
.quality-item strong { display: block; font-size: 22px; line-height: 1; margin-bottom: 6px; }
.quality-item span { display: block; font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.quality-item small { color: var(--text-muted); font-size: 11px; line-height: 1.3; }
.quality-item.danger strong { color: var(--danger); }
.quality-item.warning strong { color: var(--warning); }
@media (max-width: 980px) { .quality-items { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .quality-items { grid-template-columns: 1fr; } .quality-head { align-items: flex-start; } }

/* ============ PROPERTIES ============ */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
}

.properties-container.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.property-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.property-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.property-img {
  height: 160px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  position: relative;
  display: grid; place-items: center;
  color: white;
  font-size: 48px;
  overflow: hidden;
}
.property-img.has-photo { background: #111827; }
.property-img.has-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.38), transparent 42%, rgba(0,0,0,0.48));
  pointer-events: none;
}
.property-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.property-img.has-photo .property-status, .property-img.has-photo .photo-count { z-index: 2; }
.photo-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  backdrop-filter: blur(8px);
}
.property-status {
  position: absolute;
  top: 12px; left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  color: white;
}
.property-status.pending { background: rgba(245, 158, 11, 0.9); }
.property-status.active { background: rgba(16, 185, 129, 0.9); }
.property-status.sold { background: rgba(100, 116, 139, 0.9); }

.property-body { padding: 16px; }
.property-title { font-size: 14px; font-weight: 600; line-height: 1.3; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 36px; }
.property-location {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 12px;
}
.property-meta {
  display: flex; gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.property-meta span { display: inline-flex; align-items: center; gap: 4px; }
.property-meta .ico { width: 14px; height: 14px; }
.property-price {
  font-size: 18px; font-weight: 700; color: var(--accent);
}
.property-source {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 4px;
  color: var(--text-muted);
  margin-left: 8px;
}

.properties-container.list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.properties-container.list .property-card {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  height: auto;
}
.properties-container.list .property-card:hover { transform: none; background: var(--bg-hover); }
.properties-container.list .property-img {
  height: 64px;
  width: 80px;
  border-radius: var(--radius-sm);
  font-size: 24px;
}
.properties-container.list .property-status { display: none; }

/* ============ TABLES ============ */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;   /* breite Tabellen scrollen IN der Karte (nicht die ganze Seite) */
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-hover); }
.table-actions { display: flex; gap: 4px; }
.table-actions button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-muted);
}
.table-actions button:hover { background: var(--bg-hover); color: var(--text); }
.table-actions .delete:hover { color: var(--danger); border-color: var(--danger); }

/* ============ AUTO-UPLOAD ============ */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 980px) { .upload-grid { grid-template-columns: 1fr; } }

.json-input {
  min-height: 200px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}
.upload-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.code-block {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  max-width: 100%;
  word-break: break-all;
}
.code-block-multiline {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
  overflow-x: auto;
  max-width: 100%;
}

.upload-log {
  max-height: 400px;
  overflow-y: auto;
}
.upload-log-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.upload-log-entry:last-child { border-bottom: none; }
.upload-log-entry .status-pill { width: fit-content; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.status-pill.green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-pill.orange { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.status-pill.red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.status-pill.blue { background: rgba(59, 130, 246, 0.15); color: var(--info); }

/* ============ CALENDAR ============ */
.calendar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 400px;
  display: grid; place-items: center;
  color: var(--text-muted);
}

/* ============ SETTINGS ============ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.settings-grid .card .field { margin-bottom: 12px; }
.integration-list { display: flex; flex-direction: column; gap: 12px; }
.integration-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: grid; place-items: center;
  animation: fadeIn 0.2s;
  padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 720px; width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 { font-size: 18px; }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-body .field { margin-bottom: 14px; }
.modal-body .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ============ TOAST ============ */
#toast-root {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 300;
  display: flex; flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  min-width: 280px;
  font-size: 14px;
}
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast .ico { color: var(--success); }
.toast.error .ico { color: var(--danger); }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon-big {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--bg-elevated);
  display: grid; place-items: center;
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(310px, 86vw);
    display: flex;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 260;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 250;
  }
  .sidebar-backdrop[hidden] { display: none; }
  body.nav-open { overflow: hidden; }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar .search-wrap { display: block; max-width: none; }
  .topbar-actions { margin-left: 6px; gap: 6px; }
  .user-info { display: none; }
  #voice-btn, #chat-btn { display: none; }      /* Topbar auf dem Handy entschlacken */
  .view-header { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 18px; }
  .view-header h1 { font-size: 22px; }
  .view-actions { width: 100%; flex-wrap: wrap; }
  .view-actions > button, .view-actions > select { flex: 1 1 auto; justify-content: center; }
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .quality-items { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .view-container { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
  .modal-body .field-row { grid-template-columns: 1fr; }
  /* Kontakt-Tabellen als gestapelte Karten statt abgeschnittener Tabelle */
  #owners-table thead, #buyers-table thead { display: none; }
  #owners-table, #buyers-table, #owners-table tbody, #buyers-table tbody { display: block; width: 100%; }
  #owners-table tr, #buyers-table tr {
    display: block; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; margin-bottom: 10px; background: var(--bg);
  }
  #owners-table tr:hover, #buyers-table tr:hover { background: var(--bg); }
  #owners-table td, #buyers-table td { display: block; border: none; padding: 3px 0; text-align: left; }
  #owners-table td::before, #buyers-table td::before {
    content: attr(data-label); display: block;
    color: var(--text-muted); font-size: 11px; font-weight: 700; margin-bottom: 2px;
  }
  #owners-table td:first-child, #buyers-table td:first-child { font-size: 16px; margin-bottom: 6px; }
  #owners-table td:first-child::before, #buyers-table td:first-child::before { content: ""; margin: 0; }
  #owners-table td:last-child, #buyers-table td:last-child { margin-top: 8px; }
  #owners-table .table-actions, #buyers-table .table-actions { justify-content: flex-start; }
}

/* ============ REMINDERS ============ */
.reminders-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.reminder-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  background: var(--bg);
  transition: all 0.15s;
}
.reminder-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.reminder-item.overdue { border-left: 3px solid var(--danger); }
.reminder-item.due { border-left: 3px solid var(--warning); }
.reminder-item.done { opacity: 0.5; text-decoration: line-through; }
.reminder-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.reminder-check.done { background: var(--success); border-color: var(--success); color: white; }
.reminder-body { flex: 1; }
.reminder-title { font-weight: 600; font-size: 14px; }
.reminder-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.reminder-date { padding: 2px 8px; border-radius: 4px; background: var(--bg-elevated); }
.reminder-date.overdue { background: rgba(239,68,68,0.15); color: var(--danger); }
.reminder-date.due { background: rgba(245,158,11,0.15); color: var(--warning); }

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

/* ============ MESSAGES (Templates) ============ */
.messages-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}
.template-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.template-item:hover { background: var(--bg-hover); border-color: var(--accent); }
.template-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.template-channel {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--accent-hover);
}
.template-channel.sms { background: rgba(132,204,22,0.15); color: #84cc16; }
.template-channel.email { background: var(--accent-glow); color: var(--accent); }
.template-channel.viber { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.template-preview { font-size: 12px; color: var(--text-muted); max-height: 36px; overflow: hidden; }

.msg-history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.msg-history-item:last-child { border-bottom: none; }

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

/* ============ REPORTS ============ */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-card {
  text-align: center;
  padding: 24px 16px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 8px; }
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: block;
  margin-bottom: 4px;
}
.kpi-sub { font-size: 11px; color: var(--text-muted); }

.chart-bars { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.chart-bar {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.chart-bar-label { font-weight: 500; }
.chart-bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
  transition: width 0.5s ease;
}
.chart-bar-value { text-align: right; font-weight: 600; color: var(--accent); font-size: 13px; }

/* ============ BULK ACTIONS BAR ============ */
.bulk-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.bulk-bar strong { font-size: 14px; }
.bulk-bar .bulk-actions { display: flex; gap: 6px; margin-left: auto; }
.bulk-bar button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.bulk-bar button:hover { background: rgba(255,255,255,0.3); }
.property-checkbox {
  position: absolute; top: 12px; left: 12px;
  z-index: 5;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: rgba(0,0,0,0.5);
  display: grid; place-items: center;
  cursor: pointer;
}
.property-checkbox input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ============ TABBED MODAL ============ */
.modal.modal-large { max-width: 920px; }
.tabs-nav {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.2s; }
.tab-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* ============ CHECKBOX GRID ============ */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
}
.checkbox-grid label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.checkbox-grid label:hover { background: var(--bg-hover); }
.checkbox-grid label.checked, .checkbox-grid input:checked + span {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-hover);
}
.checkbox-grid input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ============ FIELD GROUP ============ */
.field-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.field-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}



/* ============ PROPERTY MEDIA ============ */
.photo-uploader {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.property-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.photo-empty {
  grid-column: 1 / -1;
  min-height: 108px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--text-muted);
  background: var(--bg);
  text-align: center;
  font-size: 13px;
}
.property-photo-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
}
.property-photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-chip {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
}
.property-photo-actions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
}
.property-photo-actions button {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 6px;
  padding: 5px 6px;
  background: rgba(15, 23, 42, 0.76);
  color: white;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.property-photo-actions button:hover { background: rgba(15, 23, 42, 0.92); }
.photo-url-box {
  min-height: 86px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

/* ============ REQUESTS GRID ============ */
.requests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.request-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all 0.2s;
  cursor: pointer;
}
.request-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.request-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.request-customer { font-size: 15px; font-weight: 600; }
.request-matches {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent-hover);
}
.request-criteria { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.criterion {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ MATCHING ============ */
.score-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.score-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}
.score-chip strong { color: var(--accent); }

.match-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.match-group-head {
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.match-group-head h4 { font-size: 14px; }
.match-list { padding: 8px; }
.match-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.match-item:hover { background: var(--bg-hover); }
.match-score {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: white;
}
.match-score.excellent { background: linear-gradient(135deg, #10b981, #059669); }
.match-score.good { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.match-score.fair { background: linear-gradient(135deg, #f59e0b, #d97706); }
.match-score.poor { background: linear-gradient(135deg, #6b7280, #4b5563); }
.match-info strong { font-size: 14px; display: block; }
.match-info .match-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.match-criteria {
  display: flex; gap: 4px;
  flex-wrap: wrap;
  max-width: 240px;
}
.match-criterion {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}
.match-criterion.ok { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.match-criterion.fail { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ============ ACTIVITY TIMELINE ============ */
.activities-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
}
.activity-filters .filter-chk {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 4px;
}
.activity-filters .filter-chk:hover { background: var(--bg-hover); }

.timeline {
  position: relative;
  padding-left: 32px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 11px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}
.timeline-event {
  position: relative;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.timeline-event::before {
  content: '';
  position: absolute;
  left: -27px; top: 18px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-card);
}
.timeline-event.call::before { background: var(--accent); }
.timeline-event.showing::before { background: #10b981; }
.timeline-event.offer::before { background: #f59e0b; }
.timeline-event.email::before { background: #06b6d4; }
.timeline-event.sms::before { background: #84cc16; }
.timeline-event.viber::before { background: #8b5cf6; }
.timeline-event.note::before { background: #94a3b8; }
.timeline-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.timeline-type { font-weight: 600; font-size: 14px; }
.timeline-time { font-size: 11px; color: var(--text-muted); }
.timeline-note { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.timeline-refs {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.timeline-ref {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

/* ============ AI ASSISTANT ============ */
.ai-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}
.ai-chat-card {
  grid-row: 1 / 3;
  display: flex; flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
}
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.ai-msg {
  display: flex; gap: 10px;
  margin-bottom: 14px;
  align-items: flex-start;
}
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 16px;
  background: var(--bg-elevated);
}
.ai-msg.user .ai-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.ai-bubble {
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  max-width: 80%;
}
.ai-msg.user .ai-bubble { background: var(--accent-glow); }
.ai-input {
  display: flex; gap: 8px;
  margin-top: 12px;
}
.ai-input input { flex: 1; }
.ai-input button {
  padding: 10px 16px;
  font-size: 18px;
}
.ai-suggestions { display: flex; flex-direction: column; gap: 8px; }
.ai-suggestion {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.ai-suggestion:hover { background: var(--bg-hover); border-color: var(--accent); }
.ai-suggestion strong { display: block; margin-bottom: 4px; }
.ai-tool {
  display: block; width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.ai-tool:hover { background: var(--bg-hover); border-color: var(--accent); transform: translateX(2px); }

/* Pulse badge */
.badge.pulse {
  background: var(--accent);
  color: white;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@media (max-width: 980px) {
  .ai-grid { grid-template-columns: 1fr; }
  .ai-chat-card { grid-row: auto; height: 60vh; }
  .activities-layout { grid-template-columns: 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   CODEX-IMPORT FEATURES
   ============================================================ */

/* Shared: status pills (extra colors), mini buttons, grids */
.status-pill.amber { background: rgba(245,158,11,0.16); color: var(--warning); }
.status-pill.gray  { background: rgba(136,149,175,0.16); color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.mini-btn .ico { width: 14px; height: 14px; }
.mini-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.mini-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; }
.mini-btn.green { background: rgba(16,185,129,0.15); color: var(--success); border-color: transparent; }
.mini-btn.danger:hover { background: rgba(239,68,68,0.15); color: var(--danger); border-color: var(--danger); }

.empty-row { text-align: center; color: var(--text-muted); padding: 28px; font-size: 14px; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.amount-pos { color: var(--success); font-weight: 700; }
.amount-neg { color: var(--danger); font-weight: 700; }

/* Topbar badges + voice */
.pop-wrap { position: relative; }
.icon-btn { position: relative; }
.topbar-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; font-style: normal;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
.topbar-badge[hidden] { display: none; }
.voice-btn.listening { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse-ring 1.2s infinite; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); } 70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }

/* Popovers */
.popover {
  position: absolute; top: calc(100% + 10px); right: 0; width: 320px; max-height: 420px; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 200; padding: 8px; animation: popIn .14s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pop-head { font-size: 13px; font-weight: 700; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.pop-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; color: var(--text); }
.pop-item:hover { background: var(--bg-hover); }
.pop-item strong { display: block; font-size: 13px; font-weight: 600; }
.pop-item .muted { font-size: 11px; }
.pop-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--text-dim); }
.pop-dot.green { background: var(--success); } .pop-dot.amber { background: var(--warning); }
.pop-dot.red { background: var(--danger); } .pop-dot.indigo { background: var(--accent); }
.pop-empty { padding: 18px 10px; text-align: center; color: var(--text-muted); font-size: 13px; }
.pop-chat-form { display: flex; gap: 6px; padding: 8px 6px; }
.pop-chat-form input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text); font-size: 13px; }
.pop-chat-form button { padding: 8px 12px; }

/* Acquisition pipeline */
.acq-stats, .doc-stats { margin-bottom: 18px; }
.pipeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .pipeline { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .pipeline { grid-template-columns: 1fr; } }
.pipe-col { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.pipe-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.pipe-count { font-style: normal; background: var(--bg-hover); color: var(--text-muted); border-radius: 10px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.pipe-hint { font-size: 11px; color: var(--text-dim); margin: 2px 0 10px; }
.pipe-body { display: flex; flex-direction: column; gap: 10px; }
.pipe-empty { text-align: center; color: var(--text-dim); padding: 14px; font-size: 13px; }
.lead-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px; transition: all .15s; }
.lead-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lead-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lead-name { font-weight: 700; font-size: 13px; }
.lead-score { font-size: 12px; font-weight: 800; min-width: 30px; text-align: center; border-radius: 8px; padding: 2px 6px; color: #fff; }
.lead-score.high { background: var(--success); } .lead-score.mid { background: var(--warning); } .lead-score.low { background: var(--text-dim); }
.lead-meta { font-size: 12px; color: var(--text); margin-top: 5px; }
.lead-meta.muted { color: var(--text-muted); }
.lead-actions { display: flex; gap: 5px; margin-top: 10px; flex-wrap: wrap; }

/* Finance chart (monthly bars) */
#chart-finance { display: flex; flex-direction: row; align-items: flex-end; gap: 8px; height: 200px; padding-top: 10px; }
.fin-month { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.fin-bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.fin-bar { width: 42%; min-height: 2px; border-radius: 4px 4px 0 0; transition: height .4s ease; }
.fin-bar.inc { background: linear-gradient(180deg, var(--success), #059669); }
.fin-bar.exp { background: linear-gradient(180deg, var(--danger), #b91c1c); }
.fin-month-label { font-size: 10px; color: var(--text-muted); }
.chart-bar-fill.expense { background: linear-gradient(90deg, var(--danger), #f97316); }

/* Portal feed controls */
.feed-controls { display: flex; gap: 14px; align-items: flex-end; margin: 12px 0; }
#feed-preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: 12px; }

/* ============ QUALITY REPAIR TOOLS ============ */
.quality-repair-card .json-input { min-height: 120px; }
.repair-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.repair-stats > div {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.repair-stats strong { display: block; font-size: 24px; line-height: 1; color: var(--accent); margin-bottom: 6px; }
.repair-stats span { color: var(--text-muted); font-size: 12px; }
.match-quality {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-glow);
  color: var(--accent-hover);
}
.match-quality.excellent { background: rgba(16,185,129,.16); color: var(--success); }
.match-quality.good { background: rgba(59,130,246,.16); color: #60a5fa; }
.match-quality.broad { background: rgba(245,158,11,.16); color: var(--warning); }
.match-warning {
  display: inline-flex;
  margin: 4px 6px 0 0;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(245,158,11,.13);
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
}
.match-criterion.weak { opacity: .75; border-style: dashed; }
@media (max-width: 980px) { .repair-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .repair-stats { grid-template-columns: 1fr; } }

/* ============ PAGINIERUNG ============ */
.pager-slot:empty { display: none; }
.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin: 18px 2px 6px;
}
.pager-info { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.pager-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-btn {
  min-width: 36px; height: 36px;
  padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.pager-btn:hover:not(:disabled):not(.active) { background: var(--bg-hover); border-color: var(--accent); }
.pager-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; cursor: default;
}
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-dots { color: var(--text-dim); padding: 0 2px; }
@media (max-width: 560px) { .pager { justify-content: center; } }

/* ============ KONTAKT-AKTIONEN (Anruf/WhatsApp/Viber/SMS) ============ */
.cell-phone { display: block; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.cact-row { display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.cact {
  width: 26px; height: 26px;
  display: inline-grid; place-items: center;
  border-radius: 7px;
  font-size: 13px; font-weight: 800;
  text-decoration: none; line-height: 1;
  border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text);
  transition: transform .12s ease, filter .12s ease;
}
.cact:hover { transform: translateY(-1px); filter: brightness(1.08); }
.cact.call  { background: var(--accent); border-color: transparent; color: #fff; }
.cact.wa    { background: #25D366; border-color: transparent; color: #053b1e; }
.cact.viber { background: #7360F2; border-color: transparent; color: #fff; }
.cact.sms   { background: var(--bg-hover); }
.cact-sm { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
