/* ==========================================================================
   Jarvis – im Design der Robert-Rösler-Anwendungen
   Farben, Schrift und Rundungen nur im :root-Block. Keine externen Schriften (DSGVO).
   ========================================================================== */
:root {
  --seite: #F6F7F7;
  --punkt: #D9DEDC;
  --kopf: rgba(255, 255, 255, 0.88);
  --flaeche: #FFFFFF;
  --flaeche-2: #F1F3F2;
  --text: #18191B;
  --text-leise: #6B7075;
  --linie: #E5E8E7;
  --gruen: #1E7A55;
  --gruen-dunkel: #176445;
  --gruen-hell: #E9F5EF;
  --verlauf: linear-gradient(135deg, #22A06B 0%, #3BA79B 45%, #6C86E8 100%);
  --knopf: #1B1B1D;
  --knopf-hover: #000000;
  --knopf-text: #FFFFFF;
  --fehler: #B42318;
  --fehler-hell: #FEF0EE;
  --warn: #9A5B00;
  --warn-hell: #FFF6E5;
  --ring: rgba(30, 122, 85, 0.22);

  --schrift: "Inter", "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --schrift-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 16px;
  --radius-feld: 10px;
  --radius-knopf: 12px;
  --schatten: 0 1px 2px rgba(16, 24, 20, 0.04), 0 6px 20px rgba(16, 24, 20, 0.04);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --seite: #0E1211;
    --punkt: #1E2624;
    --kopf: rgba(20, 25, 24, 0.88);
    --flaeche: #161B1A;
    --flaeche-2: #1C2321;
    --text: #ECEFEE;
    --text-leise: #9BA3A0;
    --linie: #27302D;
    --gruen: #4CC490;
    --gruen-dunkel: #6ED3A6;
    --gruen-hell: #14271F;
    --verlauf: linear-gradient(135deg, #3DD08F 0%, #4CC0B4 45%, #8AA2FF 100%);
    --knopf: #F2F4F3;
    --knopf-hover: #FFFFFF;
    --knopf-text: #111312;
    --fehler: #F59A8E;
    --fehler-hell: #351A17;
    --warn: #F3C27A;
    --warn-hell: #2E2414;
    --ring: rgba(76, 196, 144, 0.28);
    --schatten: none;
  }
}

/* Grundlagen ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--seite);
  background-image: radial-gradient(var(--punkt) 1px, transparent 1.3px);
  background-size: 22px 22px;
  color: var(--text);
  font: 1rem/1.55 var(--schrift);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--gruen); text-underline-offset: 2px; }
code { font-family: var(--schrift-mono); font-size: .88em; background: var(--flaeche-2); padding: .1em .35em; border-radius: 6px; overflow-wrap: anywhere; }
.leise { color: var(--text-leise); }
.klein { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Marke ------------------------------------------------------------------ */
.marke { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.marke-zeichen { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--verlauf); color: #fff; font-weight: 800; font-size: .95rem; }

/* Knöpfe und Felder -------------------------------------------------------- */
.knopf, .knopf-zweit, .knopf-leise, .knopf-gefahr {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .55rem 1rem; border-radius: var(--radius-knopf);
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; transition: background-color .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.knopf { background: var(--knopf); color: var(--knopf-text); }
.knopf:hover { background: var(--knopf-hover); }
.knopf-zweit { background: var(--flaeche); color: var(--text); border-color: var(--linie); }
.knopf-zweit:hover { border-color: var(--text-leise); }
.knopf-leise { background: transparent; color: var(--text-leise); padding-inline: .7rem; }
.knopf-leise:hover { color: var(--text); background: var(--flaeche-2); }
.knopf-gefahr { background: transparent; color: var(--fehler); border-color: var(--linie); }
.knopf-gefahr:hover { background: var(--fehler-hell); }
button:disabled { opacity: .55; cursor: progress; }
.klein-knopf { min-height: 34px; padding: .3rem .7rem; font-size: .875rem; border-radius: 10px; }

.feld { display: grid; gap: .3rem; margin-bottom: .9rem; }
.feld > span { font-size: .875rem; font-weight: 600; }
.feld small { color: var(--text-leise); font-size: .8rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--flaeche);
  border: 1px solid var(--linie); border-radius: var(--radius-feld); padding: .6rem .75rem; min-height: 44px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gruen); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--gruen); margin: 0; }
