:root {
  --cream: #F8F4EF;
  --forest: #2C3D2E;
  --gold: #C8A96A;
  --earth: #2A1F14;
  --stone: #8B8680;
  --card: #ffffff;
  --good: #3f7d4e;
  --bad: #b4543a;
  --line: #e7ded2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: var(--cream);
  color: var(--earth);
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 28px;
  background: var(--forest);
  color: var(--cream);
}
header.topbar .brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 24px;
  letter-spacing: 2px;
  font-weight: 600;
}
header.topbar nav { display: flex; gap: 20px; margin-left: auto; }
header.topbar nav a {
  color: var(--cream);
  text-decoration: none;
  opacity: .75;
  font-size: 14px;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
header.topbar nav a:hover, header.topbar nav a.active { opacity: 1; border-color: var(--gold); }
header.topbar .logout-link {
  color: var(--cream);
  text-decoration: none;
  opacity: .75;
  font-size: 14px;
}
header.topbar .logout-link:hover { opacity: 1; }

main { max-width: 1180px; margin: 0 auto; padding: 28px; }

h1 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: 30px; margin: 0 0 4px; }
h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; font-size: 21px; margin: 0 0 14px; }
.sub { color: var(--stone); font-size: 14px; margin: 0 0 24px; }
.note { font-size: 13px; color: var(--stone); }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.page-header h1 { margin-bottom: 4px; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }

select, input, textarea, button {
  font-family: inherit; font-size: 14px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--earth);
}

