:root {
  --bg: #f6f7f8;
  --flaeche: #ffffff;
  --flaeche-2: #f1f3f4;
  --rand: #e2e5e8;
  --text: #16201f;
  --text-leise: #67737a;
  --akzent: #0f766e;
  --akzent-sanft: #e2f3f0;
  --warn: #b45309;
  --warn-sanft: #fdf3e3;
  --rot: #b42318;
  --rot-sanft: #fdeceb;
  --gruen: #2f7d32;
  --radius: 10px;
  --schatten: 0 1px 2px rgba(16, 32, 31, .06), 0 4px 12px rgba(16, 32, 31, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111514;
    --flaeche: #181d1c;
    --flaeche-2: #202625;
    --rand: #2b3331;
    --text: #e7ecea;
    --text-leise: #94a19d;
    --akzent: #2dd4bf;
    --akzent-sanft: #12302c;
    --warn: #e0a85c;
    --warn-sanft: #2d2415;
    --rot: #f2837a;
    --rot-sanft: #2f1a18;
    --gruen: #6ee7a8;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }

.seite {
  background: var(--flaeche);
  border-right: 1px solid var(--rand);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.marke { display: flex; gap: 10px; align-items: center; padding: 0 8px 20px; }
.marke-logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--akzent); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.marke-text { display: flex; flex-direction: column; line-height: 1.2; white-space: nowrap; }
.marke-text small { color: var(--text-leise); font-size: 11px; }

#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-leise); font-size: 14px;
}
#nav a .icon { width: 16px; text-align: center; opacity: .8; }
#nav a:hover { background: var(--flaeche-2); color: var(--text); }
#nav a.aktiv { background: var(--akzent-sanft); color: var(--akzent); font-weight: 600; }

.seite-fuss { margin-top: auto; }
.mrr-box {
  background: var(--flaeche-2); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column;
}
.mrr-box small { color: var(--text-leise); font-size: 11px; }
.mrr-box strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.inhalt { min-width: 0; display: flex; flex-direction: column; }
.kopf {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px 16px; padding: 20px 26px;
  border-bottom: 1px solid var(--rand);
  background: var(--flaeche);
  position: sticky; top: 0; z-index: 5;
}
.kopf-aktionen { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.view { padding: 22px 26px 60px; }

/* ---------- Bausteine ---------- */
.btn {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--rand); background: var(--flaeche);
  color: var(--text); cursor: pointer;
}
.btn:hover { background: var(--flaeche-2); }
.btn.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.btn.primaer:hover { filter: brightness(1.08); }
.btn.still { border-color: transparent; background: transparent; color: var(--text-leise); }
.btn.still:hover { background: var(--flaeche-2); color: var(--text); }
.btn.klein { padding: 4px 9px; font-size: 12px; }
.btn.gefahr { color: var(--rot); }

input, select, textarea {
  font: inherit; font-size: 14px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--rand); background: var(--flaeche);
  color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; border-color: var(--akzent); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--text-leise); margin-bottom: 4px; }
.suche { width: 240px; }

.karte {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); box-shadow: var(--schatten);
}
.karte-kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--rand);
}
.karte-koerper { padding: 14px 16px; }
.karte-koerper.flach { padding: 0; overflow-x: auto; }