.feld-fehler { color: var(--fehler); font-size: .8rem; }
.feld.hat-fehler input, .feld.hat-fehler select, .feld.hat-fehler textarea { border-color: var(--fehler); }

.meldung { padding: .7rem .9rem; border-radius: var(--radius-feld); margin-bottom: 1rem; font-size: .925rem; }
.meldung.fehler { background: var(--fehler-hell); color: var(--fehler); }
.meldung.ok { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.meldung.warn { background: var(--warn-hell); color: var(--warn); }

/* Anmeldung / Einrichtung ---------------------------------------------------- */
.schmal { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.kasten { width: 100%; max-width: 420px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); padding: 2rem 1.75rem; }
.kasten .marke { margin-bottom: 1.5rem; }
.kasten h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.kasten .knopf { width: 100%; margin-top: .25rem; }
.hinweisfeld { background: var(--gruen-hell); border-radius: var(--radius-feld); padding: .9rem 1rem .3rem; margin-bottom: 1rem; }
.hinweisfeld p { margin-bottom: .5rem; }
.geheimnis code { font-size: 1rem; letter-spacing: .06em; background: var(--flaeche); display: inline-block; padding: .35rem .6rem; }

/* Kopfleiste ----------------------------------------------------------------- */
.kopf {
  position: sticky; top: 0; z-index: 20;
  background: var(--kopf); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--linie); padding-top: env(safe-area-inset-top, 0px);
}
.kopf-innen { max-width: 1240px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; }
.navigation { display: flex; gap: .25rem; flex: 1; }
.navigation a {
  position: relative; display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .8rem; border-radius: 10px; color: var(--text-leise); text-decoration: none; font-weight: 550; font-size: .95rem;
}
.navigation a:hover { color: var(--text); background: var(--flaeche-2); }
.navigation a[aria-current="page"] { color: var(--text); background: var(--flaeche-2); }
.zaehler { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gruen); color: #fff; font-size: .72rem; font-weight: 700; }
.abmelden { margin: 0; }

.inhalt { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; outline: none; }
.laden { color: var(--text-leise); }

/* Flächen ---------------------------------------------------------------- */
.flaeche { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); }
.flaeche-kopf { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--linie); }
.flaeche-kopf h2 { margin: 0; }
.flaeche-inhalt { padding: 1.1rem 1.25rem; }

