/* Comdat Ticketsystem – Oberfläche
 * Farben aus dem Comdat-Logo (Blau #0f6baf, Grau #888). Keine externen
 * Schriften oder Skripte (strenge Content-Security-Policy).
 */
:root {
  --brand: #0f6baf;
  --brand-600: #0c5a94;
  --brand-700: #0a4a7a;
  --brand-50: #eef5fc;
  --brand-100: #d7e8f7;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e8ee;
  --border-strong: #cdd5df;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --error: #c0362c;
  --error-bg: #fef3f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --info-bg: #eff8ff;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .22), 0 4px 8px -4px rgba(16, 24, 40, .08);
  --focus: 0 0 0 3px rgba(15, 107, 175, .22);
  --sidebar-w: 264px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* --- Grundlagen ------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 0 0 .75rem; }
h3 { font-size: .95rem; font-weight: 650; margin: 1.25rem 0 .5rem; }
p { margin: .5rem 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* --- App-Rahmen: Seitenleiste, Kopfzeile, Inhalt ----------------------------- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 1rem;
  background: var(--surface); border-right: 1px solid var(--border); padding: 1.1rem .9rem;
  overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: .2rem .5rem .4rem; }
.sidebar-brand img { height: 30px; width: auto; display: block; }
.sidebar-brand .app-name { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: .35rem; }
.sidebar .button.block { width: 100%; justify-content: center; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .9rem .75rem .35rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px; color: var(--text-2); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-50); color: var(--brand-700); }
.nav a.active .icon { color: var(--brand); }
.nav a .icon { color: var(--muted); width: 1.2rem; height: 1.2rem; }
.nav .count { margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 650; text-align: center; line-height: 1.4rem; }
.sidebar-user { margin-top: auto; border-top: 1px solid var(--border); padding-top: .9rem; }
.sidebar-user .who { display: flex; align-items: center; gap: .65rem; padding: 0 .5rem .6rem; min-width: 0; }
.sidebar-user .who strong { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user form { margin: 0; }
.sidebar-user .nav button { display: flex; width: 100%; align-items: center; gap: .7rem; padding: .55rem .75rem; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer; min-height: 0; }
.sidebar-user .nav button:hover { background: var(--surface-2); color: var(--text); }
.sidebar-user .nav button .icon { color: var(--muted); width: 1.2rem; height: 1.2rem; }
.backdrop { display: none; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem;
  height: 60px; padding: 0 2rem; background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(8px);
}
.topbar .menu-button { display: none; }
.topsearch { position: relative; flex: 1 1 auto; max-width: 34rem; margin: 0; }
.topsearch .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topsearch input { width: 100%; height: 38px; min-height: 0; padding: 0 .9rem 0 2.3rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); font: inherit; }
.topsearch input:focus { background: #fff; border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; min-height: 0; padding: 0; border: 1px solid transparent; border-radius: 999px; background: none; color: var(--text-2); cursor: pointer; }
.icon-button:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); text-decoration: none; }
.icon-button .icon { width: 1.25rem; height: 1.25rem; }
.bell-count { position: absolute; top: 2px; right: 1px; min-width: 1.1rem; height: 1.1rem; padding: 0 .28rem; border-radius: 999px; background: #e5484d; color: #fff; font-size: .68rem; font-weight: 700; line-height: 1.1rem; text-align: center; border: 2px solid #fff; box-sizing: content-box; }

.page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.75rem 2rem 3rem; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head .subtitle { color: var(--muted); margin: .3rem 0 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-head .actions form { margin: 0; }
.breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .icon { width: .9rem; height: .9rem; }

/* --- Meldungen --------------------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: .5rem; }
.message { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem 1rem; border-radius: var(--radius); background: var(--info-bg); border: 1px solid #b2ddff; color: #194185; }
.message.success { background: var(--ok-bg); border-color: #abefc6; color: #085d3a; }
.message.error { background: var(--error-bg); border-color: #fecdca; color: #912018; }
.message.warning { background: var(--warn-bg); border-color: #fedf89; color: #93370d; }
.notice { display: flex; gap: .6rem; align-items: center; padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid #fedf89; color: #93370d; margin-bottom: 1rem; }

/* --- Karten ------------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-head h2 .icon { color: var(--muted); }
.card-head .count { font-weight: 500; color: var(--muted); }
.card.flush .card-head { padding: 1rem 1.25rem; margin: 0; border-bottom: 1px solid var(--border); }
.stack { display: grid; gap: 1rem; align-content: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.layout-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.layout-form { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }

/* --- Kennzahlen (Startseite) ------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; gap: .9rem; align-items: center; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--text); }
a.stat:hover { border-color: var(--brand-100); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.stat .stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--brand-50); color: var(--brand); }
.stat .stat-icon .icon { width: 1.35rem; height: 1.35rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat.tone-amber .stat-icon { background: var(--warn-bg); color: var(--warn); }
.stat.tone-purple .stat-icon { background: #f4f3ff; color: #6941c6; }
.stat.tone-red .stat-icon { background: var(--error-bg); color: var(--error); }
.quick-create { display: flex; flex-wrap: wrap; gap: .5rem; }

/* --- Schaltflächen ----------------------------------------------------------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 38px; padding: 0 1rem; border: 1px solid var(--brand); border-radius: 8px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; font-size: .92rem;
  line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, color .12s;
}
button:hover, .button:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; text-decoration: none; }
button.secondary, .button.secondary { background: #fff; color: var(--text-2); border-color: var(--border-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
button.ghost, .button.ghost { background: none; border-color: transparent; color: var(--text-2); box-shadow: none; }
button.ghost:hover, .button.ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
button.danger, .button.danger { background: #fff; color: var(--error); border-color: #fecdca; }
button.danger:hover, .button.danger:hover { background: var(--error-bg); color: var(--error); border-color: #fda29b; }
button.small, .button.small { min-height: 32px; padding: 0 .7rem; font-size: .85rem; }
button.block, .button.block { width: 100%; }
button.link, .link { min-height: 0; padding: 0; border: 0; background: none; color: var(--brand); font-weight: 500; box-shadow: none; cursor: pointer; }
button.link:hover { background: none; color: var(--brand-700); text-decoration: underline; }
button.link.danger, .link.danger { color: var(--error); border: 0; background: none; }
button.link.muted { color: var(--muted); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* --- Formulare ---------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .88rem; color: var(--text-2); margin-bottom: .35rem; }
.req { color: var(--error); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search],
input[type=tel], input[type=url], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: .5rem .75rem; font: inherit; font-size: .95rem; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
select { padding-right: 2rem; }
select[multiple] { padding: .35rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[type=file] { width: 100%; padding: .45rem; font: inherit; font-size: .9rem; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); vertical-align: -.15em; margin: 0 .45rem 0 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--error); }
.error { color: var(--error); font-size: .88rem; margin: .3rem 0 0; }
.form-error { padding: .75rem 1rem; border-radius: var(--radius); background: var(--error-bg); border: 1px solid #fecdca; color: #912018; margin-bottom: 1rem; }
.hint, .help { color: var(--muted); font-size: .85rem; }
.help { margin-top: .3rem; }
.field.checkbox label { display: flex; align-items: flex-start; gap: .1rem; font-weight: 550; color: var(--text); }
.field ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.field ul label { font-weight: 450; display: flex; align-items: center; color: var(--text); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section + .form-section { margin-top: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1.25rem; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; margin: 1.25rem -1.4rem -1.25rem; padding: .9rem 1.4rem; background: rgba(255, 255, 255, .95); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 650; font-size: 1.05rem; padding: 0; margin-bottom: .75rem; color: var(--text); }
.input-with-action { display: flex; gap: .5rem; align-items: stretch; }
.input-with-action > :first-child { flex: 1; min-width: 0; }

/* --- Kundenauswahl mit Suche -------------------------------------------------- */
.picker { position: relative; }
.picker-selected { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--brand-100); border-radius: 8px; background: var(--brand-50); }
.picker-selected .picker-text { flex: 1; min-width: 0; }
.picker-selected strong { display: block; }
.picker-selected span { display: block; font-size: .85rem; color: var(--muted); }
.picker-input { position: relative; }
.picker-input .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.picker-input input { padding-left: 2.3rem; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; margin: 0; padding: .3rem; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 22rem; overflow-y: auto; }
.picker-results li { padding: .5rem .65rem; border-radius: 6px; cursor: pointer; }
.picker-results li span { display: block; font-size: .82rem; color: var(--muted); }
.picker-results li[aria-selected=true], .picker-results li:hover { background: var(--brand-50); }
.picker-results li.picker-empty { cursor: default; color: var(--muted); }
.picker-results li.picker-empty:hover { background: none; }
.picker-results li.picker-create { color: var(--brand); font-weight: 600; border-top: 1px solid var(--border); margin-top: .2rem; border-radius: 0 0 6px 6px; }
[hidden] { display: none !important; }

/* --- Dialog ------------------------------------------------------------------- */
dialog.modal { width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.4rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1.25rem 1.4rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.4rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.duplicate-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .4rem; }
.duplicate-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem .7rem; border: 1px solid #fedf89; border-radius: 8px; background: #fff; }

/* --- Reiter und Filter ---------------------------------------------------------- */
.tabs { display: inline-flex; gap: .25rem; padding: .25rem; background: #eaedf2; border-radius: 10px; margin-bottom: 1rem; overflow-x: auto; max-width: 100%; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border-radius: 7px; color: var(--text-2); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; box-shadow: var(--shadow-sm); margin-bottom: 1rem; }
.filter-row { display: flex; gap: .75rem; align-items: center; }
.filter-search { position: relative; flex: 1; }
.filter-search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.filter-search input { padding-left: 2.3rem; }
.filter-more { margin-top: .25rem; }
.filter-more summary { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: .9rem; padding: .5rem 0 0; list-style: none; }
.filter-more summary::-webkit-details-marker { display: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr)); gap: .75rem 1rem; margin-top: .75rem; }
.filter-grid label { font-weight: 600; font-size: .8rem; color: var(--muted); margin: 0; }
.filter-grid select, .filter-grid input { margin-top: .3rem; }
.filter-actions { display: flex; gap: .75rem; align-items: center; margin-top: 1rem; }

