/* =============================================================
   Schreibwaren Stumpf CRM — internes Arbeitswerkzeug
   Design-Tokens 1:1 aus website/css/style.css übernommen.
   Kein Framework, kein Build-Schritt: eine Datei, direkt ausgeliefert.
   ============================================================= */

:root {
  /* ---- Marken-Farben (verbindlich, Logo-Palette) ---- */
  --brand-blue:      #0D2B45;
  --brand-turquoise: #00B4D8;
  --brand-green:     #8BCB3F;
  --brand-yellow:    #FFD23F;
  --brand-purple:    #8E6CCF;
  --brand-orange:    #FF9F1C;

  /* AA-taugliche Textvarianten (Original-Türkis auf Weiß ist zu hell) */
  --brand-turquoise-cta: #0077A0;
  --brand-purple-text:   #6B47B3;
  --brand-orange-text:   #B06A00;
  --brand-green-text:    #5F8F1D;
  --brand-red-text:      #B3261E;

  /* ---- Neutrale Basis / Papier ---- */
  --ink:        var(--brand-blue);
  --ink-soft:   #1e3854;
  --muted:      #4a5b71;
  --muted-soft: #7a8590;
  --paper:      #ffffff;
  --paper-card: #fffdf7;
  --paper-app:  #fbf7ee;
  --paper-warm: #FFF6DC;
  --paper-cool: #E2F6FB;
  --tint-purple:#F1EBFB;
  --tint-green: #EEF8E0;
  --tint-orange:#FFEFDC;
  --tint-red:   #FDECEA;
  --line:       #e6ded0;
  --line-soft:  #ede4d2;
  --line-cool:  #e2e8f0;

  /* ---- Typografie ---- */
  --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --font-mono:    ui-monospace, "SF Mono", "Courier New", monospace;

  --fs-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8rem);
  --fs-sm: clamp(0.82rem, 0.78rem + 0.2vw, 0.9rem);
  --fs-md: clamp(0.95rem, 0.9rem + 0.2vw, 1rem);
  --fs-lg: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem);
  --fs-xl: clamp(1.5rem, 1.25rem + 1vw, 2rem);

  /* ---- Spacing (8pt) ---- */
  --sp-1: 0.5rem;
  --sp-2: 1rem;
  --sp-3: 1.5rem;
  --sp-4: 2rem;
  --sp-6: 3rem;

  /* ---- Form ---- */
  --r-sm: 8px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-full: 999px;
  --shadow-sm: 0 1px 3px rgba(13,43,69,.06), 0 1px 2px rgba(13,43,69,.04);
  --shadow-md: 0 4px 12px rgba(13,43,69,.08), 0 2px 4px rgba(13,43,69,.04);
  --shadow-lg: 0 12px 32px rgba(13,43,69,.10), 0 4px 8px rgba(13,43,69,.06);

  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 180ms;

  --wrap: min(1320px, 94vw);
  --header-h: 68px;
}

/* ---------- Reset + Basis ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper-app);
  background-image:
    radial-gradient(1200px 600px at 12% -8%, rgba(0,180,216,.07), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255,210,63,.10), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

/* `flex: none` ist hier nicht Kosmetik: Icons sind fast überall Flex-Kinder
   (Knöpfe, Kartenköpfe, Navigation, Aufgabenzeilen). Unter Platzdruck
   schrumpft ein Flex-Kind sonst bis auf 0 Breite — der Knopf bleibt sichtbar,
   das Icon darin verschwindet. Genau das passierte beim Löschen-Knopf. */
svg { max-width: 100%; height: auto; display: block; flex: none; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--brand-blue);
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: 1.05rem; }

/* Sichtbarer, ruhiger Fokus — überall gleich. */
:focus-visible {
  outline: 3px solid var(--brand-turquoise);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =============================================================
   Kopfzeile
   ============================================================= */
.header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,253,247,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset;
}
.header__bar {
  width: var(--wrap); margin-inline: auto;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-2);
}
.header__logo img { height: 38px; width: auto; }

.header__search { margin-left: auto; position: relative; flex: 0 1 320px; }
/* Attribut-Selektor mit dabei: die generische Regel für alle Eingabefelder
   weiter unten hat sonst dieselbe Spezifität, steht später — und würde
   Innenabstand und Höhe hier überschreiben. Dann läge die Lupe auf dem Text. */
