:root {
  --flaeche-0: #f4f4f2;
  --flaeche-1: #fcfcfb;
  --flaeche-2: #ffffff;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --text-3: #82817c;
  --linie: #e3e3df;
  --akzent: #2a78d6;
  --gut: #008300;
  --warnung: #eda100;
  --kritisch: #e34948;
  --radius: 10px;
  --schatten: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
  /* Spiegelt bewusst PALETTE.hell aus static/js/thema.js: dieselben acht
     Farben, damit eine serverseitig gerenderte Farblegende (z. B. je
     Person) exakt dieselben Töne zeigt wie die clientseitig gezeichneten
     Diagramme. */
  --serie-0: #2a78d6; --serie-1: #008300; --serie-2: #e87ba4; --serie-3: #eda100;
  --serie-4: #1baf7a; --serie-5: #eb6834; --serie-6: #4a3aa7; --serie-7: #e34948;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --flaeche-0: #111110; --flaeche-1: #1a1a19; --flaeche-2: #232322;
    --text-1: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e85;
    --linie: #33332f; --akzent: #3987e5;
    --gut: #3fa63f; --warnung: #c98500; --kritisch: #e66767;
    --schatten: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
    /* Spiegelt PALETTE.dunkel aus thema.js. */
    --serie-0: #3987e5; --serie-1: #008300; --serie-2: #d55181; --serie-3: #c98500;
    --serie-4: #199e70; --serie-5: #d95926; --serie-6: #9085e9; --serie-7: #e66767;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --flaeche-0: #111110; --flaeche-1: #1a1a19; --flaeche-2: #232322;
  --text-1: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e85;
  --linie: #33332f; --akzent: #3987e5;
  --gut: #3fa63f; --warnung: #c98500; --kritisch: #e66767;
  --schatten: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
  --serie-0: #3987e5; --serie-1: #008300; --serie-2: #d55181; --serie-3: #c98500;
  --serie-4: #199e70; --serie-5: #d95926; --serie-6: #9085e9; --serie-7: #e66767;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--flaeche-0);
  color: var(--text-1);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Seitenleiste ---- */
.seitenleiste {
  background: var(--flaeche-1);
  border-right: 1px solid var(--linie);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.marke {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 14px; letter-spacing: -0.01em;
  padding: 4px 10px 20px;
}
.marke .punkt {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--akzent); flex: none;
}
.seitenleiste nav { display: flex; flex-direction: column; gap: 1px; }
.seitenleiste nav a {
  padding: 8px 10px; border-radius: 7px;
  color: var(--text-2); text-decoration: none; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.seitenleiste nav a:hover { background: var(--flaeche-0); color: var(--text-1); }
.seitenleiste nav a.aktiv {
  background: color-mix(in srgb, var(--akzent) 12%, transparent);
  color: var(--akzent); font-weight: 550;
}
.thema-schalter {
  margin-top: auto; padding: 7px 10px; font: inherit; font-size: 12.5px;
  background: none; border: 1px solid var(--linie); border-radius: 7px;
  color: var(--text-2); cursor: pointer;
}
.thema-schalter:hover { color: var(--text-1); border-color: var(--text-3); }

/* ---- Kopf und Unter-Tabs ---- */
.inhalt { min-width: 0; }
.kopf {
  padding: 22px 28px 0;
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche-1);
  position: sticky; top: 0; z-index: 20;
}
.kopf h1 {
  margin: 0 0 14px; font-size: 19px; font-weight: 620; letter-spacing: -0.015em;
}
.unter-tabs { display: flex; gap: 2px; }
.unter-tabs a {
  padding: 8px 13px; color: var(--text-3); text-decoration: none;
  font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.unter-tabs a:hover { color: var(--text-1); }
.unter-tabs a.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); }

main { padding: 24px 28px 56px; }

/* ---- Kacheln ---- */
.kachelreihe {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
}
.kachel {
  background: var(--flaeche-2); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--schatten);
}
.kachel .etikett {
  color: var(--text-3); font-size: 11.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .045em; display: block;
  margin-bottom: 7px;
}
.kachel .wert {
  font-size: 25px; font-weight: 640; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.15; color: var(--text-1);
}
.kachel .zusatz { color: var(--text-3); font-size: 12px; margin-top: 5px; }
.kachel .wert.gut { color: var(--gut); }
.kachel .wert.kritisch { color: var(--kritisch); }
.kachel .wert a, .kachel .zusatz a {
  color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor;
}
.kachel .wert a:hover, .kachel .zusatz a:hover { border-bottom-style: solid; }