/* --- Tabellen ----------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card .table-wrap, .card.flush .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th { position: sticky; top: 0; text-align: left; padding: .65rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .74rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.list td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #fafbfd; }
table.list .title-cell a { color: var(--text); font-weight: 600; }
table.list .title-cell a:hover { color: var(--brand); }
table.list .sub { display: block; font-size: .82rem; color: var(--muted); margin-top: .1rem; }
.nowrap { white-space: nowrap; }
.number { font-family: var(--mono); font-size: .84rem; font-weight: 600; color: var(--brand-700); background: var(--brand-50); padding: .12rem .45rem; border-radius: 6px; white-space: nowrap; }
a.number:hover { text-decoration: none; background: var(--brand-100); }
.results-meta { display: flex; justify-content: space-between; align-items: center; margin: 0 0 .6rem; color: var(--muted); font-size: .88rem; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; }

/* --- Status, Abzeichen, Avatare ---------------------------------------------------- */
.status { display: inline-flex; align-items: center; gap: .4rem; padding: .18rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--info-bg); color: #175cd3; }
.status::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.status-in_progress { background: var(--warn-bg); color: var(--warn); }
.status-waiting { background: #f4f3ff; color: #6941c6; }
.status-done { background: var(--ok-bg); color: var(--ok); }
.status.large { font-size: .88rem; padding: .3rem .8rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: #f2f4f7; color: var(--text-2); white-space: nowrap; }
.badge .icon { width: .85rem; height: .85rem; }
.badge.confidential { background: var(--error-bg); color: var(--error); }
.badge.brand { background: var(--brand-50); color: var(--brand-700); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; font-size: .72rem; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--brand); }
.avatar.large { width: 38px; height: 38px; font-size: .85rem; }
.avatar.tone-1 { background: #7a5af8; }
.avatar.tone-2 { background: #0e9384; }
.avatar.tone-3 { background: #dd6b20; }
.avatar.tone-4 { background: #d92d7a; }
.avatar.tone-5 { background: #4e5ba6; }
.avatars { display: inline-flex; align-items: center; }
.avatars .avatar { border: 2px solid #fff; margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }
.person { display: inline-flex; align-items: center; gap: .5rem; }
.muted { color: var(--muted); }

/* --- Ticketansicht ------------------------------------------------------------ */
.ticket-head { margin-bottom: 1.25rem; }
.ticket-head .meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.ticket-head h1 { font-size: 1.55rem; }
.ticket-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.ticket-head .actions form { margin: 0; }
.prose { color: var(--text); overflow-wrap: anywhere; }
.prose p { margin: 0 0 .6rem; }
.prose p:last-child { margin-bottom: 0; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .55rem 1rem; margin: 0; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.stacked { grid-template-columns: 1fr; gap: .15rem; }
.facts.stacked dt { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-top: .6rem; }
.facts.stacked dt:first-child { margin-top: 0; }
.contact-lines { display: grid; gap: .3rem; margin-top: .5rem; font-size: .9rem; }
.contact-lines a, .contact-lines span { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-2); }
.contact-lines .icon { color: var(--muted); }
.side-form + .side-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.side-form .field { margin-bottom: .6rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: .8rem; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.comment:first-child { padding-top: 0; }
.comment .comment-body { flex: 1; min-width: 0; }
.comment header { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; margin-bottom: .3rem; }
.comment header strong { font-size: .92rem; }
.comment header .hint { font-size: .8rem; }
.comment-form { display: flex; gap: .8rem; padding-top: 1rem; }
.comment-form form { flex: 1; }
.comment-form textarea { min-height: 5.5rem; }
.history { list-style: none; padding: 0; margin: 0; position: relative; }
.history > li { position: relative; padding: 0 0 1rem 1.4rem; font-size: .9rem; }
.history > li::before { content: ""; position: absolute; left: .3rem; top: .45rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--border-strong); box-shadow: 0 0 0 3px #fff; }
.history > li::after { content: ""; position: absolute; left: .52rem; top: 1.1rem; bottom: 0; width: 1px; background: var(--border); }
.history > li:last-child::after { display: none; }
.history .when { color: var(--muted); font-size: .8rem; }
.history ul { margin: .25rem 0 0; padding-left: 1rem; color: var(--text-2); }
.history details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.attachments { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.attachments li { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; }
.attachments .file-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 8px; background: var(--brand-50); color: var(--brand); overflow: hidden; }
.attachments .file-meta { flex: 1; min-width: 0; }
.attachments .file-meta a { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachments form { margin: 0; }
.thumb { width: 40px; height: 40px; object-fit: cover; display: block; }
.upload-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.upload-form input[type=file] { flex: 1 1 14rem; width: auto; }
.tree, .tree ul { list-style: none; margin: 0; padding-left: 1.1rem; }
.tree { padding-left: 0; font-size: .9rem; }
.tree li { padding: .3rem 0 .3rem .7rem; border-left: 1px dashed var(--border-strong); }
.tree li.current > strong { background: var(--warn-bg); padding: .05rem .35rem; border-radius: 5px; }
.parent-form { display: flex; gap: .5rem; align-items: flex-end; margin-top: .75rem; }
.parent-form .field { margin: 0; flex: 1; }
.parent-form label { font-size: .8rem; }
.inline-form { margin: 0; }
form.inline { display: inline; margin: 0; }

/* --- Listen: Kategorie-Auswahl, Benachrichtigungen, Kunden --------------------------- */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.choice { display: flex; gap: .9rem; align-items: center; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--text); }
.choice:hover { border-color: var(--brand); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.choice .choice-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 12px; background: var(--brand-50); color: var(--brand); font-family: var(--mono); font-weight: 700; font-size: .85rem; }
.choice strong { display: block; font-size: 1rem; }
.choice span { display: block; color: var(--muted); font-size: .85rem; }
.choice .icon.go { margin-left: auto; color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: .8rem; align-items: flex-start; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed li .feed-body { flex: 1; min-width: 0; }
.feed li .feed-body a { color: var(--text); font-weight: 550; }
.feed li .feed-body a:hover { color: var(--brand); }
.feed li .hint { display: block; font-size: .8rem; margin-top: .1rem; }
.feed li.unread { background: #f5f9fe; }
.feed li.unread .feed-body a { font-weight: 700; }
.feed .dot { width: .55rem; height: .55rem; border-radius: 50%; background: transparent; margin-top: .45rem; flex: none; }
.feed li.unread .dot { background: var(--brand); }
.feed .ticket-line { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.feed .ticket-line .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-weight: 550; }
.empty { display: grid; place-items: center; gap: .4rem; text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon { width: 2rem; height: 2rem; color: var(--border-strong); }
.empty strong { color: var(--text-2); }
.contact-card { padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 10px; }
.contact-card + .contact-card { margin-top: .6rem; }
.contact-card header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.contact-card .contact-lines { margin-top: .35rem; }

/* --- Anmeldung ------------------------------------------------------------------ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background:
  radial-gradient(1200px 500px at 10% -10%, #dcebf8 0%, transparent 60%),
  radial-gradient(900px 500px at 110% 110%, #e6eef7 0%, transparent 60%), var(--bg); }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 2rem 2rem 1.5rem; }
.auth-logo { display: block; height: 42px; width: auto; margin: 0 auto 1.5rem; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card .lead { text-align: center; color: var(--muted); margin: .4rem 0 1.5rem; }
.auth-card button[type=submit] { width: 100%; min-height: 42px; margin-top: .5rem; }
.auth-foot { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: .85rem; }
.auth-card.wide { width: min(560px, 100%); }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .9rem; }
.qr { margin: .75rem 0; max-width: 13rem; padding: .5rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { display: inline-block; margin-top: .3rem; padding: .3rem .55rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; word-break: break-all; font-family: var(--mono); font-size: .9rem; }
.links li { margin-bottom: .5rem; }
.small { font-size: .88rem; }

/* --- Kleine Bildschirme -------------------------------------------------------------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-detail, .layout-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(16, 24, 40, .4); }
  .main { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .topbar .menu-button { display: inline-flex; }
  .page { padding: 1.25rem 1rem 2.5rem; }
}
@media (max-width: 700px) {
  body { font-size: 15px; }
  h1 { font-size: 1.35rem; }
  .stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
  .stat { padding: .85rem; gap: .6rem; }
  .stat .stat-icon { width: 36px; height: 36px; }
  .stat .value { font-size: 1.35rem; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 1rem; }
  .sticky-actions { margin: 1rem -1rem -1rem; padding: .8rem 1rem; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .facts dt { margin-top: .5rem; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
  table.cards td { border: 0; padding: .15rem 0; }
  table.cards td[data-label]:not(.title-cell):not(.number-cell)::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .topbar-actions .hide-mobile { display: none; }
  .filter-row { flex-wrap: wrap; }
  .auth-card { padding: 1.5rem 1.25rem 1.25rem; }
}
/* Mindestgröße für Tippflächen */
@media (pointer: coarse) {
  button, .button, .tabs a, select, input { min-height: 44px; }
}
.sidebar .menu-close { display: none; }
@media (max-width: 960px) { .sidebar .menu-close { display: inline-flex; } }

/* --- Feinschliff ------------------------------------------------------------ */
.topsearch input[type=search], .filter-search input[type=search], .filter-search input[type=text],
.picker-input input[type=search] { padding-left: 2.3rem; }
.topsearch input[type=search] { height: 38px; min-height: 0; border-radius: 999px; background: var(--surface-2); border-color: var(--border); box-shadow: none; }
.sidebar-user .who > div span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .avatar { display: inline-grid; color: #fff; font-size: .8rem; }
.sidebar-user .nav button { justify-content: flex-start; box-shadow: none; font-size: .92rem; }
.nav a { font-size: .92rem; min-width: 0; }
.stat .value, .stat .label { display: block; }
.grid > .card + .card, .grid-2 > .card + .card, .stack > .card + .card, .stack > section + section { margin-top: 0; }
.checklist { display: grid; gap: .15rem; max-height: 13rem; overflow-y: auto; padding: .35rem .5rem; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; }
.checklist > div > label, .checklist label { display: flex; align-items: center; gap: .1rem; margin: 0; padding: .3rem .2rem; font-weight: 450; color: var(--text); border-radius: 6px; cursor: pointer; }
.checklist label:hover { background: var(--surface-2); }
.show-mobile { display: none !important; }
@media (max-width: 700px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: inline-flex !important; }
  .feed li { padding: .8rem 1rem; }
  .feed .ticket-line { flex-wrap: wrap; row-gap: .25rem; }
  .feed .ticket-line .title { order: 3; flex-basis: 100%; white-space: normal; }
}

/* --- Aufklappbares Ticket-Menü in der Seitenleiste ------------------------------ */
.nav-group summary { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px; color: var(--text-2); font-weight: 550; font-size: .92rem; cursor: pointer; list-style: none; user-select: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: var(--surface-2); color: var(--text); }
.nav-group summary .icon { color: var(--muted); width: 1.2rem; height: 1.2rem; }
.nav-group summary.active { color: var(--brand-700); }
.nav-group summary.active .icon { color: var(--brand); }
.nav-group summary .nav-chevron { margin-left: auto; width: 1rem; height: 1rem; transition: transform .15s; }
.nav-group[open] summary .nav-chevron { transform: rotate(90deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px 1.35rem; padding-left: .7rem; border-left: 1px solid var(--border); }
.nav .nav-sub a { padding: .4rem .6rem; font-size: .87rem; font-weight: 500; gap: .5rem; }
.nav .nav-sub a.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.nav-prefix { flex: none; min-width: 2.4rem; padding: .05rem .3rem; border-radius: 5px; background: #f2f4f7; color: var(--muted); font-family: var(--mono); font-size: .7rem; font-weight: 700; text-align: center; }
.nav-sub a.active .nav-prefix { background: var(--brand-100); color: var(--brand-700); }
.nav-count { margin-left: auto; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: #eaedf2; color: var(--text-2); font-size: .72rem; font-weight: 650; line-height: 1.35rem; text-align: center; }