.header__search input[type="search"] {
  width: 100%; height: 40px; min-height: 40px;
  padding: 0 .9rem 0 2.4rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-full);
  background: var(--paper);
  font: inherit; font-size: var(--fs-sm); color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.header__search input[type="search"]:focus {
  outline: none;
  border-color: var(--brand-turquoise);
  box-shadow: 0 0 0 4px rgba(0,180,216,.15);
}
.header__search svg {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted-soft); pointer-events: none;
}

.header__user { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: var(--r-full);
  background: var(--brand-blue); color: #fff;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; letter-spacing: .03em;
}
.header__user-meta { line-height: 1.25; }
.header__user-name { font-size: var(--fs-sm); font-weight: 600; }
.header__user-role { font-size: var(--fs-xs); color: var(--muted-soft); }

/* Hauptnavigation (Desktop) */
.nav {
  border-top: 1px solid var(--line-soft);
  background: rgba(251,247,238,.6);
}
.nav__list {
  width: var(--wrap); margin-inline: auto;
  display: flex; gap: .25rem; list-style: none;
  overflow-x: auto; scrollbar-width: none;
}
.nav__list::-webkit-scrollbar { display: none; }
.nav__link {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .8rem 1rem;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.nav__link svg { width: 18px; height: 18px; }
.nav__link:hover { color: var(--brand-blue); }
.nav__link[aria-current="page"] {
  color: var(--brand-blue);
  border-bottom-color: var(--brand-turquoise);
}
.nav__badge {
  min-width: 20px; padding: 0 .35rem;
  border-radius: var(--r-full);
  background: var(--brand-turquoise-cta); color: #fff;
  font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center;
}

/* =============================================================
   Grundraster
   ============================================================= */
.main { width: var(--wrap); margin-inline: auto; padding: var(--sp-3) 0 var(--sp-6); }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  gap: var(--sp-2); margin-bottom: var(--sp-3);
}
.page-head__text { flex: 1 1 260px; }
.page-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: .2rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.grid { display: grid; gap: var(--sp-2); }
.grid--kpi   { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
/* `min(330px, 100%)` statt `330px`: bei 320px Bildschirmbreite bleibt nach dem
   Innenabstand nur 288px übrig — eine harte Untergrenze von 330px würde die
   Spur breiter machen als den Bildschirm und die Seite seitlich verschieben. */
.grid--halves{ grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); }
.grid--detail{ grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .grid--detail { grid-template-columns: 1fr; } }

.stack { display: grid; gap: var(--sp-2); }

/* =============================================================
   Karten im Papeterie-Stil
   ============================================================= */
.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.card__head {
  display: flex; align-items: center; gap: .7rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, var(--paper-app), transparent);
  border-bottom: 1px solid var(--line-soft);
}
.card__head h2, .card__head h3 { flex: 1 1 auto; font-size: 1rem; }
.card__body { padding: 1.25rem; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: .8rem 1.25rem;
  border-top: 1px dashed var(--line);
  background: rgba(251,247,238,.5);
  font-size: var(--fs-sm);
}

/* Kennzahl-Kachel.
   Die Farbe markiert die Kategorie, aber als Punkt und weicher Farbschein —
   nicht als Balkenkante. Die Website arbeitet genauso (--shadow-cat auf den
   Kategoriekarten); eine dicke farbige Kante wäre fremd und sähe nach
   Standard-Dashboard aus. */