.gitter { display: grid; gap: 16px; }
.gitter.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.gitter.zwei { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.abschnitt { margin-bottom: 20px; }

.kpi-karte { padding: 14px 16px; }
.kpi-karte small { display: block; color: var(--text-leise); font-size: 12px; margin-bottom: 6px; }
.kpi-wert { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-hinweis { font-size: 12px; color: var(--text-leise); margin-top: 4px; }

.marke-pille, .pille {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 8px; border-radius: 99px;
  background: var(--flaeche-2); color: var(--text-leise);
  white-space: nowrap;
}
.pille.kunde { background: var(--akzent-sanft); color: var(--akzent); }
.pille.lead { background: var(--warn-sanft); color: var(--warn); }
.pille.ehemalig { background: var(--rot-sanft); color: var(--rot); }
.pille.warn { background: var(--warn-sanft); color: var(--warn); }
.pille.rot { background: var(--rot-sanft); color: var(--rot); }
.pille.gut { background: var(--akzent-sanft); color: var(--akzent); }

/* ---------- Tabelle ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-leise); padding: 10px 14px;
  border-bottom: 1px solid var(--rand); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--rand); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.klickbar:hover { background: var(--flaeche-2); cursor: pointer; }
.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.leise { color: var(--text-leise); }
.mini { font-size: 12px; }

.leer { padding: 34px 16px; text-align: center; color: var(--text-leise); font-size: 14px; }

/* ---------- Pipeline ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.spalte {
  flex: 0 0 236px; background: var(--flaeche-2);
  border: 1px solid var(--rand); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 190px);
}
.spalte-kopf { padding: 10px 12px; border-bottom: 1px solid var(--rand); }
.spalte-kopf .zeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.spalte-kopf h3 { font-size: 13px; }
.spalte-kopf .summe { font-size: 12px; color: var(--text-leise); font-variant-numeric: tabular-nums; }
.spalte-liste { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 70px; }
.spalte.ziel { outline: 2px dashed var(--akzent); outline-offset: -2px; }

.deal {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 8px; padding: 10px 11px; cursor: grab;
  box-shadow: var(--schatten);
}
.deal:active { cursor: grabbing; }
.deal.zieht { opacity: .4; }
.deal-hotel { font-weight: 600; font-size: 13.5px; }
.deal-titel { font-size: 12px; color: var(--text-leise); margin-top: 1px; }
.deal-zeile { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.deal-wert { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.balken { height: 3px; background: var(--rand); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.balken i { display: block; height: 100%; background: var(--akzent); }

/* ---------- Detail ---------- */
.detail-kopf { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-leise); font-size: 13px; margin-top: 6px; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: 11px 16px; border-bottom: 1px solid var(--rand); display: flex; gap: 12px; align-items: flex-start; }
.liste li:last-child { border-bottom: none; }
.liste .wachs { flex: 1; min-width: 0; }
.zeit { font-size: 11px; color: var(--text-leise); font-variant-numeric: tabular-nums; white-space: nowrap; }

.aufgabe { display: flex; gap: 11px; align-items: flex-start; }
.aufgabe input[type=checkbox] { width: 16px; height: 16px; margin-top: 2px; flex: none; accent-color: var(--akzent); }
.aufgabe.fertig .wachs > div:first-child { text-decoration: line-through; color: var(--text-leise); }
/* Weitergeleitete Nachrichten bringen lange Links und Pfade mit. */
.aufgabe .mini { overflow-wrap: anywhere; }

.verlauf-form { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--rand); flex-wrap: wrap; }
.verlauf-form select { width: 120px; flex: none; }
.verlauf-form input[type=text] { flex: 1; min-width: 180px; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--rand); border-radius: 12px; padding: 0;
  background: var(--flaeche); color: var(--text);
  max-width: 540px; width: calc(100vw - 32px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .22);
}
dialog::backdrop { background: rgba(10, 18, 17, .45); }
dialog h2 { padding: 18px 20px 0; }
.felder { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 20px; }
.felder .weit { grid-column: 1 / -1; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 99px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 99;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .seite {
    position: static; height: auto; flex-direction: row; align-items: center;
    gap: 10px; padding: 9px 14px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--rand);
  }
  .marke { padding: 0 4px 0 0; flex: none; }
  .marke-text { display: none; }
  #nav { flex-direction: row; flex: none; }
  #nav a { padding: 7px 9px; white-space: nowrap; }
  .seite-fuss { margin: 0 0 0 auto; flex: none; }
  .mrr-box { flex-direction: row; align-items: baseline; gap: 6px; padding: 6px 10px; }
  .mrr-box strong { font-size: 15px; }
  .mrr-box small:last-child { display: none; }
  .kopf { position: static; padding: 14px; }
  .view { padding: 14px 14px 48px; }
  .suche { flex: 1; width: auto; min-width: 130px; }
  .kopf h1 { flex: none; }
  .kopf-aktionen { flex: 1; justify-content: flex-end; }
  .felder { grid-template-columns: 1fr; }
  .spalte { max-height: none; }
  /* Quelle, Priorität und Knopf passen neben dem Text nicht mehr in eine Zeile. */
  .aufgabe { flex-wrap: wrap; justify-content: flex-end; }
  .liste .aufgabe .wachs { flex: 1 1 60%; }
}

@media (max-width: 480px) {
  #nav a span.icon { display: none; }
}