/* Übersicht ---------------------------------------------------------------- */
.gruss { margin-bottom: 1.25rem; }
.gruss p { color: var(--text-leise); margin: 0; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.kachel { padding: 1rem 1.15rem; display: grid; gap: .15rem; text-decoration: none; color: inherit; }
a.kachel:hover { border-color: var(--text-leise); }
.kachel-titel { font-size: .875rem; color: var(--text-leise); font-weight: 550; display: flex; align-items: center; gap: .45rem; }
.kachel-titel::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--farbe, var(--gruen)); }
.kachel[data-bereich="buchhaltung"] { --farbe: #22A06B; }
.kachel[data-bereich="tickets"] { --farbe: #3BA79B; }
.kachel[data-bereich="mail"] { --farbe: #6C86E8; }
.kachel-wert { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kachel-zusatz { font-size: .85rem; color: var(--text-leise); }
.kachel-zusatz.warnung { color: var(--warn); font-weight: 600; }
.kachel-fehler { font-size: .85rem; color: var(--fehler); }

.arbeitsflaeche { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: start; }
.verlauf-liste { list-style: none; margin: 0; padding: .4rem; display: grid; gap: 2px; max-height: 560px; overflow: auto; }
.verlauf-liste button {
  width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px; padding: .55rem .7rem; cursor: pointer;
  font: inherit; color: var(--text); display: grid; gap: 1px;
}
.verlauf-liste button:hover { background: var(--flaeche-2); }
.verlauf-liste button[aria-current="true"] { background: var(--gruen-hell); }
.verlauf-liste .titel { font-size: .9rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verlauf-liste .zeit { font-size: .75rem; color: var(--text-leise); }

/* Chat ----------------------------------------------------------------------- */
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: min(74vh, 760px); min-height: 460px; }
.chat-kopf { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--linie); }
.chat-kopf h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-kopf .aktionen { display: flex; gap: .25rem; flex-shrink: 0; }
.verlauf { overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .75rem; overscroll-behavior: contain; }
.leer { margin: auto; text-align: center; max-width: 440px; color: var(--text-leise); }
.leer h3 { color: var(--text); font-size: 1.15rem; }
.vorschlaege { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; margin-top: 1rem; }
.vorschlaege button { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 999px; padding: .45rem .85rem; font: inherit; font-size: .875rem; color: var(--text); cursor: pointer; }
.vorschlaege button:hover { border-color: var(--gruen); color: var(--gruen-dunkel); }

.nachricht { max-width: min(680px, 88%); overflow-wrap: anywhere; }
.nachricht.nutzer { align-self: flex-end; background: var(--knopf); color: var(--knopf-text); padding: .6rem .9rem; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.nachricht.jarvis { align-self: flex-start; padding: .1rem 0; }
.nachricht.jarvis p:last-child, .nachricht.jarvis ul:last-child, .nachricht.jarvis ol:last-child { margin-bottom: 0; }
.nachricht.jarvis ul, .nachricht.jarvis ol { padding-left: 1.25rem; margin: 0 0 .75rem; }
.nachricht.jarvis li { margin-bottom: .2rem; }
.nachricht.jarvis table { border-collapse: collapse; font-size: .9rem; margin-bottom: .75rem; display: block; overflow-x: auto; }
.nachricht.jarvis th, .nachricht.jarvis td { border-bottom: 1px solid var(--linie); padding: .35rem .6rem; text-align: left; }
.werkzeug { align-self: flex-start; font-size: .8rem; color: var(--text-leise); display: inline-flex; align-items: center; gap: .4rem; }
.werkzeug::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gruen); }
.denkt { align-self: flex-start; font-size: .875rem; color: var(--text-leise); display: inline-flex; gap: .5rem; align-items: center; }
.denkt::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--linie); border-top-color: var(--gruen); animation: drehen .8s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }

.freigabe { align-self: stretch; border: 1px solid var(--gruen); background: var(--gruen-hell); border-radius: 14px; padding: .9rem 1rem; max-width: 560px; }
.freigabe h3 { margin: 0 0 .25rem; font-size: .95rem; }
.freigabe .frage { margin-bottom: .6rem; }
.freigabe dl { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: .2rem .9rem; margin: 0 0 .8rem; font-size: .875rem; }
.freigabe dt { color: var(--text-leise); }
.freigabe dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.freigabe .aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }
.freigabe[data-status="ausgefuehrt"] { border-color: var(--linie); background: var(--flaeche); }
.freigabe[data-status="abgelehnt"], .freigabe[data-status="abgelaufen"] { border-color: var(--linie); background: var(--flaeche-2); }
.freigabe[data-status="fehler"] { border-color: var(--fehler); background: var(--fehler-hell); }
.freigabe-status { font-size: .875rem; font-weight: 600; }

.eingabe { border-top: 1px solid var(--linie); padding: .75rem; display: flex; gap: .5rem; align-items: flex-end; }
.eingabe textarea { min-height: 46px; max-height: 200px; resize: none; border-radius: 14px; }
.eingabe .knopf { min-width: 92px; min-height: 46px; }
.chat-hinweis { font-size: .78rem; color: var(--text-leise); padding: 0 1rem .6rem; margin: 0; }