/* ---------- Buttons: primär/sekundär ---------- */
button, .btn-primary, .btn-secondary {
  cursor: pointer; font-weight: 500; border-radius: 8px; padding: 8px 16px;
}
button, .btn-primary {
  background: var(--forest); color: var(--cream); border: none;
}
button:hover, .btn-primary:hover { background: #243121; }
.btn-secondary {
  background: #fff; color: var(--forest); border: 1px solid var(--forest);
}
.btn-secondary:hover { background: #f0ebe2; }
button.ghost { background: #fff; color: var(--forest); border: 1px solid var(--forest); }
button.ghost:hover { background: #f0ebe2; }
button.mini { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
button:disabled, .btn-primary:disabled, .btn-secondary:disabled { opacity: .5; cursor: default; }

/* ---------- Karten ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 26px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
}
.card .label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--stone); }
.card .value { font-size: 26px; font-weight: 600; margin-top: 6px; }
.card .value.good { color: var(--good); }
.card .value.bad { color: var(--bad); }
.card .hint { font-size: 12px; color: var(--stone); margin-top: 4px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 22px; }

/* ---------- Kennzahlen (Insights) -- KPI-Kacheln ---------- */
.kpi-kachel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 10px; }
.kpi-kachel {
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  min-height: 76px; display: flex; flex-direction: column; justify-content: center;
}
.kpi-kachel-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--stone); }
.kpi-kachel-wert { font-size: 18px; font-weight: 600; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-kachel-klein { font-size: 11px; color: var(--stone); margin-top: 2px; }
.kpi-kachel.kachel-gelb { border-color: var(--gold); background: #fbf3e6; }
.kpi-kachel.kachel-rot { border-color: var(--bad); background: #f7e8e3; }

/* ---------- Kleine KPI-Zeile auf Influencer-Karten (Liste) ---------- */
.infl-kpi-zeile { font-size: 12px; color: var(--stone); margin-top: 4px; }

/* ---------- Status-Badges ---------- */
.status-badge {
  display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 12px; font-weight: 600;
}
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; }
.badge.on { background: #e3efe6; color: var(--good); }
.badge.off { background: #f3e7e2; color: var(--bad); }
.badge.muted { background: #ece9e3; color: var(--stone); }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
thead th { color: var(--stone); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Formular-Grid, 2-spaltig ---------- */
.form-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 20px;
}
.form-grid > label { min-width: 0; }
.form-grid label {
  display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--stone); min-width: 0;
}
.form-grid label input, .form-grid label select, .form-grid label textarea {
  color: var(--earth); width: 100%; min-width: 0; box-sizing: border-box;
}
.form-grid.full { grid-column: 1 / -1; }

/* ---------- Modal-Dialog ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(42, 31, 20, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 14px; padding: 24px 28px; max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toasts ---------- */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200;
}
.toast {
  background: var(--forest); color: var(--cream); padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: var(--bad); }
.toast.toast-ok { background: var(--good); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-action {
  background: rgba(255,255,255,.18); color: inherit; border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.toast-action:hover { background: rgba(255,255,255,.3); }

/* ---------- Kalender ---------- */
.kalender-kopf {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  margin-bottom: 12px;
}
#kalender { background: var(--card); border-radius: 10px; padding: 14px; }
.fc .fc-daygrid-event { cursor: pointer; }

/* ---------- Login-Seite ---------- */
body.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px 40px; max-width: 360px; width: 100%; text-align: center;
}
.login-card h1 { margin-bottom: 4px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

/* ---------- Fehler-/Hinweis-Banner ---------- */
.error-banner {
  background: #f7e8e3; border: 1px solid var(--bad); color: var(--bad);
  border-radius: 8px; padding: 10px 14px; font-size: 14px; margin: 6px 0;
}
.warn-box {
  background: #fbf3e6; border: 1px solid var(--gold); border-radius: 8px;
  padding: 10px 14px; font-size: 14px; margin: 6px 0;
}
.spinner { color: var(--stone); font-size: 14px; }

/* ---------- Status-Zähler-Chips (klickbar = Filter) ---------- */
.status-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.status-chip {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--stone); background: #fff; color: var(--earth); font-size: 12px; font-weight: 600; cursor: pointer;
}
.status-chip .count { font-weight: 700; }
.status-chip.active { border-color: var(--forest); background: #eef1ec; }

/* ---------- Auswahl-Chips (Plattform/Kategorien) ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 99px;
  border: 1px solid var(--stone); background: #fff; color: var(--earth); font-size: 13px; cursor: pointer; user-select: none;
}
.chip.selected { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.chip .x { font-weight: 700; }

/* ---------- Influencer-Karten (Liste) ---------- */
.infl-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.infl-card:last-child { border-bottom: none; }
.infl-card:hover { background: #faf7f2; }
.infl-card .infl-main { min-width: 0; }
.infl-card .infl-handle { font-family: "Cormorant Garamond", Georgia, serif; font-size: 22px; font-weight: 600; }
.infl-card .infl-name { font-size: 14px; color: var(--earth); margin-left: 8px; }
.infl-card .infl-email { font-size: 12px; color: var(--stone); margin-top: 2px; }
.infl-card .infl-info { font-size: 12px; color: var(--stone); margin-top: 4px; }
.infl-card .infl-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ---------- Detailseite: 2 Spalten ---------- */
.detail-grid { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.btn-icon {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--forest); background: #fff;
  color: var(--forest); font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: #f0ebe2; }
.row-akzeptiert { background: #e9f4ec !important; }
.row-erledigt { background: #e9f4ec !important; }
.row-ueberfaellig { background: #f9e7e0 !important; }
.unsaved-hint { font-size: 12px; color: var(--gold); margin-top: 6px; }
.collapsible-body[hidden] { display: none; }
.collapsible-toggle { background: none; border: none; color: var(--forest); font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.disabled-note { font-size: 12px; color: var(--stone); }
.col-preis { white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- Mailverlauf (Detailseite, Schritt 4) ---------- */
.mail-verlauf { display: flex; flex-direction: column; gap: 12px; max-height: 480px; overflow-y: auto; }
.mail-bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #f7f4ee;
}
.mail-bubble.ein { align-self: flex-start; background: #f7f4ee; }
.mail-bubble.aus { align-self: flex-end; background: #e9f4ec; border-color: #cfe6d5; }
.mail-bubble .mail-meta {
  display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--stone); margin-bottom: 4px;
}
.mail-bubble .mail-betreff { font-weight: 600; }
.mail-bubble .mail-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.mail-bubble .mail-voll { font-size: 13px; white-space: pre-wrap; word-break: break-word; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.mail-bubble .mail-anhaenge { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.mail-bubble .mail-anhaenge a { font-size: 12px; }
.mail-bubble .mail-historisch { font-size: 11px; color: var(--stone); font-style: italic; }

/* ---------- Vorschläge "Neu aus Mails" (Detailseite, Schritt 5) ---------- */
.vorschlag-karte {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #faf8f4;
}
.vorschlag-kopf { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--stone); }
.vorschlag-art { font-weight: 600; color: var(--earth); font-size: 13px; }
.vorschlag-wert { margin-top: 4px; font-size: 14px; }
.vorschlag-beleg { margin-top: 4px; font-size: 12px; color: var(--stone); }
.vorschlag-automatisch { font-size: 12px; color: var(--stone); padding: 3px 0; }

/* ---------- Sync-Status (Übersicht) ---------- */
.sync-status { font-size: 13px; color: var(--stone); display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.sync-status button.mini { padding: 3px 10px; }

/* ---------- Versand-Banner (Schritt 6, jede Seite via base.html) ---------- */
.versand-banner {
  background: #fbf3e6; border-bottom: 1px solid var(--gold); color: var(--earth);
  font-size: 13px; text-align: center; padding: 8px 16px;
}

/* ---------- Briefing-Liste (Einstellungen, Schritt 6) ---------- */
.briefing-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.briefing-item:last-child { border-bottom: none; }
.briefing-item.ausgewaehlt { color: var(--forest); font-weight: 600; }

/* ---------- Nicht zugeordnet (Übersicht) ---------- */
.unzugeordnet-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.unzugeordnet-item:last-child { border-bottom: none; }
.unzugeordnet-info { min-width: 0; }
.unzugeordnet-info .absender { font-weight: 600; }
.unzugeordnet-info .betreff { font-size: 13px; color: var(--earth); }
.unzugeordnet-info .datum { font-size: 12px; color: var(--stone); }
.unzugeordnet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.unzugeordnet-actions select { font-size: 13px; padding: 5px 8px; }

/* ---------- Responsive (mobiltauglich) ---------- */
@media (max-width: 900px) {
  header.topbar { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  /* Reihenfolge explizit setzen: Marke, dann das (umbrechende) Menü, dann
     "Abmelden" darunter rechtsbündig -- vorher stand "Abmelden" (kein
     eigenes order, Default 0) noch VOR dem Menü (order 3), siehe Plan,
     Mobil-Fix Top-Navigation. */
  header.topbar .brand { order: 1; }
  header.topbar nav { flex-wrap: wrap; gap: 10px 14px; margin-left: 0; order: 2; width: 100%; }
  header.topbar .logout-link { order: 3; width: 100%; text-align: right; }
  main { padding: 16px; }
  .panel { overflow-x: auto; }
  table { font-size: 13px; }
  th, td { padding: 6px 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 18px 20px; }
  .detail-grid { grid-template-columns: 1fr; }
  /* Kennzahlen-Karte soll auf der schmalen (einspaltigen) Ansicht ganz oben
     stehen, noch vor den Stammdaten (Feinschliff 19.09.26) -- .detail-col
     wird dafür zu display:contents, damit die einzelnen Panels (statt der
     beiden Spalten-Wrapper) direkte Grid-Items von .detail-grid werden und
     sich per order gezielt einzeln verschieben lassen. */
  .detail-col { display: contents; }
  #panel-kennzahlen { order: -1; }
  .infl-card { flex-direction: column; align-items: flex-start; }
  .infl-card .infl-right { align-items: flex-start; }
}

@media (max-width: 700px) {
  /* Kalender: Toolbar lief rechts aus dem Bild ("Monat"-Button abgeschnitten)
     und der Titel brach groß um -- siehe Plan, Mobil-Fix Kalender. FullCalendar
     selbst bekommt height:'auto' + initialView "listMonth" in static/kalender.js;
     hier nur Layout/Größe der Toolbar. */
  .kalender-kopf { flex-direction: column; align-items: flex-start; }
  #kalender { padding: 8px; }
  .fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
  .fc .fc-toolbar-chunk {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  /* .fc-button-group ist der eigentliche (inline-)flex-Container der 3
     verbundenen Ansichts-Buttons (Monat/Woche/Liste) -- ohne flex-wrap hier
     bleiben sie in einer Reihe und können bei sehr schmalen Breiten trotz
     kleinerer Buttons noch über den Rand laufen. */
  .fc .fc-button-group { flex-wrap: wrap; }
  .fc .fc-toolbar-title { font-size: 16px; }
  .fc .fc-button {
    padding: 4px 8px;
    font-size: 12px;
  }
}
