@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,500;0,600;1,500&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --border: #e8dfcf;
  --text: #2b2620;
  --text-muted: #85795f;
  --primary: #2f5b4f;
  --primary-dark: #23473d;
  --success: #1e7a57;
  --success-bg: #e6efe9;
  --warning: #c1622d;
  --warning-bg: #f7e7db;
  --danger: #a33c2a;
  --danger-bg: #f6e1d8;
  --info: #2f5b4f;
  --info-bg: #e9f1ec;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 38, 32, 0.05), 0 10px 28px -16px rgba(43, 38, 32, 0.2);
  --font-display: 'Lora', Georgia, serif;
  --font-body: 'Public Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --chart-neutral: #e4d9bf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1812;
    --surface: #262019;
    --border: #3a3225;
    --text: #f3ecdd;
    --text-muted: #b7aa8c;
    --success-bg: #1d3327;
    --warning-bg: #3c2a16;
    --danger-bg: #3b1e16;
    --info-bg: #1e2f27;
    --chart-neutral: #4a4030;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

/* ---- Navigation: siehe «App-Shell» weiter unten (v1.29.0) ---- */
/* «Ansicht als» (v1.26.0): Banner über der Kopfzeile */
.viewas-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 9px 20px; background: #2b2620; color: #f9f4e6; font-size: 13.5px; line-height: 1.4;
  border-bottom: 3px solid #d9a544;
}
.viewas-close {
  background: #d9a544; color: #2b2620; border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.viewas-close:hover { background: #e6b960; }
.viewas-list { display: flex; flex-direction: column; margin-top: 10px; }
.viewas-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.viewas-row:first-child { border-top: 0; }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn-ghost:hover { background: var(--bg); }

.bell-wrap { position: relative; }
.bell { background: none; border: none; font-size: 18px; cursor: pointer; position: relative; padding: 6px; }
.bell-badge {
  position: absolute; top: -2px; right: -2px; background: var(--danger); color: white;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; min-width: 15px; text-align: center;
}
.bell-badge.hidden { display: none; }
.notif-dropdown {
  position: absolute; right: 0; top: 36px; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px;
}
.notif-dropdown.hidden { display: none; }
.notif-item { padding: 10px; border-radius: 10px; }
.notif-item.unread { background: var(--info-bg); }
.notif-msg { font-size: 13px; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.notif-markall {
  display: block; width: 100%; text-align: center; background: none; border: none; color: var(--primary);
  cursor: pointer; font-size: 12px; padding: 8px; border-top: 1px solid var(--border); margin-top: 4px; font-family: inherit;
}

/* ---- Page structure ---- */
.page-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title h1 { font-size: 23px; }
.page-title p.subtitle { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 15.5px; margin: 0 0 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 600; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); padding: 8px 10px;
}
tbody td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* Sortierbare Spaltenköpfe + klickbare Zeilen (v1.12.0) */
thead th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 6px; }
.sort-ind { font-size: 10px; opacity: 0.35; margin-left: 2px; }
.sort-ind.active { opacity: 1; color: var(--primary); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sortbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sortbar label { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.card.clickable-card { cursor: pointer; }
.card.clickable-card:hover { box-shadow: 0 4px 16px rgba(47, 91, 79, 0.16); }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.badge-neu { background: var(--info-bg); color: var(--info); }
.badge-kontaktiert { background: var(--warning-bg); color: var(--warning); }
.badge-offeriert { background: var(--warning-bg); color: var(--warning); }
.badge-gewonnen { background: var(--success-bg); color: var(--success); }
.badge-verloren { background: var(--danger-bg); color: var(--danger); }
.badge-entwurf { background: var(--info-bg); color: var(--info); }
.badge-versendet { background: var(--warning-bg); color: var(--warning); }
.badge-angenommen { background: var(--success-bg); color: var(--success); }
.badge-abgelehnt { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-success { background: var(--success-bg); color: var(--success); }

select.status-select {
  font-size: 12px; border-radius: 999px; border: 1px solid var(--border); padding: 3px 8px;
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; font-family: inherit;
  min-width: 112px;
}

.btn {
  background: var(--primary); color: white; border: none; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
input, textarea, select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab-btn {
  background: none; border: 1px solid var(--border); padding: 7px 14px; border-radius: 999px;
  font-size: 13px; cursor: pointer; color: var(--text-muted); font-family: inherit;
}
.tab-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ---- Footer ---- */
.app-footer {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px; color: var(--text-muted); font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer-logo { height: 20px; width: auto; opacity: 0.85; }

/* ---- Login ---- */
.login-shell {
  min-height: 100vh; display: flex;
}
.login-hero {
  flex: 1.15; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 100% at 30% 20%, #24352e 0%, #16241f 45%, #0f1a16 100%);
  padding: 56px; color: #f3ecdd;
}
.login-hero-inner { position: relative; z-index: 2; max-width: 380px; }
.login-hero-art { display: block; width: 300px; height: auto; margin: 0 auto 36px; }
.login-hero-eyebrow {
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: #d9a544; margin-bottom: 10px;
}
.login-hero-inner h2 {
  font-size: 25px; line-height: 1.35; margin-bottom: 14px; color: #f9f4e6; font-weight: 500;
}
.login-hero-inner p { font-size: 14px; line-height: 1.6; color: #c9bfa4; margin: 0; }
.login-panel {
  flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px;
}
.login-panel .login-wrap { min-height: 0; padding: 0; }
.login-wrap {
  min-height: calc(100vh - 46px); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 40px 36px; width: 100%; max-width: 380px;
}
.login-logo { height: 42px; width: auto; display: block; margin-bottom: 20px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
.login-card p.subtitle { color: var(--text-muted); font-size: 13.5px; margin: 0 0 24px; }
.login-error {
  background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 10px;
  font-size: 13px; margin-bottom: 14px;
}
.login-hint {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted);
  line-height: 1.7;
}
.divider { text-align: center; font-size: 12px; color: var(--text-muted); margin: 4px 0 14px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 11px 20px; border-radius: 10px; font-size: 13.5px;
  transition: all 0.25s ease; z-index: 100; box-shadow: var(--shadow);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: white; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(30, 25, 17, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16.5px; }
.modal-body { padding: 20px; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.row-actions { display: flex; gap: 6px; }

/* ---- Übersichtsseite: Pipeline-Donut, Benachrichtigungen-Karte,
   Partner-Performance-Tabelle, Quartals-Balkendiagramm, Bexio-Kurzstatus
   (v1.11.0/v0.15.0) — zwei nebeneinander liegende Karten pro Zeile,
   klappen unter 760px auf eine Spalte (siehe Mobile-Block unten). ---- */
.dash-row { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.dash-row-wide { grid-template-columns: 1.3fr 1fr; }
.dash-row .card { margin-bottom: 0; }

.donut-row { display: flex; align-items: center; gap: 26px; }
.donut-chart {
  position: relative; width: 128px; height: 128px; border-radius: 50%; flex-shrink: 0;
}
.donut-center {
  position: absolute; inset: 20px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-center-value { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.donut-center-label { font-size: 10px; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.donut-legend-row { display: flex; align-items: center; gap: 8px; }
.donut-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.dash-notif-list { display: flex; flex-direction: column; gap: 12px; }
.dash-notif-item { padding-bottom: 11px; border-bottom: 1px solid var(--border); }
.dash-notif-item:last-child { border-bottom: none; padding-bottom: 0; }
.dash-notif-msg { font-size: 13px; margin-bottom: 4px; }
.dash-notif-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-notif-time { font-size: 11px; color: var(--text-muted); }
.dash-notif-link {
  background: none; border: none; padding: 0; font-family: inherit; cursor: pointer;
  color: var(--warning); font-size: 12px; font-weight: 700;
}
.dash-notif-link:hover { text-decoration: underline; }

.dash-quarter-chart { display: flex; align-items: flex-end; gap: 22px; padding-top: 6px; min-height: 150px; }
.dash-quarter-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dash-quarter-bar { width: 34px; border-radius: 6px 6px 0 0; background: var(--chart-neutral); }
.dash-quarter-bar-latest { background: var(--warning); }
.dash-quarter-label { font-size: 11px; color: var(--text-muted); }
.dash-quarter-label-latest { color: var(--text); font-weight: 600; }
.dash-quarter-value { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.dash-quarter-value-latest { color: var(--warning); }

.dash-sync-lines { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.dash-sync-line { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.dash-sync-line strong { color: var(--text); }

/* ---- Stat-Kacheln: klickbare Variante ---- */
.stat-card.clickable {
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.stat-card.clickable:hover { box-shadow: 0 4px 16px rgba(47, 91, 79, 0.22); transform: translateY(-1px); }
.stat-card.clickable:active { transform: translateY(1px); }
.stat-card.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Filter-Hinweis (von einer Kachel aus vorgefilterte Liste) ---- */
.filter-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--info-bg); color: var(--info); padding: 9px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 12px;
}
.filter-banner a { color: var(--info); font-weight: 600; text-decoration: underline; white-space: nowrap; cursor: pointer; }

/* ---- Notizen-Verlauf (Leads/Kunden) ---- */
.note-thread-list {
  display: flex; flex-direction: column; gap: 10px; max-height: 280px; overflow-y: auto;
  margin-bottom: 12px; padding-right: 4px;
}
.note-entry { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.note-entry-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.note-entry-author { font-weight: 600; font-size: 12.5px; }
.note-entry-role {
  font-size: 11px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 7px;
}
.note-entry-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.note-entry-body { font-size: 13px; white-space: pre-wrap; }
.note-entry-empty { color: var(--text-muted); font-size: 13px; padding: 10px 0; }
.note-thread-add { display: flex; gap: 8px; align-items: flex-start; }
.note-thread-add textarea { flex: 1; }

/* ---- Breite Tabellen: eigener horizontaler Scroll-Container statt die
   ganze Seite seitlich scrollen zu lassen (wichtig für Mobile, siehe
   @media-Block unten) — auf breiten Bildschirmen ohne Effekt, da die
   Tabelle dort ohnehin in den Container passt. ---- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Kundenportal (v1.13.0) ---- */
.nav-count {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 9px;
  background: var(--warning); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.order-card { padding-bottom: 8px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.order-head h2 { margin: 0; }
.order-meta { display: flex; gap: 28px; flex-wrap: wrap; margin: 10px 0 6px; }
.order-meta-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.order-meta-value { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-top: 2px; }
.order-positions { font-size: 12.5px; margin: 4px 0 14px; }
.order-pending { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.order-pending-title { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.order-pending-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; padding: 4px 0; }
.inline-check-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: normal; }
.inline-check { width: auto; margin: 0; }
.form-actions { flex-wrap: wrap; }

/* ==================================================================
   Mobile-Anpassungen (v1.8.0) — bestehende Seiten bleiben unverändert,
   werden aber ab hier so umgebaut, dass sie auf dem Handy ohne
   Pinch-Zoom oder seitliches Scrollen der Seite bedienbar sind. Nur
   breite Tabellen (siehe .table-scroll oben) scrollen gezielt in ihrem
   eigenen Container.
   ================================================================== */
@media (max-width: 760px) {
  .container { padding: 16px 14px 48px; }

  .page-title { flex-direction: column; align-items: flex-start; gap: 10px; }

  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .dash-row, .dash-row-wide { grid-template-columns: 1fr; gap: 16px; }
  .dash-row .card { margin-bottom: 20px; }
  .dash-row .card:last-child { margin-bottom: 0; }
  .donut-row { flex-wrap: wrap; justify-content: center; text-align: left; }
  .dash-quarter-chart { gap: 14px; }

  .table-scroll table { min-width: 620px; }

  .modal-overlay { padding: 10px; }
  .modal-body { padding: 14px; }
  .modal-head { padding: 12px 14px; }

  .note-thread-add { flex-direction: column; }
  .note-thread-add button { align-self: flex-end; }

  /* 16px verhindert das automatische Hineinzoomen von iOS Safari beim
     Fokussieren eines Eingabefelds; grössere Buttons sind leichter zu
     treffen. */
  input, textarea, select { font-size: 16px; }
  .btn, .btn-secondary { padding: 10px 16px; }
  .btn-sm { padding: 7px 12px; }

  /* Login: die Hero-Illustration braucht Platz, den ein Handy nicht hat —
     auf schmalen Bildschirmen bleibt nur die Anmeldekarte übrig, wie
     bisher. */
  .login-hero { display: none; }
}

/* ---- Rechnungen im Kundenportal (v1.14.0/v0.18.0) ---- */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.small { font-size: 12px; }
.sync-note { margin: 0 0 12px; font-size: 12.5px; }
.notice { padding: 10px 14px; border-radius: var(--radius, 8px); font-size: 13.5px; margin-bottom: 14px; }
.notice-info { background: var(--info-bg); color: var(--info); }
.notice-warn { background: var(--warning-bg); color: var(--warning); }
.page-title .btn { align-self: center; }
.nowrap { white-space: nowrap; }
.overdue-note { color: var(--danger); }
.inv-page .stat-card .value { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .inv-page .hide-sm { display: none; }
  .inv-page .table-scroll table { min-width: 0; }
  .inv-page .card { padding-left: 6px; padding-right: 6px; }
  .inv-page .stat-grid { grid-template-columns: 1fr; }
  .inv-page .stat-card .value { font-size: 22px; }
  .inv-page .table-scroll td, .inv-page .table-scroll th { padding-left: 5px; padding-right: 5px; }
}

@media (max-width: 760px) {
  .who-name { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabs { flex-wrap: wrap; }
  .order-meta { gap: 18px; }
  .order-head .row-actions { flex-wrap: wrap; }
}

/* ---- Microsoft-Lizenzen (v1.15.0/v0.19.0) ---- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ms-mine { margin-bottom: 20px; }
.ms-mine h2 { margin-bottom: 10px; }
.ms-mine p { margin: 0; }
.ms-search { margin-bottom: 14px; }
.ms-search input { max-width: 360px; }
.ms-mail { overflow-wrap: anywhere; }
.ms-code-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.ms-code-row code {
  flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.ms-setup { margin-top: 14px; }
.ms-setup summary { cursor: pointer; color: var(--text-muted); font-size: 13.5px; }
.ms-section { margin-top: 20px; }
.ms-section h3 { font-size: 14.5px; margin-bottom: 8px; }
.ms-section + .notice { margin-top: 12px; }
.ms-admin .card p { margin: 0 0 10px; }
.modal-box.modal-wide { max-width: 760px; }
.modal-wide .table-scroll table { min-width: 0; }
@media (max-width: 560px) {
  .ms-page .hide-sm, .ms-admin .hide-sm, .modal-wide .hide-sm { display: none; }
  .ms-page .table-scroll table { min-width: 0; }
  .ms-page .stat-grid { grid-template-columns: 1fr 1fr 1fr; }
  .ms-page .stat-card { padding: 12px 10px; }
  .ms-page .stat-card .value { font-size: 20px; }
  .ms-page .stat-card .label { font-size: 11.5px; }
  .ms-page .table-scroll td, .ms-page .table-scroll th { padding-left: 5px; padding-right: 5px; }
  .ms-admin .table-scroll table { min-width: 0; }
  .ms-admin .card { padding-left: 10px; padding-right: 10px; }
}

/* Kundenübersicht (ab 1.20.0): Produkt-Tabelle; auf dem Handy wird jede Zeile zu einem kleinen Block */
.order-card .table-scroll table { min-width: 0; }
@media (max-width: 560px) {
  .order-products, .order-products tbody { display: block; width: 100%; }
  .order-products thead { display: none; }
  .order-products tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--border); }
  .order-products tr:last-child { border-bottom: 0; }
  .order-products td { display: block; padding: 0; border: 0; min-width: 0; }
  .order-products td:nth-child(2)::before { content: "Menge "; color: var(--text-muted); font-size: 12px; }
  .order-products td:nth-child(3), .order-products td:nth-child(4) { grid-column: 1 / -1; }
  .order-products td:nth-child(3):empty, .order-products td:nth-child(4):empty { display: none; }
  .order-products .row-actions { text-align: left; }
  .order-products .btn-sm { padding: 5px 12px; font-size: 12.5px; }
  .order-products .badge { white-space: normal; display: inline-block; }
}

/* =====================================================================
   Ticketsystem (v1.27.0)
   ===================================================================== */
.container-wide { max-width: 1380px; }
.tk-spacer { flex: 1; }

/* ---- Status- und Prioritäts-Badges ---- */
.tk-status-open { background: var(--info-bg); color: var(--info); }
.tk-status-in_progress { background: var(--warning-bg); color: var(--warning); }
.tk-status-waiting { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.tk-status-resolved { background: var(--success-bg); color: var(--success); }
.tk-status-closed { background: var(--bg); color: var(--text-muted); }
.tk-prio-low { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.tk-prio-normal { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.tk-prio-high { background: var(--warning-bg); color: var(--warning); }
.tk-prio-urgent { background: var(--danger); color: #fff; }

/* ---- Liste: Seitenleiste mit Ansichten ---- */
.tk-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.tk-side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--stick-top, 0px) + 20px); }
.tk-side-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 14px 12px 6px; }
.tk-side-title:first-child { padding-top: 0; }
.tk-side-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; font-family: inherit;
  color: var(--text); cursor: pointer;
}
.tk-side-item:hover { background: var(--surface); }
.tk-side-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.tk-side-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.tk-side-count { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.tk-side-item.active .tk-side-count { color: #fff; opacity: 0.85; }
.tk-side-count-alert { background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px; font-weight: 600; }

.tk-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.tk-toolbar input[type="search"] { flex: 1 1 260px; width: auto; min-width: 200px; }
.tk-toolbar select { width: auto; }
.tk-list-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tk-list-head h2 { margin: 0; }
.tk-num { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-subject { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tk-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tk-sub-warn { color: var(--warning); }
.tk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
.tk-due { font-size: 12.5px; white-space: nowrap; }
.tk-due-over { color: var(--danger); font-weight: 600; }

/* ---- Ticket-Detail ---- */
.tk-back { display: inline-block; font-size: 13px; color: var(--text-muted); text-decoration: none; margin-bottom: 10px; }
.tk-back:hover { color: var(--text); text-decoration: underline; }
.tk-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.tk-head-num { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.tk-head-title { font-size: 23px; text-wrap: balance; }
.tk-head-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.tk-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.tk-main .card, .tk-aside .card { margin-bottom: 16px; }
.tk-aside .card h2 { margin-bottom: 12px; }
.tk-thread { display: flex; flex-direction: column; gap: 14px; }
.tk-msg { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--surface); max-width: 92%; }
.tk-msg-customer { align-self: flex-start; background: var(--bg); }
.tk-msg-agent { align-self: flex-end; background: var(--info-bg); border-color: transparent; }
.tk-msg-note { align-self: stretch; max-width: 100%; background: var(--warning-bg); border: 1px dashed var(--warning); }
.tk-msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 12.5px; }
.tk-msg-author { font-weight: 700; }
.tk-msg-time { margin-left: auto; color: var(--text-muted); font-size: 11.5px; }
.tk-msg-tag { font-size: 11px; font-weight: 600; background: var(--warning); color: #fff; border-radius: 999px; padding: 1px 8px; }
.tk-msg-tag-soft { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); font-weight: 500; }
.tk-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.tk-atts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.tk-att { font-size: 12.5px; color: var(--info); text-decoration: none; }
.tk-att:hover { text-decoration: underline; }

.tk-composer-note textarea { background: var(--warning-bg); border-color: var(--warning); }
#composer textarea, #composer-card textarea { margin-bottom: 10px; }
.tk-composer-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.tk-composer-actions select { width: auto; }
.tk-inline-label { margin: 0; display: inline; }
.tk-composer-hint { font-size: 12px; margin: 10px 0 0; }
.tk-closed-note { background: var(--bg); border-radius: 10px; padding: 8px 12px; font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.tk-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tk-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.tk-attach-btn { display: inline-block; margin: 0; cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; padding: 6px 10px; border: 1px dashed var(--border); border-radius: 999px; }
.tk-attach-btn:hover { background: var(--bg); }
.tk-file-input:focus-visible + .tk-file-list, .tk-file-input:focus-visible ~ .tk-attach-btn { outline: 2px solid var(--primary); }
.tk-file-list { display: contents; }
.tk-file { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.tk-file-rm { background: none; border: none; cursor: pointer; color: var(--text-muted); border-radius: 50%; width: 20px; height: 20px; }
.tk-file-rm:hover { background: var(--border); }
.tk-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--text); cursor: pointer; }
.tk-check input { width: auto; margin-top: 3px; flex: none; }

.tk-prop { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px 10px; align-items: center; margin-bottom: 10px; }
.tk-prop label { margin: 0; }
.tk-prop > :last-child:not(select):not(label) { grid-column: 2; justify-self: start; }
.tk-link-btn { background: none; border: none; padding: 0; color: var(--info); font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline; font-family: inherit; }
.tk-sla-row { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.tk-sla-row:last-of-type { border-bottom: none; }
.tk-sla-label { font-weight: 600; }
.tk-sla-due { color: var(--text-muted); font-size: 12.5px; }
.tk-sla-ok { color: var(--success); }
.tk-sla-late { color: var(--danger); font-weight: 600; }
.tk-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
.tk-kv > span:last-child { text-align: right; overflow-wrap: anywhere; }
.tk-kv-label { color: var(--text-muted); }
.tk-kv-sep { border-top: 1px solid var(--border); margin: 8px 0; }
.tk-warn { background: var(--warning-bg); color: var(--warning); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 0 0 8px; }
.tk-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; }
.tk-events li { display: flex; flex-direction: column; gap: 1px; padding-left: 12px; border-left: 2px solid var(--border); }
.tk-events time { font-size: 11px; }
.tk-flash { background: var(--info-bg); color: var(--info); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin: 0 0 14px; }
.tk-flash-warn { background: var(--warning-bg); color: var(--warning); font-weight: 600; }

/* ---- Support-Einstellungen ---- */
.ss-banner { background: var(--info-bg); color: var(--info); border-radius: 12px; padding: 12px 16px; font-size: 13.5px; margin-bottom: 14px; }
.ss-banner a { color: var(--info); font-weight: 600; }
.ss-toc { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.ss-toc-link { border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px; text-decoration: none; color: var(--text-muted); background: var(--surface); }
.ss-toc-link:hover { color: var(--text); background: var(--bg); }
.ss-section { scroll-margin-top: 80px; }
.ss-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ss-head h2 { margin: 0; }
.ss-scope { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); background: var(--info-bg); padding: 3px 10px; border-radius: 999px; }
.ss-lead { color: var(--text-muted); font-size: 13.5px; margin: 0 0 14px; max-width: 78ch; }
.ss-sub { font-size: 14px; margin: 18px 0 8px; font-family: var(--font-body); font-weight: 700; }
.ss-hint { font-size: 12px; color: var(--text-muted); margin: 3px 0 0; }
.ss-check { margin: 8px 0; }
.ss-check .ss-hint { padding-left: 24px; }
.ss-warn { background: var(--warning-bg); color: var(--warning); border-radius: 10px; padding: 9px 14px; font-size: 13px; }
.ss-box { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.ss-box-on { border-color: var(--primary); }
.ss-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ss-actions { align-items: center; flex-wrap: wrap; }
.ss-danger { color: var(--danger); }
.ss-test { margin-top: 10px; padding: 8px 12px; border-radius: 10px; font-size: 13px; background: var(--bg); }
.ss-test-ok { background: var(--success-bg); color: var(--success); }
.ss-test-bad { background: var(--danger-bg); color: var(--danger); }
.ss-details { margin-top: 10px; font-size: 13px; }
.ss-details summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.ss-details ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.ss-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ss-row input { flex: 1 1 200px; width: auto; max-width: 340px; }
.ss-row-off input { opacity: 0.6; }
.ss-row-note { font-size: 12.5px; min-width: 110px; }
.ss-table { max-width: 560px; }
.ss-table td { vertical-align: middle; }
.ss-unit { display: flex; align-items: center; gap: 8px; }
.ss-unit input { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.ss-days { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ss-day { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); font-weight: 500; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.ss-day input { width: auto; }
.ss-hours { max-width: 360px; }

@media (max-width: 960px) {
  .tk-detail { grid-template-columns: minmax(0, 1fr); }
  .tk-layout { grid-template-columns: minmax(0, 1fr); }
  .tk-side { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .tk-side-title { display: none; }
  .tk-side-item { width: auto; border: 1px solid var(--border); background: var(--surface); }
}
@media (max-width: 760px) {
  .tk-page .hide-sm { display: none; }
  .tk-msg { max-width: 100%; }
  .tk-head-title { font-size: 19px; }
  .ss-row input { max-width: none; }
}
.tk-aside a, .tk-composer-hint a, .tk-head-meta a { color: var(--info); }
.tk-aside a:hover { text-decoration: underline; }
.ss-check select { max-width: 320px; }
.ss-box-head + .ss-hint, .ss-box-head + .ss-test { margin: 0 0 12px; }
@media (prefers-color-scheme: dark) {
  .tk-status-open, .tk-flash, .ss-banner, .ss-banner a, .ss-scope, .tk-att, .tk-link-btn, .ss-details summary, .tk-attach-btn,
  .tk-aside a, .tk-composer-hint a, .tk-head-meta a, .tk-side-item.active .tk-side-count { color: #9fd1bd; }
  .tk-flash-warn { color: #f0b48e; }
  .tk-side-item.active { color: #fff; }
}

/* Tickets löschen (1.27.1) */
.tk-bulk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 12px; background: var(--info-bg); }
.tk-bulk-count { font-weight: 700; font-size: 13.5px; margin-right: 4px; }
.tk-check-col { width: 34px; padding-right: 0 !important; }
.tk-check-col input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.tk-delete { align-self: flex-start; white-space: nowrap; }
.btn-danger { background: var(--danger); color: #fff; border: 1px solid var(--danger); }
.btn.btn-danger:hover:not(:disabled) { background: var(--danger); filter: brightness(.88); }

/* ---- Wissensdatenbank (1.28.0) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kb-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.kb-brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.kb-brand img { display: block; height: 34px; width: auto; }
.kb-top-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.kb-top-links a:hover { text-decoration: underline; }
.kb-main { max-width: 900px; margin: 0 auto; padding: 32px 20px 56px; }
.kb-hero { text-align: center; padding: 20px 0 12px; }
.kb-hero h1 { font-size: 32px; margin: 0 0 8px; text-wrap: balance; }
.kb-hero p { color: var(--text-muted); margin: 0 0 18px; }
.kb-search { display: flex; gap: 10px; max-width: 620px; margin: 18px auto 0; }
.kb-search input { flex: 1; min-width: 0; }
.kb-section { margin-top: 32px; }
.kb-section h2 { font-size: 18px; margin: 0 0 12px; }
.kb-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.kb-cat { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-decoration: none; color: var(--text); }
.kb-cat:hover { border-color: var(--primary); }
.kb-cat span { color: var(--text-muted); font-size: 13.5px; }
.kb-cat em { font-style: normal; color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.kb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.kb-list li { border-top: 1px solid var(--border); }
.kb-list li:first-child { border-top: none; }
.kb-list a { display: block; padding: 12px 4px; text-decoration: none; color: var(--text); }
.kb-list a:hover strong { color: var(--primary); text-decoration: underline; }
.kb-list a span { display: block; color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.kb-crumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.kb-crumbs a { color: var(--primary); text-decoration: none; font-weight: 600; }
.kb-article-page h1 { font-size: 30px; margin: 0 0 6px; text-wrap: balance; }
.kb-meta { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.kb-lead { font-size: 17px; color: var(--text-muted); margin: 0 0 18px; }
.kb-article, .rte-area { line-height: 1.65; overflow-wrap: anywhere; }
.kb-article h2, .rte-area h2 { font-size: 22px; margin: 28px 0 8px; }
.kb-article h3, .rte-area h3 { font-size: 18px; margin: 22px 0 6px; }
.kb-article h4, .rte-area h4 { font-size: 15.5px; margin: 18px 0 4px; }
.kb-article p, .rte-area p { margin: 0 0 12px; }
.kb-article ul, .kb-article ol, .rte-area ul, .rte-area ol { margin: 0 0 14px; padding-left: 24px; }
.kb-article li, .rte-area li { margin-bottom: 4px; }
.kb-article img, .rte-area img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); margin: 6px 0; }
.kb-article blockquote, .rte-area blockquote { margin: 0 0 14px; padding: 10px 16px; border-left: 4px solid var(--primary); background: var(--info-bg); border-radius: 0 10px 10px 0; }
.kb-article code, .rte-area code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.kb-article pre, .rte-area pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 0 0 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }
.kb-article pre code, .rte-area pre code { background: none; padding: 0; }
.kb-article table, .rte-area table { border-collapse: collapse; margin: 0 0 14px; max-width: 100%; display: block; overflow-x: auto; }
.kb-article th, .kb-article td, .rte-area th, .rte-area td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.kb-article th, .rte-area th { background: var(--surface-2); }
.kb-article hr, .rte-area hr { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.kb-article a, .rte-area a { color: var(--primary); text-decoration: underline; }
.kb-feedback { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 32px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.kb-help-cta { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--info-bg); display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.kb-help-cta a { color: var(--primary); font-weight: 600; }
.kb-foot { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 24px 0 36px; }
@media (max-width: 640px) { .kb-top { padding: 12px 16px; } .kb-hero h1 { font-size: 26px; } .kb-article-page h1 { font-size: 24px; } .kb-search { flex-direction: column; } }

/* Verwaltung: Liste, Editor */
.kb-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.kb-vis { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.kb-vis-public { background: var(--warning-bg); color: var(--warning); }
.kb-vis-customers { background: var(--info-bg); color: var(--info); }
.kb-vis-internal { background: var(--surface-2); color: var(--text-muted); }
.kb-draft { font-size: 11.5px; font-weight: 700; color: var(--text-muted); border: 1px dashed var(--border); padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.kb-edit { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.kb-title-input { width: 100%; font-size: 24px; font-weight: 700; font-family: var(--font-display); padding: 10px 12px; }
.rte { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: var(--stick-top, 0px); z-index: 2; }
.rte-btn { min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.rte-btn:hover { background: var(--surface); border-color: var(--border); }
.rte-btn.active { background: var(--primary); color: #fff; }
.rte-sep { width: 1px; background: var(--border); margin: 4px 4px; }
.rte-area { min-height: 360px; padding: 16px 18px; outline: none; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.kb-side-card h2 { font-size: 14px; }
.kb-radio { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.kb-radio input { width: auto; margin-top: 3px; }
.kb-radio.on { border-color: var(--primary); background: var(--info-bg); }
.kb-radio strong { display: block; font-size: 13.5px; }
.kb-radio span { font-size: 12.5px; color: var(--text-muted); }
.kb-warn { background: var(--warning-bg); color: var(--warning); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin: 0 0 12px; }
.kb-pick { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; margin-top: 10px; }
.kb-pick-item { text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 8px 12px; font: inherit; color: var(--text); cursor: pointer; }
.kb-pick-item:hover { border-color: var(--primary); }
.kb-pick-item small { display: block; color: var(--text-muted); }
.kb-suggest { margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--info-bg); font-size: 13.5px; }
.kb-suggest a { display: block; color: var(--primary); font-weight: 600; margin-top: 4px; }
@media (max-width: 900px) { .kb-layout, .kb-edit { grid-template-columns: minmax(0, 1fr); } .kb-layout > *, .kb-edit > * { min-width: 0; } }

/* Wissensdatenbank — Verwaltung (v1.28.0) */
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tk-head-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.tk-composer-tools { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.kb-cat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.kb-cat-actions { display: flex; gap: 6px; }
.kb-cat-new { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.kb-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0 0 8px; font-size: 13.5px; }
.kb-facts dt { color: var(--text-muted); }
.kb-facts dd { margin: 0; }
.kb-pick-item { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.kb-suggest a { text-decoration: none; }
.kb-suggest a:hover { text-decoration: underline; }
.rte-area img { cursor: default; }
@media (max-width: 640px) { .kb-cat-row { grid-template-columns: minmax(0, 1fr); } }
a.btn { text-decoration: none; display: inline-block; }
#kb-manage-cats { align-self: flex-start; padding: 10px 12px; }

/* Mails in Originalformatierung (v1.28.1) */
.tk-mailhtml { background: #fff; color: #1f1d1a; border-radius: 8px; padding: 10px 12px; font-size: 14px; line-height: 1.5; overflow-x: auto; overflow-wrap: anywhere; }
.tk-mailhtml p { margin: 0 0 .6em; }
.tk-mailhtml a { color: #1a5fb4; text-decoration: underline; }
.tk-mailhtml img { max-width: 100%; height: auto; }
.tk-mailhtml table { max-width: 100%; }
.tk-mailhtml blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid #ccc; }
.tk-mailhtml pre { white-space: pre-wrap; }
.tk-mailhtml .mailhtml-blocked { color: #6b645a; font-size: 12.5px; font-style: italic; }
.tk-msg-toggle { margin-left: auto; margin-right: 8px; }
.tk-msg-toggle + .tk-msg-time { margin-left: 0; }

/* ==================================================================
   App-Shell (v1.29.0): Seitenleiste links statt Menü oben.
   Am Handy und in schmalen Fenstern (≤ 900 px) wird die Leiste zur Schublade.
   ================================================================== */
:root {
  --side-w: 248px;
  --side-bg: #1f3a33;
  --side-text: #d3e0d9;
  --side-muted: #93aca0;
  --side-active: #2f5b4f;
  --side-line: rgba(255, 255, 255, 0.1);
  --topbar-h: 0px;
  --stick-top: calc(var(--topbar-h) + var(--viewas-h, 0px));
}
@media (prefers-color-scheme: dark) {
  :root { --side-bg: #17302a; --side-active: #27493f; }
}
#app-header { display: contents; }
.app-shell { display: flex; min-height: 100vh; }
.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app-content > main { flex: 1; width: 100%; }

.app-side {
  flex: 0 0 var(--side-w); width: var(--side-w); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 24px 12px 14px;
  background: var(--side-bg); color: var(--side-text); z-index: 40;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 0 12px 18px; }
.side-brand { display: flex; flex-direction: column; gap: 3px; color: #fff; text-decoration: none; min-width: 0; }
.side-logo { display: block; width: 150px; height: auto; margin: 0 0 12px -4px; }
.side-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.side-sub { font-size: 12px; color: var(--side-muted); overflow-wrap: anywhere; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding-top: 8px; }
.side-link {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 7px 12px; border-radius: 10px;
  color: var(--side-text); text-decoration: none; font-size: 14.5px; font-weight: 500;
}
.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-link.active { background: var(--side-active); color: #fff; font-weight: 700; }
.side-link:focus-visible, .side-btn:focus-visible, .topbar-toggle:focus-visible, .side-brand:focus-visible { outline: 2px solid #d9a544; outline-offset: 1px; }
.side-link .nav-count { margin: 0 0 0 auto; padding: 0; min-width: 0; background: none; color: var(--side-muted); font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.side-link.active .nav-count { color: #d6e8df; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group-title { padding: 12px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--side-muted); }
.side-foot { margin-top: 12px; flex-shrink: 0; padding: 14px 12px 0; border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 8px; }
.side-who-label { font-size: 11.5px; color: var(--side-muted); }
.side-who-name { font-size: 14px; font-weight: 600; color: #fff; overflow-wrap: anywhere; }
.side-btn {
  width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 10px;
  background: none; color: var(--side-text); font: inherit; font-size: 13.5px; cursor: pointer; text-align: center;
}
.side-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.side-btn.hidden { display: none; }
.side-bell .bell { color: #fff; }
.pwa-steps { margin: 0 0 12px; padding-left: 22px; line-height: 1.6; }

/* Glocke: Auswahl immer über allem, nie von der Leiste abgeschnitten */
.notif-dropdown { position: fixed; left: calc(var(--side-w) + 8px); right: auto; top: 14px; width: min(340px, calc(100vw - 16px)); z-index: 60; }

.app-topbar { display: none; }
.side-overlay { display: none; }

@media (max-width: 900px) {
  :root { --topbar-h: calc(56px + env(safe-area-inset-top, 0px)); }
  .app-topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: var(--viewas-h, 0px); z-index: 30;
    height: var(--topbar-h); padding: env(safe-area-inset-top, 0px) 12px 0; background: var(--side-bg); color: #fff;
  }
  .topbar-toggle {
    width: 44px; height: 44px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.08); color: #fff; font-size: 20px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .topbar-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: #fff; text-decoration: none; }
  .topbar-logo { height: 34px; width: auto; flex: none; }
  .topbar-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-bell .bell { color: #fff; font-size: 20px; min-width: 44px; min-height: 44px; }
  .side-bell { display: none; }
  .app-side {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; width: min(300px, 86vw); flex: none;
    padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-102%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; box-shadow: none;
  }
  body.nav-open .app-side { transform: none; visibility: visible; transition: transform 0.2s ease; box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35); }
  body.nav-open .side-overlay { display: block; position: fixed; inset: 0; background: rgba(20, 16, 10, 0.5); z-index: 35; }
  body.nav-open { overflow: hidden; }
  .side-link { min-height: 42px; font-size: 15px; }
  .side-foot { position: sticky; bottom: calc(-14px - env(safe-area-inset-bottom, 0px)); background: var(--side-bg); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); margin-bottom: calc(-14px - env(safe-area-inset-bottom, 0px)); }
  .notif-dropdown { left: 8px; right: 8px; width: auto; top: calc(var(--topbar-h) + 4px); }
  .viewas-bar { padding: 9px 14px; }
}
@media (prefers-reduced-motion: reduce) { .app-side { transition: none !important; } }

/* =====================================================================
   Handy-Bedienung Ticketbereich (v1.29.0)
   ===================================================================== */
@media (max-width: 900px) {
  /* 16 px verhindert den automatischen Zoom von iOS beim Antippen eines Feldes */
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
}
@media (max-width: 720px) {
  .tk-page .page-title .subtitle { display: none; }

  /* Ansichten + Gruppen: eine einzige, seitlich wischbare Chip-Zeile */
  .tk-side { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tk-side::-webkit-scrollbar { display: none; }
  .tk-side-item { flex: 0 0 auto; white-space: nowrap; min-height: 40px; padding: 6px 14px; border-radius: 999px; gap: 8px; font-size: 14px; }
  .tk-layout { gap: 12px; }

  /* Werkzeugleiste: Suche über die ganze Breite, Filter und Knöpfe je zu zweit */
  .tk-toolbar { gap: 8px; }
  .tk-toolbar input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .tk-toolbar select, .tk-toolbar .btn { flex: 1 1 calc(50% - 4px); min-width: 0; width: auto; }
  .tk-toolbar .tk-spacer { display: none; }
  .tk-toolbar .btn { justify-content: center; }

  .tk-page .card { padding: 12px; }
  .tk-list-head { margin-bottom: 6px; }

  /* Tabelle → Karten */
  .tk-page .card .table-scroll { overflow-x: visible; }
  .tk-page .card .table-scroll table { min-width: 0; }
  .tk-page .card table, .tk-page .card tbody { display: block; }
  .tk-page .card thead { display: none; }
  .tk-page .card tbody tr {
    display: grid; grid-template-columns: 40px auto auto minmax(0, 1fr); grid-template-areas: "chk subj subj subj" "chk prio status due";
    column-gap: 8px; row-gap: 6px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--border);
  }
  .tk-page .card tbody tr:last-child { border-bottom: none; }
  .tk-page .card tbody td { display: block; padding: 0; border: none; background: none; }
  .tk-page .card tbody td.hide-sm { display: none; }
  .tk-c-chk { grid-area: chk; align-self: stretch; display: flex !important; align-items: flex-start; justify-content: center; }
  .tk-c-chk input { width: 22px; height: 22px; margin-top: 2px; }
  .tk-c-num { display: none !important; }
  .tk-c-subj { grid-area: subj; min-width: 0; }
  .tk-c-prio { grid-area: prio; }
  .tk-c-status { grid-area: status; }
  .tk-c-due { grid-area: due; justify-self: end; font-size: 12.5px; text-align: right; }
  .tk-subject { align-items: flex-start; line-height: 1.3; }
  .tk-subject > span:empty { display: none; }
  .tk-unread .tk-subject { font-weight: 700; }
  .tk-page .card tbody tr:not(.tk-unread) .tk-subject { font-weight: 500; }
  .tk-bulk { padding: 10px 12px; }
  .tk-bulk .btn { flex: 1 1 auto; }

  /* Einzelnes Ticket */
  .tk-head { flex-direction: column; gap: 10px; }
  .tk-head-actions { justify-content: flex-start; }
  .tk-head-actions .btn { flex: 1 1 auto; justify-content: center; }
  .tk-composer-actions > *, .tk-composer-tools > * { flex: 1 1 auto; }
  .tk-composer-actions .btn, .tk-composer-tools .btn { justify-content: center; }
  .tk-composer-actions select { width: 100%; }
  .tk-aside .card { padding: 14px; }
}
@media (max-width: 720px) {
  .pt-row { flex-direction: column; align-items: stretch !important; gap: 12px; }
  .pt-stats { flex-wrap: wrap; gap: 12px 20px !important; }
  .pt-stats .btn { flex: 1 1 auto; justify-content: center; }
  .tk-head-actions .btn { min-height: 44px; }
}
@media (max-width: 720px) {
  .page-title .btn { align-self: stretch; justify-content: center; }
}

/* Mit Seitenleiste bleibt auf mittleren Bildschirmen wenig Platz für die Ticketliste */
.tk-c-subj { min-width: 240px; }
@media (max-width: 1500px) { .tk-page .hide-md { display: none; } }
@media (max-width: 720px) { .tk-c-subj { min-width: 0; } }

/* ---- v1.30.0: Wiedervorlage, Zusammenführen, Vorlagen, Regeln, Freshdesk, Auswertungen ---- */
.tk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tk-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 5px 12px; font: inherit; font-size: 12.5px; cursor: pointer; min-height: 30px;
}
.tk-chip:hover { border-color: var(--primary); color: var(--primary); }
.tk-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tk-remind-now { font-size: 14px; margin: 0 0 8px; }
.tk-remind-note { margin: 0 0 10px; padding: 8px 12px; background: var(--bg); border-radius: 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-remind-tag { color: var(--warning); white-space: nowrap; }
.tk-merged-tag { color: var(--text-muted); font-style: italic; }
.tk-merged-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--info-bg); color: var(--primary); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-size: 14px;
}
.tk-merge-facts { margin: 8px 0 12px; padding-left: 20px; font-size: 13.5px; }
.tk-merge-facts li { margin-bottom: 4px; }
.tk-tpl-item small { white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-reopen-row { margin: 10px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.ss-ph { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; }
.tpl-box textarea { min-height: 110px; }
.rule-box .ss-box-head { flex-wrap: wrap; }
.rule-pos { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); border: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.rule-hits { font-size: 12.5px; margin-left: auto; }
.rule-sum { margin: 0 0 8px; overflow-wrap: anywhere; }
.fd-progress { margin-top: 14px; }
.fd-numbers { display: flex; flex-wrap: wrap; gap: 10px 24px; font-size: 14px; }
.fd-numbers strong { font-family: var(--font-display); font-size: 20px; margin-right: 4px; }
.fd-problems { margin: 8px 0 0; padding-left: 20px; font-size: 13px; max-height: 240px; overflow: auto; }

.rp-page .tk-inline-label { color: var(--text-muted); font-size: 13px; }
.rp-page .tk-toolbar input[type="date"] { width: auto; }
.rp-chips { margin: 0 0 0 auto; }
.rp-tile .rp-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.rp-tile.rp-alert .value { color: var(--danger); }
.rp-chart-wrap { width: 100%; }
.rp-chart { width: 100%; height: auto; display: block; }
.rp-grid { stroke: var(--border); stroke-width: 1; }
.rp-axis { fill: var(--text-muted); font-size: 10.5px; font-family: var(--font-body); }
.rp-bar-in { fill: var(--primary); }
.rp-bar-out { fill: var(--warning); }
.rp-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; flex-wrap: wrap; }
.rp-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.rp-key-in { background: var(--primary); }
.rp-key-out { background: var(--warning); }
.rp-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 20px; }
.rp-card { min-width: 0; }
.rp-table .rp-num, .rp-table th.rp-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-label { font-weight: 500; overflow-wrap: anywhere; }
.rp-meter { height: 4px; border-radius: 2px; background: var(--chart-neutral); margin-top: 4px; max-width: 220px; }
.rp-meter span { display: block; height: 100%; border-radius: 2px; background: var(--primary); }
.rp-oldest { margin: -6px 0 18px; font-size: 13.5px; color: var(--text-muted); }
.rp-oldest a { color: var(--primary); }
@media (max-width: 720px) {
  .rp-grid2 { grid-template-columns: 1fr; }
  .rp-chips { margin-left: 0; }
  .rp-page .card { padding: 14px; }
  .rule-hits { margin-left: 0; width: 100%; }
}

/* ---- v1.32.0: Kopie-Empfänger (Cc) ---- */
.tk-cc-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.tk-cc-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; background: var(--bg); border-radius: 10px; font-size: 13.5px; }
.tk-cc-who { min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline; }
.tk-cc-x { border: 0; background: transparent; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer; min-width: 32px; min-height: 32px; border-radius: 8px; }
.tk-cc-x:hover { color: var(--danger, #a33c2a); background: var(--surface); }
.tk-cc-x:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tk-cc-add { display: flex; gap: 8px; align-items: center; }
.tk-cc-add input { flex: 1; min-width: 0; font-size: 16px; }