/* Posteingang ----------------------------------------------------------------- */
.seitenkopf { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.seitenkopf h1 { margin: 0; }
.seitenkopf p { margin: .25rem 0 0; color: var(--text-leise); }
.reiter { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.reiter button { font: inherit; font-size: .9rem; font-weight: 550; border: 1px solid var(--linie); background: var(--flaeche); color: var(--text-leise); border-radius: 999px; padding: .4rem .85rem; cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; }
.reiter button[aria-pressed="true"] { background: var(--knopf); color: var(--knopf-text); border-color: var(--knopf); }
.reiter .anzahl { font-variant-numeric: tabular-nums; opacity: .75; }
.sammelleiste { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; border-bottom: 1px solid var(--linie); flex-wrap: wrap; font-size: .9rem; }
.sammelleiste label { display: inline-flex; gap: .5rem; align-items: center; cursor: pointer; }
.mails { list-style: none; margin: 0; padding: 0; }
.mail { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--linie); align-items: start; }
.mail:last-child { border-bottom: 0; }
.mail > input { margin-top: .2rem; }
.mail-kopf { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.mail-absender { font-weight: 650; }
.mail-zeit { font-size: .8rem; color: var(--text-leise); }
.mail-betreff { font-weight: 550; overflow-wrap: anywhere; }
.mail-zusammenfassung { color: var(--text-leise); font-size: .9rem; margin: .1rem 0 0; }
.mail-aktionen { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.etikett { display: inline-flex; align-items: center; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--flaeche-2); color: var(--text-leise); }
.etikett.ticket { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.etikett.kunde, .etikett.behoerde, .etikett.rechnung { background: var(--warn-hell); color: var(--warn); }
.mail-detail { grid-column: 2 / -1; margin-top: .6rem; }
.mail-text { background: var(--flaeche-2); border-radius: var(--radius-feld); padding: .9rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; max-height: 420px; overflow: auto; }
.ticket-form { border: 1px solid var(--linie); border-radius: 12px; padding: 1rem; margin-top: .6rem; background: var(--flaeche); }
.ticket-form .reihe { display: grid; grid-template-columns: 140px 1fr; gap: .75rem; }
.ticket-form .reihe-3 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.ticket-form .aktionen { display: flex; gap: .5rem; }
.leer-liste { padding: 2.5rem 1.25rem; text-align: center; color: var(--text-leise); }

/* Einstellungen --------------------------------------------------------------- */
.raster-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--linie); align-items: center; }
.liste li:last-child { border-bottom: 0; }
.punkt { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--gruen); margin-right: .45rem; }
.punkt.aus { background: var(--fehler); }
.formular-2 { display: grid; grid-template-columns: 1fr 120px; gap: 0 .75rem; }

/* Hinweis unten --------------------------------------------------------------- */
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--knopf); color: var(--knopf-text); padding: .65rem 1rem; border-radius: 12px; font-size: .9rem; box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 50; max-width: calc(100vw - 2rem); }
.toast.fehler { background: var(--fehler); color: #fff; }

/* Mobil ---------------------------------------------------------------------- */
@media (max-width: 900px) {
  .arbeitsflaeche { grid-template-columns: 1fr; }
  .verlauf-box { order: 2; }
  .verlauf-liste { max-height: 260px; }
}
@media (max-width: 640px) {
  .kopf-innen { padding: .5rem .9rem; gap: .6rem; flex-wrap: wrap; }
  .marke-name { display: none; }
  .navigation { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .navigation { gap: 0; justify-content: space-between; }
  .navigation a { padding: .4rem .55rem; font-size: .875rem; white-space: nowrap; }
  .abmelden { margin-left: auto; }
  .inhalt { padding: 1.1rem .75rem 2.5rem; }
  .kacheln { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .kachel { padding: .7rem .75rem; }
  .kachel-titel { font-size: .75rem; line-height: 1.25; align-items: flex-start; }
  .kachel-titel::before { margin-top: .3em; flex-shrink: 0; }
  .kachel-wert { font-size: 1.45rem; }
  .kachel-zusatz, .kachel-fehler { font-size: .72rem; line-height: 1.3; }
  .chat-hinweis { display: none; }
  .chat { height: calc(100dvh - 190px); min-height: 420px; }
  .nachricht { max-width: 94%; }
  .mail { grid-template-columns: auto minmax(0, 1fr); padding: .85rem .9rem; }
  .mail-aktionen { grid-column: 2; justify-content: flex-start; }
  .mail-detail { grid-column: 1 / -1; }
  .ticket-form .reihe, .ticket-form .reihe-3, .formular-2 { grid-template-columns: 1fr; }
  .sammelleiste { padding: .6rem .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.abstand-oben { margin-top: 1rem; }
.qr { margin: .25rem 0 .75rem; }
.qr img { display: block; width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 10px; image-rendering: pixelated; }
