/* Farben aus dem kalucare-Logo: Navy (#000050) als Hauptfarbe, Hellblau (#C1DBEB) als Akzent.
   Hell/Dunkel folgt dem System; theme.js setzt data-theme, wenn jemand im Header umschaltet. */
/* Schrift Inter (SIL Open Font License, fonts/Inter-OFL.txt), liegt in app/static/fonts und wird vom Server selbst ausgeliefert,
   keine Aufrufe bei Google Fonts oder einem CDN. Eine variable Datei je Schriftschnitt deckt alle Stärken ab;
   latin-ext lädt der Browser nur, wenn Zeichen außerhalb von Westeuropa vorkommen (z. B. ł, ő). */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-wght-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("fonts/inter-latin-ext-wght-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --navy: #0a0a5a; --pale: #c1dbeb;
  --bg: #f3f5fa; --card: #fff; --raised: #f7f9fc; --text: #14183d; --muted: #5d6483; --line: #dde3ee; --line-strong: #c5cddd;
  --primary: #0a0a5a; --primary-hover: #20207e; --primary-text: #fff;
  --link: #24249a; --soft: #e6f0f8; --soft-text: #0a0a5a; --focus: rgba(70, 120, 200, 0.35);
  --input: #fff; --header: #fff; --shadow: 0 1px 2px rgba(10, 10, 90, 0.05), 0 2px 8px rgba(10, 10, 90, 0.04);
  --ok: #1d7a4c; --ok-bg: #e3f4ea; --warn: #94570b; --warn-bg: #fdf0d9; --err: #b3261e; --err-bg: #fce8e6;
  --violet: #4b3fb0; --violet-bg: #ebe9fb; --grey: #5d6483; --grey-bg: #eceff5;
  --radius: 10px; --radius-sm: 7px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0d1e; --card: #14172c; --raised: #191d35; --text: #e6e9f6; --muted: #9ba2c2; --line: #261b48; --line-strong: #353b5e;
    --primary: #c1dbeb; --primary-hover: #d8e8f3; --primary-text: #0a0a5a;
    --link: #a8cbec; --soft: #1d2647; --soft-text: #c9e0f2; --focus: rgba(168, 203, 236, 0.35);
    --input: #0f1225; --header: #10132a; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --ok: #6fd3a0; --ok-bg: #12301f; --warn: #f0b860; --warn-bg: #33250d; --err: #ff8a80; --err-bg: #3a1513;
    --violet: #b3abff; --violet-bg: #251f4d; --grey: #9ba2c2; --grey-bg: #1f2340;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d1e; --card: #14172c; --raised: #191d35; --text: #e6e9f6; --muted: #9ba2c2; --line: #261b48; --line-strong: #353b5e;
  --primary: #c1dbeb; --primary-hover: #d8e8f3; --primary-text: #0a0a5a;
  --link: #a8cbec; --soft: #1d2647; --soft-text: #c9e0f2; --focus: rgba(168, 203, 236, 0.35);
  --input: #0f1225; --header: #10132a; --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ok: #6fd3a0; --ok-bg: #12301f; --warn: #f0b860; --warn-bg: #33250d; --err: #ff8a80; --err-bg: #3a1513;
  --violet: #b3abff; --violet-bg: #251f4d; --grey: #9ba2c2; --grey-bg: #1f2340;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Die Seite wächst mit dem Fenster bis 1680px, damit breite Listen auf großen Bildschirmen als Tabelle
   passen; Fließtext bleibt auf lesbarer Zeilenlänge */
main { max-width: 1680px; margin: 0 auto; padding: 24px clamp(20px, 2.5vw, 40px) 48px; }
main p { max-width: 110ch; }
h1 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -0.01em; margin: 0.3em 0 0.4em; }
h2 { font-size: 1.05rem; margin: 1.2em 0 0.6em; }
.card > h2:first-child, form.card > input[type=hidden] + h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Kopfzeile */
header.top { position: sticky; top: 0; z-index: 10; background: var(--header); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1680px; margin: 0 auto; padding: 10px clamp(20px, 2.5vw, 40px); display: flex; flex-wrap: wrap; gap: 8px 20px;
  align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.brand-name { font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--text); }
.brand-sub { font-weight: 300; font-size: 1.05rem; color: var(--muted); }
.top nav { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
/* Breiter Bildschirm: Kopf in einer Zeile. Die Navigation löst sich in die Kopfzeile auf (display: contents), damit
   die Kollegen zwischen Menü und „Neues Ticket“ stehen können: Logo, Menü, Kollegen, Neues Ticket, Benutzermenü. */
@media (min-width: 801px) {
  .top-inner { flex-wrap: nowrap; gap: 8px 4px; padding-top: 8px; padding-bottom: 8px; }
  .top nav { display: contents; }
  .brand { order: -1; margin-right: 12px; }
  .top-inner .colleagues { order: 1; flex: 0 1 auto; flex-wrap: nowrap; overflow: hidden; margin: 0 8px 0 auto; padding: 2px; }
  .top-inner .colleague { flex: none; }
  .top nav .nav-end { order: 2; flex: none; gap: 10px; }
  .top .brand img.brand-logo { height: 48px; }
  .top .brand img.brand-wide { height: 38px; }
}
@media (min-width: 801px) and (max-width: 1280px) {
  .nav-user-name { display: none; }
  .top nav .company-switch select { max-width: 11rem; }
}
.top nav .nav-new { padding: 7px 14px; white-space: nowrap; color: var(--primary-text); }
.top nav .nav-new:hover { background: var(--primary-hover); color: var(--primary-text); }
.top nav .nav-new.active { background: var(--primary-hover); color: var(--primary-text); }
/* Untermenüs Stammdaten, Verwaltung und Benutzer */
.nav-group { position: relative; }
.nav-group > summary { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-sm);
  font-weight: 500; cursor: pointer; list-style: none; white-space: nowrap; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0 2px; border: solid currentColor;
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); opacity: 0.6; }
.nav-group[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
.nav-group > summary:hover, .nav-group[open] > summary { background: var(--soft); color: var(--soft-text); }
.nav-group.active > summary { background: var(--soft); color: var(--soft-text); font-weight: 600; }
.nav-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; display: flex; flex-direction: column; gap: 1px;
  min-width: 13rem; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(10, 10, 90, 0.14); }