/* ---- Diagrammkarten ---- */
.tafelraster { display: grid; gap: 14px; margin-bottom: 14px; }
.tafelraster.zwei { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.tafel {
  background: var(--flaeche-2); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 16px 18px 12px; box-shadow: var(--schatten);
  min-width: 0;
}
.tafel > h2 {
  margin: 0 0 3px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
}
.tafel > .unterzeile {
  color: var(--text-3); font-size: 12px; margin: 0 0 14px;
}
.diagramm { width: 100%; height: 300px; }
.diagramm.hoch { height: 420px; }
.diagramm.karte { height: 540px; border-radius: 8px; overflow: hidden; }

.fallzahl {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  border-radius: 20px; background: var(--flaeche-0);
  color: var(--text-3); font-size: 11px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.fallzahl.schwach { color: var(--warnung); }

.marke-schaetzung {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 5px; font-size: 11px;
  border: 1px dashed var(--warnung); color: var(--warnung);
}

/* Deutlich sichtbare Begruendungs-/Warnbox, z. B. der Erfassungswechsel-
   Hinweis in Trend & Prognose -- ein Absatz reicht dafuer nicht, die
   Aussage darf nicht wie eine beilaeufige Fussnote wirken. */
.hinweis {
  display: flex; gap: 10px; align-items: flex-start;
  background: color-mix(in srgb, var(--warnung) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warnung) 35%, transparent);
  border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px;
  font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.hinweis strong { color: var(--text-1); }
.hinweis .symbol { font-size: 16px; line-height: 1.4; flex: none; color: var(--warnung); }

/* ---- Tabellen ---- */
.tabelle { margin-top: 4px; }
.tabulator {
  background: transparent; border: none;
  font-size: 13px; color: var(--text-1);
}
.tabulator .tabulator-header {
  background: transparent; border-bottom: 1px solid var(--linie); color: var(--text-3);
}
.tabulator .tabulator-header .tabulator-col {
  background: transparent; border-right: none;
  font-weight: 500; font-size: 12px;
}
.tabulator .tabulator-row { background: transparent; border-bottom: 1px solid var(--linie); }
.tabulator .tabulator-row:hover { background: var(--flaeche-0); }
.tabulator .tabulator-row .tabulator-cell {
  border-right: none; padding: 9px 10px; font-variant-numeric: tabular-nums;
}
.tabulator .tabulator-footer { background: transparent; border-top: 1px solid var(--linie); }
.tabulator-col-title { color: var(--text-3); }

/* ---- Statusabzeichen ---- */
.abzeichen {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.abzeichen.gut { background: color-mix(in srgb, var(--gut) 15%, transparent); color: var(--gut); }
.abzeichen.warnung { background: color-mix(in srgb, var(--warnung) 18%, transparent); color: var(--warnung); }
.abzeichen.kritisch { background: color-mix(in srgb, var(--kritisch) 15%, transparent); color: var(--kritisch); }
.abzeichen.neutral { background: var(--flaeche-0); color: var(--text-3); }

/* ---- Formulare ---- */
.formular { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.formular label { display: grid; gap: 5px; font-size: 12px; color: var(--text-3); }
.formular input, .formular select {
  padding: 8px 10px; border: 1px solid var(--linie); border-radius: 7px;
  font: inherit; font-size: 13px; background: var(--flaeche-1); color: var(--text-1);
}
.formular input:focus, .formular select:focus {
  outline: 2px solid color-mix(in srgb, var(--akzent) 45%, transparent);
  outline-offset: 1px; border-color: var(--akzent);
}
.formular fieldset {
  border: 1px solid var(--linie); border-radius: 7px; padding: 7px 12px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0;
}
.formular fieldset legend {
  padding: 0 4px; font-size: 12px; color: var(--text-3);
}
.formular .kontrolle {
  display: inline-flex; flex-direction: row; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-2);
}
.formular .kontrolle input { width: auto; padding: 0; }
.filterleiste { margin-bottom: 14px; }
button.tat {
  padding: 8px 15px; border: 0; border-radius: 7px;
  background: var(--akzent); color: #fff; font: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer;
}
button.tat:hover { filter: brightness(1.07); }
button.leise {
  background: transparent; border: 1px solid var(--linie); color: var(--text-2);
}

/* ---- Anmeldung ---- */
.anmeldeseite { display: grid; place-items: center; min-height: 100vh; background: var(--flaeche-0); }
.anmeldekarte {
  display: grid; gap: 12px; padding: 34px; min-width: 320px;
  border: 1px solid var(--linie); border-radius: 12px;
  background: var(--flaeche-2); box-shadow: var(--schatten);
}
.anmeldekarte h1 { margin: 0 0 6px; font-size: 17px; }
.fehler { color: var(--kritisch); margin: 0; font-size: 13px; }

.leer { color: var(--text-3); font-size: 13px; padding: 28px; text-align: center; }

/* ---- Personenfarbe (Makler/Agenten) ---- */
.punkt-klein {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  flex: none;
}
.profil-name {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 620; margin: 2px 0 16px;
}
table.legende { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
table.legende th {
  text-align: left; color: var(--text-3); font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid var(--linie);
}
table.legende td {
  padding: 6px 8px; border-bottom: 1px solid var(--linie); color: var(--text-2);
}
table.legende td.zahl { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .huelle { grid-template-columns: 1fr; }
  .seitenleiste { position: static; height: auto; flex-direction: row;
                  flex-wrap: wrap; align-items: center; }
  .seitenleiste nav { flex-direction: row; flex-wrap: wrap; }
  main, .kopf { padding-left: 16px; padding-right: 16px; }
}

/* --- Zuletzt verkauft: kompakte Liste der letzten zehn --- */
.zuletzt-zeile {
  display: grid;
  grid-template-columns: 108px 1fr 160px 150px;
  gap: 14px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--linie);
}
.zuletzt-zeile:last-child { border-bottom: 0; }
.zuletzt-datum { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 13px; }
.zuletzt-objekt { font-weight: 500; }
.zuletzt-ort { color: var(--text-3); font-weight: 400; margin-left: 6px; font-size: 13px; }
.zuletzt-makler { color: var(--text-2); font-size: 13px; }
.zuletzt-betrag { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .zuletzt-zeile { grid-template-columns: 1fr; gap: 2px; }
  .zuletzt-betrag { text-align: left; }
}