.kpi {
  display: block;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  color: var(--accent, var(--brand-turquoise));
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease);
}
a.kpi:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-md), 0 10px 26px -14px currentColor;
}
.kpi__label {
  display: flex; align-items: center; gap: .45rem;
  font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted-soft); font-weight: 700;
}
.kpi__label::before {
  content: ""; flex: none;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent, var(--brand-turquoise));
}
.kpi__value {
  font-family: var(--font-display);
  font-size: 2.1rem; line-height: 1.1; font-weight: 700;
  color: var(--brand-blue); margin-top: .25rem;
}
.kpi__hint { font-size: var(--fs-xs); color: var(--muted); margin-top: .15rem; }
.kpi--turquoise { --accent: var(--brand-turquoise); }
.kpi--yellow    { --accent: var(--brand-yellow); }
.kpi--orange    { --accent: var(--brand-orange); }
.kpi--green     { --accent: var(--brand-green); }
.kpi--purple    { --accent: var(--brand-purple); }
.kpi--red       { --accent: #E4572E; }

/* =============================================================
   Schaltflächen
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: 0 1.15rem;
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  border-radius: 14px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease-out);
}
.btn svg { width: 17px; height: 17px; }
.btn--primary {
  background: var(--brand-blue); color: #fff; border-color: var(--brand-blue);
  box-shadow: 0 6px 16px -6px rgba(13,43,69,.35), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn--primary:hover { transform: translateY(-1px); background: #143857; }
.btn--secondary {
  background: rgba(255,255,255,.7); color: var(--brand-blue);
  border-color: color-mix(in srgb, var(--brand-blue) 22%, transparent);
  box-shadow: 0 2px 6px -2px rgba(13,43,69,.12), inset 0 1px 0 rgba(255,255,255,.5);
}
.btn--secondary:hover { transform: translateY(-1px); background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }
.btn--accent {
  background: var(--brand-yellow); color: var(--brand-blue); border-color: var(--brand-yellow);
  box-shadow: 0 6px 16px -6px rgba(255,210,63,.55);
}
.btn--accent:hover { transform: translateY(-1px); background: #ffda63; }
.btn--danger { background: transparent; color: var(--brand-red-text); border-color: color-mix(in srgb, var(--brand-red-text) 35%, transparent); }
.btn--danger:hover { background: var(--brand-red-text); color: #fff; }
.btn--small { min-height: 36px; padding: 0 .8rem; font-size: var(--fs-xs); border-radius: 11px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Schnellaktionen als Zeile */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* =============================================================
   Formulare
   ============================================================= */
.field { display: grid; gap: .35rem; }
.field > label, .label {
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted-soft);
}
input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%;
  padding: .7rem .85rem;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-sm);
  color: var(--ink); background: var(--paper);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-turquoise);
  box-shadow: 0 0 0 4px rgba(0,180,216,.15);
}
input[disabled], textarea[disabled], select[disabled] { background: var(--paper-app); color: var(--muted); }

.form-grid { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.checkline { display: flex; align-items: center; gap: .5rem; font-size: var(--fs-sm); }
.checkline input { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--brand-turquoise-cta); }

.hint { font-size: var(--fs-xs); color: var(--muted); }
.error-text { font-size: var(--fs-xs); color: var(--brand-red-text); font-weight: 600; }

/* =============================================================
   Meldungen
   ============================================================= */