.nav-menu-end { left: auto; right: 0; }
.top nav .nav-menu a, .top nav .nav-menu button.link, .nav-menu .theme-toggle.with-label { display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; justify-content: flex-start; text-align: left; white-space: nowrap; color: var(--text); }
.top nav .nav-menu a.active { color: var(--soft-text); }
.nav-menu form.inline { display: block; margin: 0; }
.nav-user > summary { padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; gap: 8px; }
.nav-user > summary .avatar { width: 30px; height: 30px; font-size: 0.72rem; }
.theme-toggle.with-label { width: auto; height: auto; margin: 0; border: 0; border-radius: var(--radius-sm); justify-content: flex-start;
  font: inherit; font-weight: 500; color: var(--text); }
.theme-toggle.with-label:hover { background: var(--soft); color: var(--soft-text); }
.top nav a, .top nav button.link { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.top nav a:hover, .top nav button.link:hover { background: var(--soft); color: var(--soft-text); text-decoration: none; }
.top nav a.active { background: var(--soft); color: var(--soft-text); font-weight: 600; }
.top nav .sep { width: 1px; height: 22px; margin: 0 8px; background: var(--line); }
.top nav .user { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.top nav .nav-end, .top nav .nav-tools { display: flex; align-items: center; gap: 2px; }
/* Profilbild und Menü-Knopf gibt es nur in der Handy-Kopfzeile (unten) */
.top-me, .menu-toggle { display: none; }
/* Kollegen des Unternehmens neben dem Logo, Punkt unten rechts: grün = online, rot = offline */
.colleagues { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; margin: 0 auto 0 4px;
  padding: 0; list-style: none; }
.colleague { position: relative; display: inline-flex; margin: 0; padding: 0; cursor: default; }
.colleague .avatar { width: 34px; height: 34px; font-size: 0.78rem; }
.colleague .presence { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--header); }
.colleague .presence.on { background: #22a65a; }
.colleague .presence.off { background: #d93a2f; }
.colleague.more { align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px;
  background: var(--soft); color: var(--soft-text); font-size: 0.75rem; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; }
.company-switch select { width: auto; max-width: 16rem; padding: 5px 8px; font-weight: 500; }

/* Profilbilder: rund; ohne Bild Initialen in den Markenfarben */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%;
  object-fit: cover; background: var(--soft); color: var(--soft-text); font-weight: 600; line-height: 1;
  vertical-align: middle; user-select: none; }
.avatar-s { width: 26px; height: 26px; font-size: 0.7rem; }
.avatar-m { width: 34px; height: 34px; font-size: 0.8rem; }
.avatar-l { width: 96px; height: 96px; font-size: 2rem; }
img.avatar { border: 1px solid var(--line); background: var(--card); }
.person { display: inline-flex; align-items: center; gap: 10px; }
.picture-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.picture-card form { margin: 0; }
.picture-card .picture-actions { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.picture-card .picture-actions > form:first-child { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.comment .meta .avatar { margin-right: 6px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  margin-left: 4px; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 50%; }
.theme-toggle:hover { background: var(--soft); color: var(--soft-text); }
.lang-switch { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px;
  padding: 0 6px; border-radius: 8px; font-size: 13px; font-weight: 600; letter-spacing: .03em; text-decoration: none; }
.lang-switch:hover { background: var(--soft); color: var(--soft-text); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun, .theme-toggle .i-moon, .theme-toggle .i-auto { display: none; }
.theme-toggle[data-mode="light"] .i-sun, .theme-toggle[data-mode="dark"] .i-moon, .theme-toggle[data-mode="auto"] .i-auto { display: block; }

/* Bausteine */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 14px 0;
  box-shadow: var(--shadow); }
.narrow { max-width: 400px; margin: 40px auto; }
.login-logo { display: block; width: auto; max-width: 190px; max-height: 220px; height: auto; margin: 0 auto 8px; padding: 10px; background: #fff; border-radius: 14px; }
.login h1 { text-align: center; font-size: 1.25rem; margin-bottom: 1em; }
.login button { width: 100%; padding: 10px 14px; }

label { display: block; margin: 0 0 14px; font-weight: 600; font-size: 0.9rem; }
label.choice { display: inline-flex; gap: 8px; align-items: center; margin: 0; font-weight: 400; font-size: 1rem; }
label .hint { display: block; margin-top: 4px; font-weight: 400; }
input, select, textarea { width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-size: 1rem; font-weight: 400; color: var(--text);
  background: var(--input); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); box-shadow: none; }
input[type=file] { padding: 7px; background: var(--raised); border-style: dashed; }
input[type=file]::file-selector-button { margin-right: 10px; padding: 5px 12px; font: inherit; font-weight: 600; color: var(--soft-text);
  background: var(--soft); border: 0; border-radius: 6px; cursor: pointer; }
textarea { resize: vertical; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select { height: 40px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; font: inherit;
  font-weight: 600; line-height: 1.2; cursor: pointer; color: var(--primary-text); background: var(--primary); border: 1px solid transparent;
  border-radius: var(--radius-sm); transition: background 0.15s, border-color 0.15s; }
button:hover, .button:hover { background: var(--primary-hover); text-decoration: none; }
button.secondary, .button.secondary { color: var(--text); background: var(--card); border-color: var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--soft); border-color: var(--soft); color: var(--soft-text); }
button.link { padding: 0; color: var(--link); background: none; border: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button.danger, .button.danger { color: var(--err); background: var(--card); border-color: var(--err); }
button.danger:hover, .button.danger:hover { color: var(--card); background: var(--err); }
.danger-zone { margin-top: 16px; text-align: right; }
form.inline { display: inline; }
.choices { display: flex; flex-wrap: wrap; gap: 18px; }

.flash { padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); border-left-width: 4px; background: var(--card); }
.flash.ok { border-color: var(--ok); background: var(--ok-bg); }
.flash.error { border-color: var(--err); background: var(--err-bg); color: var(--err); }

/* Liste und Tabellen */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.filters.with-brand { grid-template-columns: 1.6fr repeat(5, 1fr); }
.filters input, .filters select { margin: 0; }
.bulk-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 4px; }
.bulk-edit select { width: auto; max-width: 220px; margin: 0; }
.bulk-edit button { margin: 0; }
.filters input[type=search], input.table-search { padding-left: 34px; background: var(--input) no-repeat 11px center / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a91ad' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: var(--raised); }
td input, td select { margin: 0; }
/* Sortierbare Spaltenköpfe (theme.js): der Kopftext wird zum Knopf, der Pfeil zeigt die Richtung */
th button.sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; min-width: 0; font: inherit; letter-spacing: inherit;
  text-transform: inherit; text-align: inherit; color: inherit; background: none; border: 0; border-radius: 3px; cursor: pointer; }
th button.sort:hover { background: none; color: var(--text); }
th button.sort::after { content: "↕"; font-size: 0.9em; opacity: 0; transition: opacity 0.1s; }
th button.sort:hover::after, th button.sort:focus-visible::after { opacity: 0.5; }
th[aria-sort] { color: var(--text); }
th[aria-sort=ascending] button.sort::after { content: "↑"; opacity: 1; }
th[aria-sort=descending] button.sort::after { content: "↓"; opacity: 1; }
.sort-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.sort-bar[hidden] { display: none; }
[data-provider][hidden] { display: none; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; margin: 10px 0 16px; font-size: 0.9rem; }
.pager[hidden], tr.page-off, table.stacked tr.page-off { display: none !important; }
.pager label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-weight: 600; }
.pager select { width: auto; margin: 0; }
.pager-info { color: var(--muted); margin-right: auto; order: -1; }
.pager button { margin: 0; min-width: 0; }
.table-search { max-width: 26em; margin: 0 0 12px; }
.table-search[hidden] { display: none; }
.contact-choices .choice.page-off { display: none !important; }
.choice-search { margin-bottom: 8px; }
.choice-pager { margin: 0 0 8px; }
.suggest { position: relative; display: block; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 2px 0 0; padding: 4px 0; list-style: none;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  max-height: 18em; overflow-y: auto; font-weight: normal; }
.suggest-list[hidden] { display: none; }
#push-control [hidden] { display: none; }
.suggest-list li { padding: 7px 12px; cursor: pointer; }
.suggest-list li.active, .suggest-list li[role=option]:hover { background: var(--soft); color: var(--soft-text); }
@media (max-width: 600px) {
  .pager { justify-content: stretch; }
  .pager-info { flex-basis: 100%; }
  .pager button { flex: 1 1 0; }
}
.sort-bar select { width: auto; max-width: 100%; margin: 0; flex: 1 1 auto; }
/* Auswahlfelder in Tabellen so breit wie ihr längster Eintrag, Textfelder nicht zusammengedrückt */
td select { width: auto; max-width: 16em; text-overflow: ellipsis; }
td input:not([type=checkbox]):not([type=radio]) { min-width: 9em; }
td input[name=name]:not([type=checkbox]) { min-width: 11em; }
td input[type=email]:not([type=checkbox]), td input[name=emails]:not([type=checkbox]) { min-width: 13em; }
td input[type=checkbox] { vertical-align: middle; }
td.nowrap { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.tickets tbody tr { transition: background 0.1s; }
.tickets tbody tr:hover { background: var(--raised); }
.tickets td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tickets td:first-child a { color: var(--muted); font-weight: 600; }
.tickets td:nth-child(2) a { color: var(--text); font-weight: 600; }
.tickets td:last-child { color: var(--muted); white-space: nowrap; font-size: 0.9rem; }

/* Status und Priorität */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  line-height: 1.4; white-space: nowrap; color: var(--grey); background: var(--grey-bg); border: 1px solid transparent; }
.badge[class*=" s-"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-neu { color: var(--soft-text); background: var(--soft); }
.s-in_bearbeitung { color: var(--violet); background: var(--violet-bg); }
.s-wartet_auf_kunde { color: var(--warn); background: var(--warn-bg); }
.s-erledigt { color: var(--ok); background: var(--ok-bg); }
.s-geschlossen { color: var(--grey); background: var(--grey-bg); }
.p-niedrig { color: var(--grey); background: transparent; border-color: var(--line-strong); }
.p-normal { color: var(--text); background: transparent; border-color: var(--line-strong); }
.p-hoch { color: var(--warn); background: var(--warn-bg); }
.p-dringend { color: var(--err); background: var(--err-bg); }

/* Ticketdetail */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }
.grid3 > div { margin-bottom: 14px; }
.grid3 > .wide { grid-column: 1 / -1; }
td.access .access-state { margin-top: 4px; font-size: 0.85rem; }
td.access .access-state .small { margin: 2px 0; }
td.access .access-state .badge { font-size: 0.72rem; padding: 1px 8px; }
.grid3.top { align-items: start; }
label input[type=color] { display: block; }
/* Eine Zeile aus Feld, Häkchen und Knopf */
.form-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.form-row label { margin: 0; }
.form-row label input:not([type=checkbox]) { display: inline-block; width: 6em; margin: 0 6px; }
.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.detail aside .card:first-child { margin-top: 14px; }
.detail .grid3 { grid-template-columns: 1fr; }
.title-row h1 { margin-bottom: 0.2em; }
.card > .title-row:first-child { margin-bottom: 12px; }
.card > .title-row:first-child h2 { margin: 0; }
.title-row .actions { display: flex; gap: 10px; align-items: center; }
.title-row .actions select { width: auto; margin: 0; }
.title-row .badge { font-size: 0.85rem; padding: 5px 12px; }
.description, .comment .body { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Formatierte Kommentare (app/formatting.py): Zeilenumbrüche kommen als <br>, Absätze und Listen als Blöcke */
.comment .body.formatted { white-space: normal; }
/* Lange Ticketbeschreibung (Mails mit Signatur): begrenzte Höhe, scrollbar und unten rechts größer ziehbar wie das
   Kommentarfeld. theme.js hebt die Grenze beim Ziehen auf, damit die Box auch über 18em hinaus wachsen kann. */
.description.scroll-box { max-height: 18em; min-height: 4em; overflow-y: auto; resize: vertical; }
@media (max-width: 600px) { .description.scroll-box { max-height: 14em; } }
.formatted p, .formatted ul, .formatted ol { margin: 0 0 .6em; }
.formatted > :last-child { margin-bottom: 0; }
.formatted ul, .formatted ol { padding-left: 1.4em; }
.formatted ul { list-style: disc; }
.formatted ol { list-style: decimal; }
.format-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; }
.format-bar button { min-width: 2.4em; padding: 4px 10px; font-size: .9rem; line-height: 1.4; }
.format-bar .hint { margin-left: auto; }
.history { list-style: none; padding: 0 0 0 18px; margin: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.history > li { position: relative; margin: 10px 0; }
.history > li::before { content: ""; position: absolute; left: -25px; top: 12px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line-strong); }
.history > li.comment::before { top: 16px; border-color: var(--muted); background: var(--card); }
.history > li.comment.external::before { border-color: var(--primary); background: var(--pale); }
.comment { background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-left-color: var(--line-strong);
  border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow); }
.comment.external { border-left-color: var(--primary); }
/* Kommentar vom Kunden (per Mail oder Kundenportal) */
.comment.from-customer { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-bg) 45%, var(--card)); }
.history > li.comment.from-customer::before { border-color: var(--ok); background: var(--ok-bg); }
.comment .meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.comment .meta strong { color: var(--text); }
.audit { font-size: 0.85rem; padding: 3px 0; }
.files, .mails { list-style: none; padding: 14px 20px; }
.files li, .mails li { margin: 6px 0; }
.files li + li, .mails li + li { padding-top: 6px; border-top: 1px solid var(--line); }
.grid-time { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.time-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
#zeiten h2 { display: flex; justify-content: space-between; align-items: baseline; }
#zeiten h2 .muted { font-variant-numeric: tabular-nums; font-weight: 600; }
#zeiten table { margin-top: 16px; }
#zeiten table td { padding: 8px 4px; }
#zeiten form button + button { margin-left: 6px; }
aside label.choice { margin-bottom: 14px; }
.button.danger, button.danger { color: var(--err); background: var(--card); border-color: var(--err); }
.button.danger:hover, button.danger:hover { color: var(--card); background: var(--err); }

@media (max-width: 800px) {
  main { padding: 16px 16px 40px; }
  .top-inner { padding: 10px 16px; }
  .brand-sub { display: none; }
  .top nav .sep { display: none; }
  .filters, .filters.with-brand { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { grid-column: 1 / -1; }
  .detail, .grid2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
.theme-corner { position: absolute; top: 14px; right: 16px; display: flex; align-items: center; gap: 4px; }
/* Tabellen mit class="stack": passt die Tabelle nicht ins Panel, setzt theme.js die Klasse "stacked" und
   jede Zeile erscheint als Karte, der Spaltenkopf als Beschriftung über dem Feld (data-label) */
table.stack th, table.stack td { padding-left: 10px; padding-right: 10px; }
table.stack th:first-child, table.stack td:first-child { padding-left: 14px; }
table.stack th:last-child, table.stack td:last-child { padding-right: 14px; }
table.stack.stacked thead { display: none; }
table.stack.stacked, table.stack.stacked tbody { display: block; }
table.stack.stacked tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(13em, 1fr)); gap: 12px 16px; align-items: end; padding: 14px; border-bottom: 1px solid var(--line); }
table.stack.stacked tbody tr:last-child { border-bottom: 0; }
table.stack.stacked td { display: block; min-width: 0; padding: 0; border: 0; }
table.stack.stacked td:empty { display: none; }
table.stack.stacked td:first-child, table.stack.stacked td.access, table.stack.stacked td.actions, table.stack.stacked td[colspan] { grid-column: 1 / -1; }
table.stack.stacked td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; margin-bottom: 5px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
table.stack.stacked td:first-child { font-weight: 600; }
table.stack.stacked td:first-child input { font-weight: 400; }
table.stack.stacked td input:not([type=checkbox]):not([type=radio]), table.stack.stacked td select { width: 100%; min-width: 0; max-width: none; }
table.stack.stacked td.actions { white-space: normal; }
table.stack.stacked .link-url { flex-wrap: wrap; }
table.stack.stacked .link-url input { min-width: 0; flex: 1 1 14em; }
/* Ticketliste auf dem Handy als Karten statt breiter Tabelle */
@media (max-width: 640px) {
  .tickets thead { display: none; }
  .tickets, .tickets tbody { display: block; }
  .tickets tr { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tickets tbody tr:last-child { border-bottom: 0; }
  .tickets td { display: block; padding: 0; border: 0; }
  .tickets td:empty { display: none; }
  .tickets td:nth-child(2) { order: -1; flex-basis: 100%; }
  .tickets td:first-child { font-size: 0.85rem; }
  .tickets td:last-child { flex-basis: 100%; font-size: 0.8rem; }
}
@media (max-width: 800px) {
  .top nav a, .top nav button.link { padding: 5px 8px; }
  .colleagues { gap: 4px; }
  .colleague .avatar { width: 30px; height: 30px; font-size: 0.7rem; }
  .colleague .presence { width: 10px; height: 10px; }
}
/* Handy-Kopfzeile: eine Zeile mit Logo, Kollegen, eigenem Profilbild und Menü-Knopf; der Knopf klappt die
   Navigation darunter auf (theme.js setzt html.js und header.menu-open). Ohne JavaScript bleibt die Navigation offen. */
@media (max-width: 800px) {
  .top-inner { flex-wrap: wrap; gap: 0 12px; padding: 8px 16px; }
  .brand img.brand-logo { height: 44px; padding: 2px 4px; }
  .brand img.brand-wide { height: 34px; max-width: 46vw; }
  .colleagues { flex: 1 1 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 2px; }
  .colleagues::-webkit-scrollbar { display: none; }
  .colleague { flex: none; }
  html.js .top-me { display: inline-flex; flex: none; border-radius: 50%; }
  html.js .top-me:hover { text-decoration: none; }
  html.js .menu-toggle { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 40px; height: 40px;
    padding: 0; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm); }
  html.js .menu-toggle:hover, html.js .menu-toggle[aria-expanded="true"] { background: var(--soft); color: var(--soft-text); }
  .menu-toggle svg { width: 22px; height: 22px; }
  .menu-toggle .i-close, .menu-toggle[aria-expanded="true"] .i-open { display: none; }
  .menu-toggle[aria-expanded="true"] .i-close { display: block; }
  html.js .top nav { display: none; }
  html.js header.top.menu-open nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; flex-basis: 100%;
    margin-top: 8px; padding: 10px 0 4px; border-top: 1px solid var(--line); max-height: calc(100dvh - 72px); overflow-y: auto; }
  html.js .top nav a, html.js .top nav button.link { padding: 10px 12px; }
  html.js .top nav .nav-end { grid-column: 1 / -1; flex-wrap: wrap; gap: 8px 4px; margin-top: 4px; padding-top: 10px;
    border-top: 1px solid var(--line); }
  html.js .top nav .company-switch { flex-basis: 100%; }
  html.js .company-switch select { width: 100%; max-width: none; padding: 9px 10px; }
  html.js .top nav .nav-end .user { flex: 1 1 auto; min-width: 0; }
  html.js .top nav .nav-tools { gap: 4px; }
  /* Untermenüs stehen am Handy offen untereinander (theme.js öffnet sie), die Überschrift ist nur Beschriftung */
  .top nav .nav-group:not(.nav-user) { grid-column: 1 / -1; }
  .top nav .nav-group > summary { padding: 8px 12px 2px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--muted); background: none; pointer-events: none; }
  .top nav .nav-group > summary::after { display: none; }
  .top nav .nav-menu { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; min-width: 0; padding: 0;
    border: 0; box-shadow: none; background: none; }
  .top nav .nav-menu a, .top nav .nav-menu button.link, .nav-menu .theme-toggle.with-label { padding: 10px 12px; }
  .top nav .nav-user { flex-basis: 100%; }
  .top nav .nav-user > summary { display: none; }
  .top nav .nav-new { flex: 1 1 auto; text-align: center; }
}

/* Öffentliches Kundenformular */
.public { max-width: 640px; margin: 32px auto; }
.public-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.public-head img { flex: none; object-fit: contain; border-radius: 50%; background: #fff; }
.public-head h1 { margin: 0; }
.public-head p { margin: 2px 0 0; }
.time-edit { max-width: 560px; }
fieldset.contacts, fieldset.plain { margin: 0 0 14px; padding: 0; border: 0; }
fieldset.contacts legend, fieldset.plain legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; }
.contact-choices { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 8px; }
fieldset.contacts details { margin: 4px 0 8px; }
fieldset.contacts details[hidden] { display: none; }
fieldset.reporter-edit [hidden] { display: none; }
fieldset.contacts summary { cursor: pointer; color: var(--primary); }
fieldset.contacts details .grid2 { margin-top: 10px; }
fieldset.prio { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 14px; padding: 0; border: 0; }
fieldset.prio legend { width: 100%; padding: 0; margin-bottom: 8px; font-weight: 600; font-size: 0.9rem; }
fieldset.choices { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; padding: 0; border: 0; }
fieldset.choices legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.ticket-number { font-size: 1.6rem; font-weight: 700; letter-spacing: 0.02em; }
.link-url { display: flex; gap: 8px; align-items: center; }
.link-url input { min-width: 22em; margin: 0; font-family: ui-monospace, monospace; font-size: 0.85rem; }