.flash {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .85rem 1.1rem; margin-bottom: var(--sp-2);
  border-radius: var(--r-md); font-size: var(--fs-sm);
  border: 1px solid var(--line);
  background: var(--tint-green); border-color: #cfe4ac; color: #35520f;
}
.flash--error { background: var(--tint-red); border-color: #f2c9c4; color: #7d1d16; }
.flash--info  { background: var(--paper-cool); border-color: #bfe6f2; color: #10495e; }
.flash--warn  { background: var(--paper-warm); border-color: #f0dfa4; color: #6b5410; }
.flash strong { display: block; }

/* =============================================================
   Abzeichen / Status
   ============================================================= */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .22rem .6rem;
  border-radius: var(--r-full);
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--plain::before { display: none; }

.st-neu               { background: var(--paper-cool);  color: #0b5a75; border-color: #bfe6f2; }
.st-in_bearbeitung    { background: var(--tint-orange); color: var(--brand-orange-text); border-color: #f6d7ae; }
.st-rueckfrage        { background: var(--tint-purple); color: var(--brand-purple-text); border-color: #ddd0f3; }
.st-wartet_auf_kunden { background: var(--paper-warm);  color: #6b5410; border-color: #f0dfa4; }
.st-erledigt          { background: var(--tint-green);  color: var(--brand-green-text); border-color: #cfe4ac; }
.st-archiviert        { background: #f1f2f4;            color: var(--muted); border-color: #dcdfe4; }

.pr-niedrig  { background: #f1f2f4; color: var(--muted); border-color: #dcdfe4; }
.pr-normal   { background: var(--paper-cool); color: #0b5a75; border-color: #bfe6f2; }
.pr-hoch     { background: var(--tint-orange); color: var(--brand-orange-text); border-color: #f6d7ae; }
.pr-dringend { background: var(--tint-red); color: var(--brand-red-text); border-color: #f2c9c4; }

.tag {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem; border-radius: var(--r-full);
  font-size: .7rem; font-weight: 600;
  background: var(--paper-cool); color: #0b5a75; border: 1px solid #bfe6f2;
}
.tag--green { background: var(--tint-green); color: var(--brand-green-text); border-color: #cfe4ac; }
.tag--purple{ background: var(--tint-purple); color: var(--brand-purple-text); border-color: #ddd0f3; }
.tag--orange{ background: var(--tint-orange); color: var(--brand-orange-text); border-color: #f6d7ae; }
.tag--yellow{ background: var(--paper-warm); color: #6b5410; border-color: #f0dfa4; }
.tag--blue  { background: #e6ecf3; color: var(--brand-blue); border-color: #ccd8e4; }

.ticket {
  font-family: var(--font-mono); font-size: .82rem; font-weight: 700;
  color: var(--brand-turquoise-cta); letter-spacing: .03em;
}

/* =============================================================
   Tabellen — ab 760px Kartenansicht statt Scrollbalken
   ============================================================= */
.table-wrap { width: 100%; overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
}
table.data th {
  text-align: left; padding: .7rem 1rem;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted-soft); font-weight: 700;
  background: var(--paper-app); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: .85rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { transition: background var(--dur-fast) var(--ease); }
table.data tbody tr:hover { background: rgba(226,246,251,.45); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data a.rowlink { font-weight: 600; color: var(--brand-blue); }
table.data a.rowlink:hover { color: var(--brand-turquoise-cta); }

@media (max-width: 760px) {
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    margin: 0 1rem 0.75rem;
    padding: .35rem .2rem;
  }
  table.data td {
    display: flex; gap: 1rem; align-items: baseline;
    border-bottom: 1px dashed var(--line-soft);
    padding: .55rem .9rem;
    /* Ohne `anywhere` bestimmt das längste ungetrennte Wort — eine lange
       E-Mail-Adresse, ein Firmenname — die Mindestbreite der Zelle. Die Karte
       würde dann seitlich scrollen statt umzubrechen. */
    min-width: 0;
    overflow-wrap: anywhere;
  }
  table.data td:last-child { border-bottom: 0; }
  table.data td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted-soft); font-weight: 700;
  }
  table.data td[data-label=""]::before { content: none; }
}

.empty {
  padding: var(--sp-4) var(--sp-2);
  text-align: center; color: var(--muted);
}
.empty__icon { width: 44px; height: 44px; margin: 0 auto .7rem; color: var(--line); }

/* Blätterleiste */
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; justify-content: center; padding: 1rem; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 .6rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--paper); font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
}
.pagination a:hover { border-color: var(--brand-turquoise); color: var(--brand-blue); }
.pagination .is-current { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }
.pagination .is-disabled { opacity: .4; }
.pagination__info { width: 100%; text-align: center; font-size: var(--fs-xs); color: var(--muted); }

/* =============================================================
   Filterleiste
   ============================================================= */
.filters {
  display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}
.filters__actions { display: flex; gap: .5rem; align-items: end; }
.chiprow { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .85rem; border-radius: var(--r-full);
  border: 1px solid var(--line); background: var(--paper);
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--brand-turquoise); color: var(--brand-blue); }
.chip[aria-current="true"], .chip.is-active {
  background: var(--brand-blue); border-color: var(--brand-blue); color: #fff;
}
.chip__count {
  padding: 0 .4rem; border-radius: var(--r-full);
  background: rgba(13,43,69,.08); font-size: .68rem;
}
.chip.is-active .chip__count { background: rgba(255,255,255,.22); }

/* =============================================================
   Detailansicht
   ============================================================= */
.deflist { display: grid; gap: .9rem; }
.deflist > div { display: grid; gap: .1rem; }
.deflist dt {
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted-soft); font-weight: 700;
}
.deflist dd { font-size: var(--fs-sm); color: var(--ink); word-break: break-word; }

.message-body {
  font-family: var(--font-display);
  font-size: 1.02rem; line-height: 1.75; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 1.1rem 1.25rem;
  white-space: pre-wrap; word-break: break-word;
}

/* Zeitleiste */
.timeline { list-style: none; display: grid; gap: 0; }
.timeline li {
  position: relative;
  padding: .6rem 0 .6rem 1.6rem;
  border-left: 2px solid var(--line);
  font-size: var(--fs-sm);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 1rem;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper-card); border: 2px solid var(--brand-turquoise);
}
.timeline li.is-key::before { background: var(--brand-turquoise); }
.timeline__meta { font-size: var(--fs-xs); color: var(--muted-soft); }

/* Notizen */
.note {
  background: var(--paper-warm);
  border: 1px solid #f0dfa4;
  border-radius: var(--r-md);
  padding: .9rem 1.05rem;
}
.note--important { background: var(--tint-orange); border-color: #f6d7ae; }
.note--pinned { box-shadow: 0 0 0 2px rgba(0,180,216,.25); }
.note__meta {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  font-size: var(--fs-xs); color: var(--muted); margin-bottom: .4rem;
}
.note__body { white-space: pre-wrap; font-size: var(--fs-sm); line-height: 1.65; word-break: break-word; }
.note__history { margin-top: .6rem; font-size: var(--fs-xs); }
.note__history summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.note__history pre {
  white-space: pre-wrap; font-family: inherit;
  background: rgba(255,255,255,.65); border-radius: var(--r-sm);
  padding: .5rem .7rem; margin-top: .4rem; color: var(--muted);
}

/* Aufgabenzeile */
.task {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .8rem 0; border-bottom: 1px dashed var(--line-soft);
}
.task:last-child { border-bottom: 0; }
.task__check { flex: none; }
.task__main { flex: 1 1 auto; min-width: 0; }
.task__title { font-weight: 600; font-size: var(--fs-sm); }
.task--done .task__title { text-decoration: line-through; color: var(--muted); }
.task__meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: var(--fs-xs); color: var(--muted); margin-top: .15rem; }
.task__due--overdue { color: var(--brand-red-text); font-weight: 700; }

/* =============================================================
   Anmeldung
   ============================================================= */
.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--sp-3) var(--sp-2);
}
.auth__card {
  width: min(440px, 100%);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth__head {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  background: linear-gradient(180deg, var(--paper-app), transparent);
  border-bottom: 1px solid var(--line-soft);
  text-align: center;
}
.auth__head img { height: 46px; width: auto; margin: 0 auto var(--sp-2); }
.auth__head p { font-size: var(--fs-sm); color: var(--muted); }
.auth__body { padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.auth__foot {
  padding: 1rem var(--sp-3); text-align: center;
  font-size: var(--fs-xs); color: var(--muted-soft);
  border-top: 1px dashed var(--line);
}
.code-input {
  font-family: var(--font-mono); font-size: 1.4rem;
  letter-spacing: .5em; text-align: center;
}

/* Wiederherstellungscodes */
.codes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem;
  font-family: var(--font-mono); font-size: var(--fs-sm);
}
.codes span {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: .5rem .7rem; text-align: center;
}

.qr {
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 1rem; width: fit-content;
}
.qr svg { width: 200px; height: 200px; }

.secret {
  font-family: var(--font-mono); font-size: var(--fs-sm);
  background: var(--paper); border: 1px dashed var(--line);
  border-radius: var(--r-sm); padding: .55rem .8rem;
  word-break: break-all; user-select: all;
}

/* =============================================================
   Mobile Bottom-Navigation
   ============================================================= */
.bottomnav { display: none; }

@media (max-width: 860px) {
  :root { --wrap: 100%; }
  .header__bar { padding-inline: 1rem; }
  .header__logo img { height: 32px; }
  .header__search { flex-basis: auto; order: 3; width: 100%; padding: 0 0 .7rem; }
  .header__bar { flex-wrap: wrap; padding-top: .6rem; }
  .header__user-meta { display: none; }
  .nav { display: none; }
  .main { padding: var(--sp-2) 1rem calc(var(--sp-6) + 68px); }
  .grid--kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .card { border-radius: var(--r-md); }
  table.data tr { margin-inline: 0; }

  .bottomnav {
    display: block;
    position: fixed; inset: auto 0 0 0; z-index: 50;
    background: rgba(255,253,247,.96);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 20px -8px rgba(13,43,69,.18);
  }
  .bottomnav__list { display: flex; list-style: none; }
  .bottomnav__link {
    flex: 1 1 0; min-height: 60px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .18rem;
    font-size: .66rem; font-weight: 600; color: var(--muted);
    position: relative;
  }
  .bottomnav__link svg { width: 21px; height: 21px; }
  .bottomnav__link[aria-current="page"] { color: var(--brand-turquoise-cta); }
  .bottomnav__link[aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 22%; right: 22%;
    height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-turquoise);
  }
  .bottomnav__badge {
    position: absolute; top: 8px; left: 55%;
    min-width: 17px; height: 17px; padding: 0 .25rem;
    border-radius: var(--r-full);
    background: #E4572E; color: #fff;
    font-size: .6rem; font-weight: 700; line-height: 17px; text-align: center;
  }
}

/* =============================================================
   Druck
   ============================================================= */
@media print {
  body { background: #fff; }
  .header, .nav, .bottomnav, .actions, .no-print { display: none !important; }
  .main { width: 100%; padding: 0; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a[href]::after { content: ""; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Kleine Helfer */
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row--between { justify-content: space-between; }
.divider { height: 1px; background: var(--line-soft); border: 0; margin: var(--sp-2) 0; }