/* Marken */
.projects table { table-layout: fixed; }
.projects th:first-child { width: 40%; }

.brand-preview { display: inline-flex; gap: 6px; vertical-align: middle; }
.brand-preview span { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.brand-thumb.wide { width: auto; max-width: 180px; padding: 4px; }
.brand-thumb { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--line); }
input[type=color] { width: 64px; height: 40px; padding: 3px; }
/* Mail-Fußzeile: Bilder mit Platzhalter, Breite und Einfügen-Knopf, darunter die Vorschau der Mail */
.footer-editor h3 { margin: 18px 0 8px; font-size: 1rem; }
.footer-images { list-style: none; margin: 0 0 14px; padding: 0; }
.footer-images li { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.footer-images li > img { flex: none; width: 120px; height: 60px; object-fit: contain; padding: 4px; background: #fff;
  border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--line); }
.footer-images li > div { min-width: 0; }
.footer-images code { overflow-wrap: anywhere; }
.footer-image-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 6px; }
.footer-image-actions label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
.footer-image-actions input[type=number] { width: 90px; margin: 0; }
.footer-image-actions button { padding: 5px 12px; }
/* Vorschau der Kundenmail im Ticket: Knopf nur bei „an Kunde“, Vorschau verschwindet bei „intern“ */
.comment-form .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.comment-form:not(:has(input[name="visibility"][value="kunde"]:checked)) :is(.mail-preview-button, #mail-vorschau) { display: none; }
.mail-draft { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mail-draft h3 { margin: 0; }
.mail-head { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 12px; }
.mail-head dt { color: var(--muted); }
.mail-head dd { margin: 0; overflow-wrap: anywhere; }
.mail-preview { display: block; width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f3f4f7; }
.error-text { color: var(--err); }
@media (max-width: 600px) { .footer-images li { align-items: flex-start; } .footer-images li > img { width: 72px; height: 48px; } }
/* Aktionsknöpfe stehen nebeneinander und rutschen untereinander, wenn die Tabelle sonst breiter als das Panel würde */
td.actions > * { display: inline-block; margin: 3px 6px 3px 0; vertical-align: middle; }
td.actions > *:last-child { margin-right: 0; }
td.actions button, td.actions .button { white-space: nowrap; }
/* Knöpfe in der Aktionsspalte einer Liste alle gleich breit, ob neben- oder untereinander */
td.actions button:not(.link), td.actions .button, table.stack td:last-child > form > button:not(.link), table.stack td:last-child > .button { min-width: 9em; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--grey-bg); color: var(--grey); font-size: 0.8rem; font-weight: 600; }
.tag.warn { color: var(--warn); background: var(--warn-bg); }
.tag.ok { color: var(--ok); background: var(--ok-bg); }
.req { color: var(--err); font-weight: 700; }
.contact-email { margin: 0 0 14px; font-size: 0.9rem; }
.contact-email .label { display: block; font-weight: 600; }
.contact-email .value { display: flex; align-items: center; height: 40px; margin-top: 5px; color: var(--muted); }
.public [hidden] { display: none; }
.brand img.brand-wide { display: block; height: 46px; width: auto; max-width: 300px; object-fit: contain; padding: 2px 6px; background: #fff; border-radius: var(--radius-sm); }
.brand img.brand-logo { display: block; height: 64px; width: auto; object-fit: contain; padding: 3px 5px; background: #fff; border-radius: var(--radius-sm); box-shadow: 0 0 0 1px var(--line); }
.public-head img.public-logo { display: block; height: 96px; width: auto; object-fit: contain; padding: 4px 6px; background: #fff; border-radius: var(--radius-sm); }
.public-head img.public-wide { display: block; height: 52px; width: auto; max-width: 220px; object-fit: contain; padding: 4px 8px; background: #fff; border-radius: var(--radius-sm); }

/* Zwei-Faktor-Anmeldung */
.qr { margin: 12px 0; }
.qr svg { display: block; background: #fff; border-radius: var(--radius-sm); }
.recovery-codes { columns: 2; list-style: none; padding: 0; font-size: 1.05rem; }
.recovery-codes li { margin: 4px 0; }

/* Kundenportal */
.public.portal { max-width: 860px; }
.portal-nav { display: flex; gap: 16px; align-items: center; margin: -6px 0 16px; flex-wrap: wrap; }
.portal .history { margin-top: 8px; }
.portal-nav button.link { font-size: inherit; font-weight: inherit; }
.portal td:first-child, .portal td:last-child { white-space: nowrap; }

/* Auswertungen */
.report td.num, .report th { text-align: right; white-space: nowrap; }
.report td:first-child, .report th:first-child { text-align: left; white-space: normal; }
.report tr.sum td { border-top: 2px solid var(--line-strong); font-weight: 600; }
.report tr.mite td { border-top: none; padding-top: 0; color: var(--muted); }
.report td.diff { color: var(--warn); font-weight: 600; }
.report-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 0 0 14px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented a { padding: 7px 14px; color: var(--text); background: var(--card); text-decoration: none; }
.segmented a + a { border-left: 1px solid var(--line-strong); }
.segmented a:hover { background: var(--soft); color: var(--soft-text); text-decoration: none; }
.segmented a.active { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.period-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.period-nav .button { padding: 7px 12px; }
.period-nav select, .period-nav input[type=date] { width: auto; margin: 0; }
#update pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24em; overflow: auto; padding: 10px; border-radius: var(--radius-sm); background: var(--soft); color: var(--soft-text); }

/* Rückfrage bei ungespeicherten Änderungen (unsaved.js) */
dialog.dialog { width: min(440px, calc(100vw - 32px)); padding: 22px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(10, 10, 90, 0.25); }
dialog.dialog::backdrop { background: rgba(10, 10, 40, 0.45); }
dialog.dialog h2 { margin: 0 0 0.5em; }
dialog.dialog p { margin: 0 0 18px; color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
@media (max-width: 480px) { .dialog-actions { flex-direction: column-reverse; } .dialog-actions button { width: 100%; } }
/* Update-Hinweis (update_notice.js): Pop-up mit Markenfarbe oben und Logo, danach schmaler Banner unten */
dialog.update-notice { border-top: 4px solid var(--primary); }
dialog.update-notice p { color: var(--text); }
.update-notice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.update-notice-icon { position: relative; display: block; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--warn-bg); box-shadow: inset 0 0 0 2px var(--warn); }
.update-notice-icon::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--warn); font-weight: 800; }
.update-notice-icon.is-busy { background: none; box-shadow: none; border: 3px solid var(--line-strong); border-top-color: var(--primary);
  animation: update-spin 1s linear infinite; }
.update-notice-icon.is-busy::after { content: none; }
.update-notice-icon.is-done { background: var(--ok-bg); box-shadow: inset 0 0 0 2px var(--ok); }
.update-notice-icon.is-done::after { content: "\2713"; color: var(--ok); }
/* Logos sind für weißen Grund gemacht, auch im dunklen Farbschema */
.update-notice-mark { width: auto; max-width: 140px; height: 56px; padding: 4px; object-fit: contain; border-radius: var(--radius-sm); background: #fff;
  box-shadow: inset 0 0 0 1px var(--line); }
.update-notice .dialog-actions button { min-height: 44px; }
.update-notice .dialog-actions button[hidden] { display: none; }
.update-banner { position: fixed; inset: auto 0 0 0; z-index: 1000; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px; font-weight: 600; text-align: center; color: var(--text); background: var(--warn-bg);
  border-top: 1px solid var(--warn); box-shadow: inset 0 3px 0 var(--primary); }
.update-banner[hidden] { display: none; }
.update-banner img { flex: none; width: auto; max-width: 60px; height: 28px; padding: 2px; object-fit: contain; border-radius: 5px; background: #fff; }
html.update-banner-visible body { padding-bottom: 64px; }
@keyframes update-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .update-notice-icon.is-busy { animation: none; } }
@media (max-width: 480px) { dialog.update-notice { padding: 16px; } .update-banner { font-size: 0.9rem; } }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
h1 .reporter { font-weight: 400; font-size: 0.7em; }

.preview-progress { width: 100%; height: 1rem; accent-color: var(--primary); }
.preview-customer { min-width: 14rem; }

/* Server (Hetzner Cloud): eine Karte je Zugang, darin eine schmale Zeile je Server; Farbe nach Zustand */
fieldset.pick { margin: 4px 0 10px; padding: 0; border: 0; }
fieldset.pick legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.server-account { padding-top: 12px; padding-bottom: 12px; }
.server-account.htmx-request .server-account-body { opacity: 0.6; transition: opacity 0.2s; }
.server-account-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; }
.server-account-body { margin-top: 10px; }
.server-account.folded .server-account-body { display: none; }
.server-account-title { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.server-account-title h2 { margin: 0; font-size: 1.1rem; }
.server-fold { gap: 6px; padding: 2px 4px 2px 0; color: var(--text); background: none; border: 0; }
.server-fold:hover { background: none; color: var(--link); }
.server-fold .server-chevron { transform: rotate(90deg); }
.server-account.folded .server-fold .server-chevron { transform: none; }
.server-account-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.icon-button { padding: 5px 7px; }
.badge.server-ok { color: var(--ok); background: var(--ok-bg); }
.badge.server-warn { color: var(--warn); background: var(--warn-bg); }
.badge.server-err { color: var(--err); background: var(--err-bg); }
.badge.server-grey { color: var(--grey); background: var(--grey-bg); }
.server-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.server-ok > summary .server-dot, .badge.server-ok .server-dot { animation: server-pulse 2.4s infinite; }
@keyframes server-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .server-ok > summary .server-dot, .badge.server-ok .server-dot { animation: none; } }
/* Eine Zeile je Server; Klick klappt Ausstattung, Tags und Knöpfe auf */
.server-list { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.server + .server { border-top: 1px solid var(--line); }
.server > summary { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) 16px;
  gap: 4px 16px; align-items: center; padding: 7px 12px; cursor: pointer; list-style: none; }
.server > summary::-webkit-details-marker { display: none; }
.server > summary:hover, .server[open] > summary { background: var(--raised); }
.server-ok .server-dot { color: var(--ok); }
.server-warn .server-dot { color: var(--warn); }
.server-err .server-dot { color: var(--err); }
.server-grey .server-dot { color: var(--grey); }
.server-grey > summary { color: var(--muted); }
.server-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-name .badge { flex: none; font-size: 0.74rem; }
.server-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.server-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-title span { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-ip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86rem; }
.server-ip code, .server-facts code { font-size: 0.84rem; user-select: all; }
.server-metric { display: grid; grid-template-columns: auto minmax(30px, 1fr) auto; gap: 8px; align-items: center; min-width: 0; font-size: 0.8rem; }
.server-metric-label { color: var(--muted); font-size: 0.74rem; }
.server-metric strong { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.server-chevron { color: var(--muted); transition: transform 0.15s; }
.server[open] > summary .server-chevron { transform: rotate(90deg); }
.server-more { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: flex-start; justify-content: space-between;
  padding: 8px 12px 12px 30px; background: var(--raised); }
.server-facts { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; font-size: 0.86rem; }
.server-facts > div { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.server-facts dt { color: var(--muted); font-size: 0.78rem; }
.server-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meter-bar { display: block; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width 0.4s; }
.spark { display: block; width: 100%; height: 18px; overflow: visible; color: var(--ok); }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark polygon { fill: currentColor; opacity: 0.14; stroke: none; }
.meter-bar > span.warm, .spark.warm { background: var(--warn); color: var(--warn); }
.meter-bar > span.hot, .spark.hot { background: var(--err); color: var(--err); }
.spark.warm, .spark.hot { background: none; }
.server-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.8rem; width: 100%; }
.server-tags .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-tags .tag.ok { color: var(--ok); background: var(--ok-bg); }
.server-tags .label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 400; font-size: 0.74rem; }
.server-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.server-actions form { margin: 0; }
.server-actions button { padding: 5px 12px; font-size: 0.8rem; white-space: nowrap; }
@media (max-width: 760px) {
  .server > summary { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 16px; }
  .server-name { grid-column: 1 / 3; grid-row: 1; }
  .server > summary > .server-chevron { grid-column: 3; grid-row: 1; }
  .server-ip { grid-column: 1 / 3; grid-row: 2; padding-left: 18px; }
  .server > summary > :nth-child(3) { grid-column: 1; grid-row: 3; padding-left: 18px; }
  .server > summary > :nth-child(4) { grid-column: 2; grid-row: 3; }
  .server-more { padding-left: 12px; }
}

.server-secret { max-width: 720px; }
.server-secret-field { display: flex; gap: 8px; margin: 12px 0; }
.server-secret-field input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; }
.server-console { height: 72vh; min-height: 360px; background: #000; border-radius: var(--radius-sm); overflow: hidden; }

/* Stammdaten aus sevDesk: Bezeichnung links, Wert rechts, schmal untereinander */
dl.details { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 4px 16px; margin: 12px 0; }
dl.details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
@media (max-width: 600px) { dl.details { grid-template-columns: 1fr; } dl.details dd { margin-bottom: 6px; } }

/* Modul Angebote */
td.num, input.num { text-align: right; white-space: nowrap; }
ul.plain { list-style: none; padding: 0; margin: 0 0 8px; }
ul.plain li { padding: 2px 0; }
.grid2.top { align-items: start; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
table.positions td { vertical-align: top; }
table.positions td.wide { min-width: 18em; }
table.positions input.strong { font-weight: 600; margin-bottom: 6px; }
table.positions td.actions button.link { padding: 2px 6px; font-size: 1.1rem; }
table.totals { margin: 16px 0 0 auto; min-width: 22em; }
table.totals td { padding: 6px 10px; }
table.totals tr.strong td { font-weight: 700; }
.badge.o-entwurf { opacity: 0.8; }
.tab-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 18px; border-bottom: 1px solid var(--line); }
.tab-row a { padding: 9px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tab-row a:hover { color: var(--text); text-decoration: none; }
.tab-row a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }
form.brand-pick { margin: 0 0 8px; }
form.brand-pick label { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
form.brand-pick select { width: auto; margin: 0; }
.status-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 16px; }
.status-form label { margin: 0; }
.status-form select { width: auto; }
button:disabled, button:disabled:hover { opacity: .5; cursor: not-allowed; background: var(--primary); }
button.secondary:disabled, button.secondary:disabled:hover { background: var(--card); }
.flash.support-hint { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; border-left-color: var(--primary); }

/* Impressum und Datenschutz unten im Kundenportal */
.legal-links{display:flex;justify-content:center;gap:24px;padding:8px 16px 32px;font-size:.9rem}
.legal-links a{color:var(--muted)}
.app-version{text-align:center;padding:0 16px 24px}
button.app-version-copy{display:inline;background:none;border:0;padding:0;font:inherit;font-weight:inherit;color:inherit;cursor:copy}
button.app-version-copy:hover{background:none;color:inherit;text-decoration:underline}
.legal .legal-title{margin:8px 0 12px}

/* Fernwartung: Seite für den Kunden und Karte im Ticket */
.remote-steps { padding-left: 1.4em; }
.remote-steps > li { margin-bottom: 18px; }
.remote-steps h2 { font-size: 1.05rem; margin: 0 0 6px; }
.remote-config textarea.config-line { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; word-break: break-all; }
.remote-password { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.remote-password summary { cursor: pointer; color: var(--muted, inherit); text-decoration: underline; list-style: none; }
.remote-password summary::-webkit-details-marker { display: none; }
.remote-password[open] summary { order: 2; }
.remote-password code { user-select: all; font-weight: 600; }
#fernwartung form + form { margin-top: 20px; }

/* Startseite: Karten im Raster, weitere kommen über app/home.py dazu */
.home-brand select { min-width: 220px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 14px; }
.home-grid > .card { margin: 0; display: flex; flex-direction: column; min-width: 0; }
.home-card.wide { grid-column: 1 / -1; }
.home-card h2 { margin: 0 0 8px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.home-card-head { margin-bottom: 8px; }
.home-card-head h2 { margin: 0; }
.home-number { font-size: 2.8rem; font-weight: 700; line-height: 1.05; color: var(--text); text-decoration: none;
  font-variant-numeric: tabular-nums; align-self: flex-start; }
.home-number:hover { color: var(--link); }
.home-card p.small { margin: 4px 0 0; }
.home-facts { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 0.9rem; }
.home-facts a.badge { text-decoration: none; }
.home-facts a.badge:hover { filter: brightness(0.95); }
.home-hot { color: var(--err); font-weight: 600; }
.home-sub { font-size: 0.85rem; margin: 14px 0 6px; color: var(--muted); }
.home-servers { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px; }
.home-servers a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--raised); color: var(--text); text-decoration: none; min-width: 0; }
.home-servers a:hover { border-color: var(--line-strong); }
.home-servers strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-servers .muted { margin-left: auto; font-size: 0.82rem; white-space: nowrap; }
.home-servers .server-ok .server-dot { animation: server-pulse 2.4s infinite; }
@media (prefers-reduced-motion: reduce) { .home-servers .server-ok .server-dot { animation: none; } }

/* Seiten mit Kopfkarte und Reitern (Issue #261): Unternehmen, Kunde, Benutzer */
p.back { margin: 0 0 10px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 20px; background: var(--card); border: 1px solid var(--line);
  border-top: 4px solid var(--head-color, var(--primary)); border-radius: var(--radius); box-shadow: var(--shadow); }
.page-head h1 { margin: 0; font-size: 1.4rem; overflow-wrap: anywhere; }
.page-head-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.page-head-kicker { font-size: 0.8rem; color: var(--muted); }
.page-head-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.page-head-img { flex: none; width: 56px; height: 56px; object-fit: contain; padding: 4px; background: #fff; border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line); }
.page-head-img.round { border-radius: 50%; padding: 0; object-fit: cover; }
.page-head-img.initials { display: inline-flex; align-items: center; justify-content: center; padding: 0; background: var(--soft);
  color: var(--soft-text); font-weight: 700; font-size: 1.1rem; }
.page-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  background: var(--grey-bg); color: var(--grey); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.err { background: var(--err-bg); color: var(--err); }
.tabs-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 0 24px; align-items: start; }
.tabs-layout > input[type=hidden] { display: none; }
.tab-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); margin-top: 14px; }
.tab-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; }
.tab-nav a:hover { background: var(--soft); color: var(--soft-text); text-decoration: none; }
.tab-nav a[aria-current="true"] { background: var(--soft); color: var(--soft-text); font-weight: 600; }
.tab-flag { flex: none; font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--grey-bg); color: var(--grey); }
.tab-flag.warn { background: var(--warn-bg); color: var(--warn); }
.tab-panels { min-width: 0; }
.tab-panel > .card:first-child { margin-top: 14px; }
/* Ohne JavaScript stehen alle Reiter untereinander, die Leiste springt dann zum Abschnitt */
html.js .tab-panel:not(.current) { display: none; }
.save-bar { grid-column: 1 / -1; position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: flex-end; gap: 10px; margin: 18px 0 0; padding: 12px 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 -6px 18px rgba(10, 10, 90, 0.08); }
.save-bar > span { margin-right: auto; }
/* Lange Hilfetexte stehen hinter einem „?“ an der Überschrift (theme.js), ohne JavaScript sichtbar */
html.js [data-help] .card:not(.help-open):not(.fold .card) .help, html.js [data-help] details.fold:not(.help-open) .help { display: none; }
.help-toggle { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 8px; padding: 0;
  vertical-align: 2px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 0.72rem; font-weight: 700; line-height: 1; cursor: pointer; }
.help-toggle:hover, .help-open .help-toggle { background: var(--soft); color: var(--soft-text); border-color: var(--soft); }
@media (max-width: 900px) {
  .tabs-layout { grid-template-columns: minmax(0, 1fr); }
  .tab-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: thin; margin: 0; }
  .tab-nav a { flex: none; white-space: nowrap; }
  .page-head { padding: 14px 16px; }
  .page-head-img { width: 46px; height: 46px; }
  .page-chips { justify-content: flex-start; margin: 0; flex-basis: 100%; }
}

/* Systemseite: Kacheln mit Ampel, darunter Abschnitte zum Aufklappen */
.status-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 12px; margin: 8px 0 20px; padding: 0; list-style: none; }
.status-tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.status-tile > a { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 12px 14px; color: var(--text); }
.status-tile:not(:has(> a)) { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.status-tile > a:hover { text-decoration: none; background: var(--raised); border-radius: 0 var(--radius) var(--radius) 0; }
.status-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; color: var(--grey); }
.status-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-tile.ok { border-left-color: var(--ok); } .status-tile.ok .status-state { color: var(--ok); }
.status-tile.warn { border-left-color: var(--warn); } .status-tile.warn .status-state { color: var(--warn); }
.status-tile.err { border-left-color: var(--err); } .status-tile.err .status-state { color: var(--err); }
details.fold { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 10px 0; padding: 0 20px;
  box-shadow: var(--shadow); }
details.fold > summary { display: flex; align-items: center; gap: 8px; padding: 14px 0; font-weight: 600; font-size: 1.05rem; cursor: pointer;
  list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ""; width: 7px; height: 7px; margin: -4px 2px 0 10px; border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
details.fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.fold[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.fold-state { margin-left: auto; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
details.fold > .card { border: 0; box-shadow: none; padding: 4px 0 16px; margin: 0; background: none; }
details.fold > .card > h2:first-child { display: none; }

/* Ticketseite: Eckdaten speichern sofort, Kunde und Details zum Lesen, Bearbeiten klappt auf */
.title-row { align-items: flex-start; }
.title-actions { display: inline-flex; align-items: center; gap: 12px; flex: none; }
.basics-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.basics-grid > label { align-self: start; padding-top: 10px; margin: 0; font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.basics-grid select { margin: 0; }
.basics-grid label.choice { margin: -2px 0 2px; font-size: 0.85rem; color: var(--text); }
.basics-assignee { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.basics-assignee .link { font-size: 0.85rem; }
.basics > p.muted { margin: 10px 0 0; }
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0 0 12px; font-size: 0.92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
details.edit-more > summary { list-style: none; display: inline-block; width: auto; }
details.edit-more > summary::-webkit-details-marker { display: none; }
details.edit-more[open] > summary { margin-bottom: 14px; }
details.time-manual { margin: 12px 0 4px; }
details.time-manual > summary { cursor: pointer; color: var(--link); font-weight: 500; font-size: 0.92rem; }
details.time-manual[open] > summary { margin-bottom: 10px; }
a.danger-link { color: var(--err); font-size: 0.9rem; }

/* Benutzer: Zugriff als Tabelle je Unternehmen; die Speicherleiste nur auf den Reitern des Formulars */
html.js .tab-form:not(:has(.tab-panel.current)) > .save-bar { display: none; }
table.access-matrix { width: 100%; }
table.access-matrix th[scope=row] { background: transparent; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--text); }
table.access-matrix td, table.access-matrix th { vertical-align: middle; }
table.access-matrix select { margin: 0; width: auto; min-width: 10rem; }
table.access-matrix label.choice { margin: 0; justify-content: center; }
table.access-matrix thead th:not(:first-child):not(:nth-child(2)), table.access-matrix td:not(:nth-child(2)) { text-align: center; }
table.access-matrix tr.no-role th[scope=row] { color: var(--muted); font-weight: 500; }
table.access-matrix tr[data-main] { background: var(--soft); }
.superadmin-switch { margin-top: 16px; }
.table-wrap:has(> table.access-matrix) { margin-bottom: 4px; }
td.roles > div { white-space: nowrap; }
td.roles > .tag { margin-bottom: 4px; }

/* Feinschliff (Issue #261): „Bearbeiten“ in Tabellenzeilen zurückhaltend, damit die Zeilen nicht wie Knopfreihen
   wirken; Formulare in Karten nicht breiter als lesbar */
td.actions a.button:not(.danger):not(.secondary) { color: var(--text); background: var(--card); border-color: var(--line-strong); }
td.actions a.button:not(.danger):not(.secondary):hover { background: var(--soft); border-color: var(--soft); color: var(--soft-text); }
td.actions .button.danger, td.actions button.danger { border-color: transparent; }
td.actions .button.danger:hover, td.actions button.danger:hover { border-color: var(--err); }
.card textarea { max-width: 72rem; }

/* Altangebote: Texte aus der PDF mit ihren Zeilenumbrüchen (#275) */
.pre { white-space: pre-line; overflow-wrap: anywhere; }
