/*
 * Ticketsystem – Oberfläche
 *
 * Design-System mit hellem und dunklem Farbschema, Schrift „Inter“ (lokal, SIL OFL),
 * Inline-SVG-Icons und ohne externe Ressourcen (passend zur strikten Content-Security-Policy).
 *
 * Farbschema: folgt dem System; über den Schalter in der Kopfleiste fest auf hell/dunkel
 * umstellbar (data-theme am <html>-Element, gesetzt von theme.js).
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterVariable.woff2") format("woff2");
}

/* ------------------------------------------------------------------ Tokens */
:root {
  color-scheme: light;

  --bg: #f5f6fa;
  --bg-accent: radial-gradient(1200px 500px at 85% -10%, rgba(99, 102, 241, .07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f8;
  --surface-raised: #ffffff;
  --border: #e5e7ef;
  --border-strong: #d2d6e1;
  --text: #0f172a;
  --text-2: #475467;
  --muted: #6b7385;
  --placeholder: #9aa1b1;

  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-hover: #4338ca;
  --accent-text: #4338ca;
  --accent-soft: #eef0ff;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
  --ring: rgba(99, 102, 241, .28);

  --blue: #2563eb;
  --violet: #7c3aed;
  --amber: #d97706;
  --orange: #ea580c;
  --green: #16a34a;
  --red: #dc2626;
  --slate: #64748b;
  --sky: #0284c7;

  --ok: #15803d;
  --warn: #b45309;
  --error: #b91c1c;
  --info: #1d4ed8;
  --note: #92400e;
  --note-bg: #fffbeb;
  --note-border: #f5d68a;

  --tint-base: #ffffff;
  --tint-bg: 9%;
  --tint-border: 24%;
  --tint-text-base: #000000;
  --tint-text: 78%;

  --nav-bg: #0c1121;
  --nav-glow: radial-gradient(520px 260px at -10% -5%, rgba(99, 102, 241, .28), transparent 65%);
  --nav-text: #a7b0c5;
  --nav-icon: #6f7a94;
  --nav-hover: rgba(255, 255, 255, .055);
  --nav-active: rgba(255, 255, 255, .095);
  --nav-border: rgba(255, 255, 255, .07);

  --radius-lg: 16px;
  --radius: 12px;
  --radius-md: 10px;
  --radius-sm: 7px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 2px 4px -2px rgba(16, 24, 40, .06), 0 8px 16px -4px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, .25);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --sidebar-w: 264px;
  --topbar-h: 64px;
}

/* Dunkles Schema: explizit gewählt … */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d16;
  --bg-accent: radial-gradient(1200px 500px at 85% -10%, rgba(99, 102, 241, .10), transparent 60%);
  --surface: #11151f;
  --surface-2: #151a26;
  --surface-3: #1b2130;
  --surface-raised: #171c29;
  --border: #232a3a;
  --border-strong: #303849;
  --text: #e8ebf3;
  --text-2: #a9b2c5;
  --muted: #8790a5;
  --placeholder: #616a80;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-hover: #a5b4fc;
  --accent-text: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, .13);
  --ring: rgba(129, 140, 248, .35);
  --ok: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --info: #93c5fd;
  --note: #fcd34d;
  --note-bg: rgba(245, 158, 11, .08);
  --note-border: rgba(245, 158, 11, .32);
  --tint-base: transparent;
  --tint-bg: 15%;
  --tint-border: 32%;
  --tint-text-base: #ffffff;
  --tint-text: 62%;
  --nav-bg: #070a12;
  --nav-border: rgba(255, 255, 255, .06);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .25);
  --shadow-md: 0 2px 4px -2px rgba(0, 0, 0, .4), 0 8px 16px -4px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, .5), 0 4px 8px -4px rgba(0, 0, 0, .3);
  --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, .6);
}

/* … oder vom System übernommen (sofern nicht ausdrücklich hell gewählt). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0d16;
    --bg-accent: radial-gradient(1200px 500px at 85% -10%, rgba(99, 102, 241, .10), transparent 60%);
    --surface: #11151f;
    --surface-2: #151a26;
    --surface-3: #1b2130;
    --surface-raised: #171c29;
    --border: #232a3a;
    --border-strong: #303849;
    --text: #e8ebf3;
    --text-2: #a9b2c5;
    --muted: #8790a5;
    --placeholder: #616a80;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-hover: #a5b4fc;
    --accent-text: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, .13);
    --ring: rgba(129, 140, 248, .35);
    --ok: #4ade80;
    --warn: #fbbf24;
    --error: #f87171;
    --info: #93c5fd;
    --note: #fcd34d;
    --note-bg: rgba(245, 158, 11, .08);
    --note-border: rgba(245, 158, 11, .32);
    --tint-base: transparent;
    --tint-bg: 15%;
    --tint-border: 32%;
    --tint-text-base: #ffffff;
    --tint-text: 62%;
    --nav-bg: #070a12;
    --nav-border: rgba(255, 255, 255, .06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .25);
    --shadow-md: 0 2px 4px -2px rgba(0, 0, 0, .4), 0 8px 16px -4px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 24px -6px rgba(0, 0, 0, .5), 0 4px 8px -4px rgba(0, 0, 0, .3);
    --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, .6);
  }
}

/* ------------------------------------------------------------------ Basis */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-accent), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; color: var(--text); letter-spacing: -.012em; }
h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.024em; }
h2 { font-size: 1.06rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75em; }
strong { font-weight: 650; }
code, pre, .pre, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: .05em .35em; }
.pre {
  display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: .7rem .85rem; white-space: pre-wrap; word-break: break-all; margin: .5rem 0;
}
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.35rem; height: 1.35rem;
  padding: 0 .3rem; border-radius: 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  background: var(--surface-2); color: var(--muted); font-size: .72rem; line-height: 1;
}
.select-all { user-select: all; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -.2em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sidebar :focus-visible, .mobile-nav-panel :focus-visible { outline-color: #a5b4fc; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: .75rem; top: -3rem; z-index: 100;
  background: var(--accent); color: #fff; padding: .55rem 1rem; border-radius: var(--radius-md); font-weight: 600;
}
.skip-link:focus { top: .75rem; color: #fff; text-decoration: none; }

.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); }
.error-text { color: var(--error); }
.empty { color: var(--muted); padding: .75rem 0; margin: 0; }
.sub { display: block; font-size: .84em; margin-top: .1rem; }
[hidden] { display: none !important; }

/* Ohne / mit JavaScript */
.js-only { display: none; }
.js .js-only { display: inline; }
.js .no-js-only { display: none; }

/* ------------------------------------------------------------------ Rahmen */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .35rem;
  padding: 1.1rem .85rem 1rem;
  background: var(--nav-glow), var(--nav-bg);
  color: var(--nav-text);
  border-right: 1px solid var(--nav-border);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent;
}
.brand {
  display: flex; align-items: center; gap: .7rem;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em;
  padding: .2rem .5rem .9rem;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 6px 16px -4px rgba(99, 102, 241, .6); }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-cta { margin: 0 .15rem .7rem; }

.nav { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav li a {
  position: relative; display: flex; align-items: center; gap: .75rem;
  padding: .52rem .7rem; border-radius: var(--radius-md);
  color: var(--nav-text); text-decoration: none; font-weight: 500; font-size: .92rem;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav li a .icon { color: var(--nav-icon); transition: color .15s var(--ease); }
.nav li a:hover { background: var(--nav-hover); color: #fff; }
.nav li a:hover .icon { color: #c7cde0; }
.nav li a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav li a.active .icon { color: #a5b4fc; }
.nav li a.active::before {
  content: ""; position: absolute; left: -.85rem; top: .45rem; bottom: .45rem; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent-grad);
}
.nav-heading {
  text-transform: uppercase; letter-spacing: .09em; font-size: .68rem; font-weight: 650; color: #5f6a83;
  margin: 1.35rem .7rem .45rem;
}
.nav-user {
  margin-top: auto; padding: .75rem .25rem 0; border-top: 1px solid var(--nav-border);
  display: flex; align-items: center; gap: .35rem;
}
.nav-user > a {
  flex: 1; min-width: 0; display: flex; gap: .65rem; align-items: center;
  color: var(--nav-text); text-decoration: none; padding: .4rem .45rem; border-radius: var(--radius-md);
}
.nav-user > a:hover, .nav-user > a.active { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav-user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.nav-user-name { color: #fff; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-role { font-size: .76rem; color: #7d879e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user form { margin: 0; }
.nav-logout {
  display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-size: .88rem; font-weight: 500;
  background: transparent; border: 1px solid transparent; color: var(--nav-text); cursor: pointer;
  padding: .5rem; border-radius: var(--radius-md); transition: background-color .15s, color .15s;
}
.nav-logout:hover { background: rgba(239, 68, 68, .14); color: #fecaca; }
.sidebar .nav-logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.shell { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 2rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand-mobile { display: none; color: var(--text); padding: 0; }
.brand-mobile:hover { color: var(--text); }
.brand-mobile img { width: 30px; height: 30px; }
.topbar-search { position: relative; flex: 1; min-width: 0; max-width: 520px; margin: 0; }
.topbar-search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar-search input[type="search"] {
  padding-left: 2.5rem; padding-right: 2.5rem; height: 40px; min-height: 40px;
  background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-xs);
}
.topbar-search kbd { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); }
.js .topbar-search kbd.js-only { display: inline-flex; }
.topbar-search input:focus ~ kbd { opacity: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); cursor: pointer; text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s, transform .15s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.icon-btn:active { transform: scale(.96); }
.js .icon-btn.js-only { display: inline-flex; }
.icon-btn-primary { background: var(--accent-grad); color: #fff; border-color: transparent; }
.icon-btn-primary:hover { color: #fff; filter: brightness(1.08); background: var(--accent-grad); }
.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: block; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-dark { display: block; }
  :root:not([data-theme="light"]) .theme-icon-light { display: none; }
}
.topbar-new { display: none; }

.mobile-nav { display: none; }
.mobile-nav > summary { list-style: none; }
.mobile-nav > summary::-webkit-details-marker { display: none; }
.mobile-nav .icon-close { display: none; }
.mobile-nav[open] .icon-close { display: block; }
.mobile-nav[open] .icon-open { display: none; }

.main {
  width: 100%; max-width: 1380px;
  padding: 1.75rem 2rem 3.5rem;
}
.main:focus { outline: none; }

.demo-banner {
  display: flex; align-items: center; gap: .5rem;
  background: repeating-linear-gradient(-45deg, rgba(245, 158, 11, .14), rgba(245, 158, 11, .14) 10px, rgba(245, 158, 11, .07) 10px, rgba(245, 158, 11, .07) 20px);
  border: 1px solid rgba(245, 158, 11, .4); color: var(--note); border-radius: var(--radius-md);
  padding: .55rem .9rem; font-weight: 600; margin-bottom: 1.1rem; font-size: .88rem;
}

/* ------------------------------------------------------------ Seitenkopf */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem;
  margin-bottom: 1.4rem;
}
.page-header h1 { margin: 0; }
.page-header > p { flex-basis: 100%; margin: 0; color: var(--muted); }
.page-eyebrow { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; letter-spacing: .01em; }
.page-sub { margin: .35rem 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.page-actions form { margin: 0; }

/* ------------------------------------------------------------------ Karten */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}
.card > h2:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .85rem; }
.card-header h2 { margin: 0; }
.card-header a { font-size: .86rem; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem; }
.card-header a .icon { width: 15px; height: 15px; transition: transform .15s var(--ease); }
.card-header a:hover { text-decoration: none; }
.card-header a:hover .icon { transform: translateX(2px); }
details.card > summary { cursor: pointer; font-weight: 650; }
.alert-card { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); background: color-mix(in srgb, var(--amber) 7%, var(--surface)); }
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.danger-zone > h2:first-child { color: var(--error); }
.status-line { margin: -.6rem 0 1.1rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

.empty-state {
  text-align: center; padding: 3rem 1.25rem;
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
}
.empty-state p { margin: 0; }
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: .75rem;
  border-radius: 16px; background: var(--accent-soft); color: var(--accent-text);
}
.empty-icon .icon { width: 26px; height: 26px; }
.empty-mini { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem; padding: 1.5rem 1rem 1.25rem; }
.empty-mini p { margin: 0; }
.empty-mini .empty-icon { width: 46px; height: 46px; border-radius: 14px; margin-bottom: .55rem; }
.empty-mini .empty-icon .icon { width: 22px; height: 22px; }
.status-card { background: var(--surface-2); }

/* ---------------------------------------------------------------- Buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; letter-spacing: -.005em;
  min-height: 38px; padding: .5rem .95rem; border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease),
    box-shadow .15s var(--ease), transform .15s var(--ease), filter .15s var(--ease);
}
.btn .icon { width: 17px; height: 17px; }
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 4px 12px -4px rgba(99, 102, 241, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { color: #fff; filter: brightness(1.07) saturate(1.05); box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 8px 18px -6px rgba(99, 102, 241, .65), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: color-mix(in srgb, var(--text) 25%, var(--border-strong)); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost-dark { background: transparent; color: var(--nav-text); border-color: var(--nav-border); }
.btn-ghost-dark:hover { background: var(--nav-hover); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; box-shadow: 0 4px 12px -4px rgba(220, 38, 38, .5); }
.btn-danger:hover { color: #fff; filter: brightness(1.07); }
.btn-note { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; box-shadow: 0 4px 12px -4px rgba(217, 119, 6, .5); }
.btn-note:hover { color: #fff; filter: brightness(1.06); }
.btn-sm { min-height: 32px; padding: .32rem .7rem; font-size: .83rem; border-radius: var(--radius-sm); }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-link-danger {
  background: none; border: 0; padding: .1rem .3rem; color: var(--error); font: inherit; font-size: .8rem; font-weight: 600;
  cursor: pointer; border-radius: 6px;
}
.btn-link-danger:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
form.inline, form.inline-form { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }

/* ------------------------------------------------------------- Formulare */
.form .field, .stack .field { margin-bottom: .15rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.field-inline { flex-direction: row; align-items: center; gap: .65rem; flex-wrap: wrap; }
.field-inline select { width: auto; min-width: 200px; }
label { font-weight: 600; font-size: .86rem; color: var(--text); }
.req { color: var(--error); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"],
input[type="number"], input[type="datetime-local"], input[type="date"], input[type="tel"], select, textarea {
  font: inherit; font-size: .92rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: .55rem .75rem; width: 100%; min-height: 40px;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text) 22%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238891a5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px;
}
select[multiple] { background-image: none; padding-right: .75rem; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
textarea { min-height: 9rem; resize: vertical; line-height: 1.6; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input[type="file"] { font: inherit; font-size: .88rem; color: var(--text-2); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; font-size: .85rem; margin-right: .75rem; cursor: pointer;
  padding: .42rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs);
}
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.help { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.5; }
.help.warn { color: var(--warn); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 1.1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .4rem; }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.form-inline .field { min-width: 240px; }
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem 1.1rem; margin: 0; min-width: 0;
  background: var(--surface-2);
}
legend { font-weight: 650; padding: 0 .4rem; font-size: .9rem; }
fieldset > * + * { margin-top: .9rem; }
fieldset > legend + * { margin-top: .2rem; }
fieldset > .form-grid > .field, fieldset > .form-grid > .check { margin-top: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 450; cursor: pointer; line-height: 1.45; }
.check input { margin-top: .15rem; width: 1.05rem; height: 1.05rem; flex: none; }
.check-list {
  max-height: 280px; overflow: auto; display: flex; flex-direction: column; gap: .4rem; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
}

/* ---------------------------------------------------------------- Hinweise */
.alert {
  --tone: var(--blue);
  position: relative; display: block;
  border: 1px solid color-mix(in srgb, var(--tone) var(--tint-border), var(--tint-base));
  background: color-mix(in srgb, var(--tone) 7%, var(--surface));
  color: var(--text);
  border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1.1rem; font-size: .92rem;
}
.alert.has-icon { display: flex; gap: .7rem; align-items: flex-start; }
.alert-icon { color: var(--tone); flex: none; margin-top: .05rem; }
.alert-body { min-width: 0; flex: 1; }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert ul { margin: .3rem 0 .5rem 1.15rem; padding: 0; }
.alert a { font-weight: 600; }
.alert-success { --tone: var(--green); }
.alert-error { --tone: var(--red); }
.alert-warning { --tone: var(--amber); }
.alert-info { --tone: var(--blue); }

/* ------------------------------------------------------------------ Badges */
.badge {
  --tone: var(--slate);
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .76rem; font-weight: 600; line-height: 1.2; letter-spacing: .005em;
  padding: .22rem .6rem; border-radius: 999px; white-space: nowrap; vertical-align: middle;
  background: var(--surface-3);
  background: color-mix(in srgb, var(--tone) var(--tint-bg), var(--tint-base));
  border: 1px solid color-mix(in srgb, var(--tone) var(--tint-border), var(--tint-base));
  color: color-mix(in srgb, var(--tone) var(--tint-text), var(--tint-text-base));
}
.badge .icon { width: 13px; height: 13px; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tone); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); }
.status-new { --tone: var(--blue); }
.status-in_progress { --tone: var(--violet); }
.status-waiting_customer { --tone: var(--amber); }
.status-waiting_support { --tone: var(--orange); }
.status-resolved { --tone: var(--green); }
.status-closed { --tone: var(--slate); }
.status-new .dot, .status-waiting_support .dot { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--tone) 6%, transparent); }
}
.prio-low { --tone: var(--slate); }
.prio-normal { --tone: var(--slate); }
.prio-high { --tone: var(--orange); }
.prio-urgent { --tone: var(--red); }
.prio-normal .icon { opacity: .6; }
.due-overdue { --tone: var(--red); background: linear-gradient(135deg, #ef4444, #dc2626); border-color: transparent; color: #fff; }
.due-today { --tone: var(--amber); }
.due-later { --tone: var(--slate); }
.badge-ok { --tone: var(--green); }
.badge-warn { --tone: var(--amber); }
.badge-error { --tone: var(--red); }
.badge-muted { --tone: var(--slate); }
.badge-note { --tone: var(--amber); }
.out-sent { --tone: var(--green); }
.out-queued, .out-sending { --tone: var(--blue); }
.out-failed, .out-bounced { --tone: var(--red); }
.out-unclear { --tone: var(--amber); }
.out-cancelled { --tone: var(--slate); }
.in-review, .in-error { --tone: var(--amber); }
.in-bounce { --tone: var(--red); }
.in-assigned, .in-ticket_created, .in-reply_added, .in-note_added { --tone: var(--green); }

/* ----------------------------------------------------------------- Avatare */
.avatar {
  --tone: #6366f1;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: color-mix(in srgb, var(--tone) 16%, var(--surface));
  color: color-mix(in srgb, var(--tone) 80%, var(--tint-text-base));
  border: 1px solid color-mix(in srgb, var(--tone) 24%, transparent);
  font-weight: 650; font-size: .76rem; letter-spacing: .02em; user-select: none;
}
.tone-0 { --tone: #6366f1; }
.tone-1 { --tone: #8b5cf6; }
.tone-2 { --tone: #ec4899; }
.tone-3 { --tone: #f43f5e; }
.tone-4 { --tone: #f97316; }
.tone-5 { --tone: #10b981; }
.tone-6 { --tone: #14b8a6; }
.tone-7 { --tone: #0ea5e9; }
.avatar-xs { width: 1.4rem; height: 1.4rem; font-size: .58rem; }
.sidebar .avatar, .mobile-nav-panel .avatar { background: color-mix(in srgb, var(--tone) 30%, #0c1121); color: #fff; border-color: rgba(255, 255, 255, .1); }

/* -------------------------------------------------------------- Dashboard */
.hello { margin-bottom: 1.5rem; }
.hello h1 { margin: 0; font-size: 1.85rem; }
.hello h1 .wave { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hello .page-sub { margin-top: .3rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tile {
  --tone: var(--accent);
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; gap: .1rem .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 1.1rem 1.15rem 1rem; text-decoration: none; color: var(--text);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.tile::after {
  content: ""; position: absolute; inset: auto -40% -60% auto; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tone) 14%, transparent), transparent);
  pointer-events: none;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--tone) 35%, var(--border)); color: var(--text); text-decoration: none; }
.tile-icon {
  grid-column: 2; grid-row: 1 / span 2; align-self: start;
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 13%, var(--tint-base)); color: var(--tone);
}
.tile-count { grid-column: 1; grid-row: 1; font-size: 2.1rem; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile-label { grid-column: 1; grid-row: 2; font-weight: 600; font-size: .92rem; }
.tile-desc { grid-column: 1 / -1; grid-row: 3; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.tile-mine { --tone: var(--accent); }
.tile-unassigned { --tone: var(--violet); }
.tile-today { --tone: var(--amber); }
.tile-overdue { --tone: var(--red); }
.tile-waiting_customer { --tone: var(--sky); }
.tile-alert .tile-count { color: var(--tone); }

.ticket-mini-list { list-style: none; margin: 0 -.6rem; padding: 0; }
.ticket-mini-list li { position: relative; padding: .7rem .6rem; border-radius: var(--radius-md); transition: background-color .15s; }
.ticket-mini-list li + li::before { content: ""; position: absolute; top: 0; left: .6rem; right: .6rem; border-top: 1px solid var(--border); }
.ticket-mini-list li:hover { background: var(--surface-2); }
.ticket-mini-list li:hover + li::before, .ticket-mini-list li:hover::before { opacity: 0; }
.ticket-mini-list a { display: flex; align-items: baseline; gap: .6rem; text-decoration: none; color: var(--text); font-weight: 600; min-width: 0; }
.ticket-mini-list a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.ticket-mini-list .ticket-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-mini-list .meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); margin-top: .35rem; pointer-events: none; }
.ticket-no {
  font-family: var(--mono); font-size: .76rem; font-weight: 500; color: var(--text-2); white-space: nowrap;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: .08rem .4rem; letter-spacing: -.01em;
}
a.ticket-no:hover { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); text-decoration: none; }

/* ---------------------------------------------------------- Ticketliste */
.chips { display: inline-flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1.1rem; padding: .25rem; background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .42rem .85rem; border-radius: 9px;
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: .86rem;
  transition: background-color .15s, color .15s;
}
.chip:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); text-decoration: none; }
.chip.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chip-count { background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 999px; padding: .02rem .45rem; font-size: .74rem; font-variant-numeric: tabular-nums; }
.chip.active .chip-count { background: var(--accent-soft); color: var(--accent-text); }

.filters { padding: 1rem 1.1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .65rem; align-items: flex-end; }
.toolbar .field-search { flex: 1 1 280px; }
.toolbar .field { min-width: 170px; }
.toolbar .field label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.35rem; }
.more-filters { margin-top: .85rem; border-top: 1px dashed var(--border); padding-top: .75rem; }
.more-filters > summary {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; list-style: none;
  font-weight: 600; font-size: .86rem; color: var(--text-2); padding: .2rem .1rem; border-radius: 6px;
}
.more-filters > summary::-webkit-details-marker { display: none; }
.more-filters > summary .icon { transition: transform .2s var(--ease); width: 16px; height: 16px; }
.more-filters[open] > summary .icon { transform: rotate(180deg); }
.more-filters > summary:hover { color: var(--text); }
.filter-count { background: var(--accent-soft); color: var(--accent-text); border-radius: 999px; padding: 0 .45rem; font-size: .74rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem 1rem; margin-top: .8rem; }
.filter-grid .field label { font-size: .78rem; color: var(--muted); }
.filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; }
.result-count { font-variant-numeric: tabular-nums; }
.toolbar-buttons { display: flex; gap: .4rem; align-items: center; }

.table-wrap, .card.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th, .table td { text-align: left; padding: .75rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650;
  background: var(--surface-2); white-space: nowrap; padding-top: .7rem; padding-bottom: .7rem;
}
.table thead th:first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); }
.table thead th:last-child { border-top-right-radius: calc(var(--radius-lg) - 1px); }
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover, .table thead th a[aria-sort] { color: var(--accent-text); }
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 3.5%, var(--surface)); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn + .btn, .table td.actions form + form, .table td.actions .btn + form, .table td.actions form + .btn { margin-left: .3rem; }
.ticket-table .ticket-subject { font-weight: 600; color: var(--text); text-decoration: none; }
.ticket-table .ticket-subject:hover { color: var(--accent-text); }
.ticket-table tr[data-href] { cursor: pointer; }
.ticket-table td[data-label="Betreff"] { min-width: 240px; }
@media (min-width: 641px) {
  .ticket-table th:first-child, .ticket-table td:first-child { padding-left: 1.15rem; }
  /* Abzeichen-Spalten nur so breit wie nötig – der Platz geht an Betreff, Kunde und Zuständig */
  .ticket-table td[data-label="Status"], .ticket-table td[data-label="Priorität"],
  .ticket-table td[data-label="Fällig"], .ticket-table td[data-label="Letzte Aktivität"] { width: 1%; white-space: nowrap; }
  .ticket-table td[data-label="Kunde"], .ticket-table td[data-label="Anfragesteller"] { min-width: 140px; }
}
.ticket-table .sub { display: flex; align-items: center; flex-wrap: wrap; gap: .1rem .45rem; margin-top: .25rem; }
.ticket-table .sub .ticket-no { font-size: .72rem; padding: 0 .35rem; }
.ticket-table .cell-person { white-space: normal; font-size: .87rem; line-height: 1.3; }
.due-cell { display: inline-flex; flex-direction: column; align-items: flex-start; gap: .15rem; white-space: nowrap; }
.due-cell .sub { margin: 0; font-size: .76rem; }
.due-plain { flex-direction: row; align-items: center; gap: .35rem; color: var(--text-2); font-size: .86rem; }
.due-plain .icon { width: 15px; height: 15px; color: var(--muted); }
.cell-person { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.cell-person .avatar { width: 1.7rem; height: 1.7rem; font-size: .66rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: .75rem; margin: 1.25rem 0; font-size: .88rem; }

/* -------------------------------------------------------- Ticketdetail */
.ticket-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem 1.5rem; margin-bottom: 1.1rem; }
.ticket-title { min-width: 0; flex: 1 1 420px; }
.ticket-title h1 { margin: .45rem 0 .65rem; overflow-wrap: anywhere; font-size: 1.6rem; }
.ticket-no-line { margin: 0; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .86rem; }
.crumb { color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: .3rem; }
.crumb:hover { color: var(--text); text-decoration: none; }
.crumb .icon { width: 16px; height: 16px; }
.ticket-badges { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: 0; }
.ticket-meta { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .86rem; margin-left: .25rem; }
.ticket-meta .icon { width: 15px; height: 15px; }
.next-step {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), color-mix(in srgb, var(--accent-2) 6%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border)); border-radius: var(--radius);
  padding: .8rem 1.05rem; margin-bottom: 1.4rem;
}
.next-step p { margin: 0; display: flex; align-items: center; gap: .6rem; }
.next-step .icon { color: var(--accent-text); }
.next-step > p:first-child > .icon { flex: none; }
.next-links .icon { width: 15px; height: 15px; }
.next-links { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .87rem; }
.next-links a { font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.ticket-main { min-width: 0; }
.ticket-side { position: sticky; top: calc(var(--topbar-h) + 1rem); display: flex; flex-direction: column; }
.side-card { padding: 1.05rem 1.15rem; margin-bottom: 1rem; }
.side-card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin-bottom: .85rem; }
.side-sub { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 1rem 0 .5rem; font-weight: 650; }
.side-card .side-sub:first-of-type { margin-top: 0; }
.props { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; margin: 0; font-size: .89rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.props-wide { grid-template-columns: minmax(130px, max-content) 1fr; }
.people { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.people li { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; font-size: .9rem; }
.people .avatar { width: 1.8rem; height: 1.8rem; font-size: .66rem; }
.people .btn-link-danger { margin-left: auto; }
.add-member { display: flex; gap: .4rem; }
.add-member select { flex: 1; min-width: 0; min-height: 34px; padding-top: .35rem; padding-bottom: .35rem; font-size: .86rem; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; padding: .12rem .6rem;
  font-size: .8rem; font-weight: 500; color: var(--text-2); text-decoration: none;
}
.tag::before { content: "#"; color: var(--muted); }
.tag:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent-text); text-decoration: none; }

/* Zeitleiste */
.timeline { position: relative; list-style: none; margin: 0 0 1.5rem; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.timeline::before {
  content: ""; position: absolute; left: 19px; top: 8px; bottom: 8px; width: 2px;
  background: linear-gradient(180deg, var(--border), color-mix(in srgb, var(--border) 40%, transparent));
}
.msg { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: .9rem; scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.msg-avatar { width: 40px; height: 40px; font-size: .8rem; box-shadow: 0 0 0 4px var(--bg); position: relative; z-index: 1; }
.msg-bubble {
  min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: .95rem 1.15rem 1rem;
  transition: box-shadow .2s var(--ease);
}
.msg-support .msg-bubble {
  background: color-mix(in srgb, var(--accent) 3.5%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}
.msg-note .msg-bubble { background: var(--note-bg); border-color: var(--note-border); border-style: dashed; }
.msg-new .msg-bubble { box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 55%, transparent), var(--shadow-md); }
.msg:target .msg-bubble { box-shadow: 0 0 0 3px var(--ring), var(--shadow-md); }
.msg-new-label { display: inline-flex; align-items: center; gap: .35rem; color: var(--warn); font-weight: 650; font-size: .82rem; margin: 0 0 .5rem; }
.msg-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.msg-author { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: .15rem .5rem; align-items: center; font-size: .9rem; }
.msg-author .muted { font-size: .82rem; }
.msg-role {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .72rem; font-weight: 650; letter-spacing: .02em; padding: .1rem .5rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.msg-role .icon { width: 12px; height: 12px; }
.msg-support .msg-role { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.msg-role.role-note { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--note); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.msg-time { font-size: .8rem; color: var(--muted); text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg-time:hover { color: var(--text); }
.msg-body { overflow-wrap: anywhere; font-size: .93rem; line-height: 1.65; }
.msg-text { white-space: normal; }
.msg-text p:last-child { margin-bottom: 0; }
.msg-html { overflow-x: auto; max-width: 100%; }
:root[data-theme="dark"] .msg-html { background: #fff; color: #1f2937; border-radius: var(--radius-md); padding: .8rem 1rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-html { background: #fff; color: #1f2937; border-radius: var(--radius-md); padding: .8rem 1rem; } }
.msg-html img { max-width: 100%; height: auto; }
.msg-html table { border-collapse: collapse; max-width: 100%; }
.msg-html td, .msg-html th { border: 1px solid #e5e7eb; padding: .2rem .4rem; }
.msg-html blockquote { border-left: 3px solid #d1d5db; margin: .5rem 0; padding: .1rem .8rem; color: #4b5563; }
.msg-plain { margin-top: .6rem; font-size: .88rem; }
.msg-plain summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.img-blocked, .img-missing { display: inline-block; border: 1px dashed var(--border-strong); color: var(--muted); font-size: .78rem; padding: .15rem .5rem; border-radius: 6px; }

.event {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: .9rem; align-items: center;
  font-size: .84rem; color: var(--text-2); padding: .1rem 0;
}
.event-dot {
  justify-self: center; width: 10px; height: 10px; border-radius: 50%; position: relative; z-index: 1;
  background: var(--surface); border: 2px solid var(--border-strong); box-shadow: 0 0 0 4px var(--bg);
}
.event-text { min-width: 0; }
.event-text strong { color: var(--text); font-weight: 600; }
.event time { color: var(--muted); white-space: nowrap; font-size: .78rem; font-variant-numeric: tabular-nums; }

.attachments { list-style: none; margin: .9rem 0 0; padding: .8rem 0 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .6rem; }
.attachment {
  display: flex; flex-direction: column; gap: .2rem; max-width: 230px; font-size: .82rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: .5rem .65rem;
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.attachment:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.attachment-internal { background: var(--note-bg); border-color: var(--note-border); }
.attachment-name { font-weight: 600; overflow-wrap: anywhere; display: inline-flex; align-items: flex-start; gap: .35rem; }
.attachment-name .icon { width: 15px; height: 15px; margin-top: .1rem; color: var(--muted); }
.attachment-thumb img { display: block; max-height: 140px; width: auto; border-radius: 8px; border: 1px solid var(--border); background: #fff; margin-bottom: .2rem; }
.delivery { list-style: none; margin: .8rem 0 0; padding: .7rem 0 0; border-top: 1px dashed var(--border); font-size: .82rem; display: flex; flex-direction: column; gap: .4rem; color: var(--text-2); }
.delivery li { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; }
.delivery-error { flex-basis: 100%; color: var(--error); font-size: .8rem; }

/* Editor */
.editor { scroll-margin-top: calc(var(--topbar-h) + 1rem); padding: 1.2rem 1.35rem 1.35rem; }
.editor:focus { outline: none; }
.editor-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: 1rem; }
.editor-panel + .editor-panel { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.js .tabs-active .editor-panel + .editor-panel { margin-top: 0; padding-top: 0; border-top: 0; }
.js .tabs-active .editor-title { display: none; }
.panel-note { border-radius: var(--radius); }
.js .tabs-active .panel-note { background: var(--note-bg); border: 1px dashed var(--note-border); padding: 1rem; }
.tabs {
  display: inline-flex; gap: .25rem; padding: .25rem; margin: 0 0 1.1rem;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
}
.tabs button {
  display: inline-flex; align-items: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .88rem; background: none; border: 0; border-radius: 9px;
  padding: .5rem .95rem; color: var(--text-2); cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s;
}
.tabs button .icon { width: 16px; height: 16px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.tabs button.tab-note[aria-selected="true"] { color: var(--note); }
.recipients {
  display: flex; gap: .6rem; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: .65rem .85rem; font-size: .87rem;
}
.recipients > .icon { color: var(--muted); margin-top: .1rem; }
.recipients ul { margin: .25rem 0 0 1.1rem; padding: 0; }
.recipients p { margin: .2rem 0 0; }
.recipients-label { font-weight: 650; }
.canned-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.canned-form select { width: auto; min-width: 240px; min-height: 34px; padding-top: .35rem; padding-bottom: .35rem; font-size: .86rem; }
.canned-form label .icon { width: 15px; height: 15px; }
.canned-form label { margin: 0; font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; }

/* ------------------------------------------------------------------ Upload */
.upload { display: flex; flex-direction: column; gap: .5rem; }
.upload-label { display: inline-flex; align-items: center; gap: .4rem; }
.upload-label .icon { width: 16px; height: 16px; color: var(--muted); }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .5rem;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: .9rem 1rem;
  background: var(--surface-2); transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.js .dropzone { align-items: center; text-align: center; padding: 1.15rem 1rem; }
.dropzone-icon { display: none; }
.js .dropzone-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-text);
}
.dropzone:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px var(--ring); }
.dropzone input[type="file"] { font-size: .86rem; }
.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.upload-item {
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; font-size: .86rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: .45rem .65rem;
}
.upload-item .btn-link-danger { margin-left: auto; }
.upload-item.invalid { border-color: color-mix(in srgb, var(--red) 40%, var(--border)); background: color-mix(in srgb, var(--red) 6%, var(--surface)); }
.upload-item .upload-error { color: var(--error); font-size: .8rem; flex-basis: 100%; }
.upload-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.pending { padding: .6rem .85rem .8rem; }
.progress { position: relative; height: 1.5rem; background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-grad); transition: width .25s var(--ease); }
.progress-text { position: relative; display: block; text-align: center; font-size: .76rem; line-height: 1.5rem; font-weight: 650; color: var(--text); }

/* ------------------------------------------------------------- Diagnose */
.checks { list-style: none; margin: .5rem 0 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); gap: .05rem .55rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.checks li:first-child { border-top: 0; }
.check-icon {
  grid-row: span 2; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; border-radius: 50%; width: 1.5rem; height: 1.5rem; font-size: .75rem; margin-top: .05rem;
}
.check-ok .check-icon { background: color-mix(in srgb, var(--green) 15%, var(--tint-base)); color: var(--ok); }
.check-fail .check-icon { background: color-mix(in srgb, var(--red) 15%, var(--tint-base)); color: var(--error); }
.check-warn .check-icon { background: color-mix(in srgb, var(--amber) 18%, var(--tint-base)); color: var(--warn); }
.check-label { font-weight: 600; }
.check-detail { font-size: .84rem; }
.plain-list { margin: 0; padding-left: 1.15rem; display: flex; flex-direction: column; gap: .4rem; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; font-size: .88rem; }
.history time { color: var(--muted); margin-right: .35rem; font-variant-numeric: tabular-nums; }
.sub-action { margin-top: 1rem; }
.sub-action summary { cursor: pointer; font-weight: 600; color: var(--accent-text); }

/* ---------------------------------------------------------- Anmeldung */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 2.5rem 3rem; color: #e5e7f5;
  background:
    radial-gradient(800px 500px at 0% 0%, rgba(99, 102, 241, .55), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(168, 85, 247, .45), transparent 60%),
    radial-gradient(500px 400px at 80% 10%, rgba(14, 165, 233, .25), transparent 60%),
    #0b1020;
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0; opacity: .35; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M40 0H0v40' fill='none' stroke='rgba(255,255,255,0.07)'/%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}
.auth-hero > * { position: relative; }
.auth-hero .brand { padding: 0; font-size: 1.1rem; }
.auth-hero-copy { max-width: 520px; margin: 3rem 0; }
.auth-hero h2 { color: #fff; font-size: clamp(1.9rem, 3vw, 2.6rem); line-height: 1.12; letter-spacing: -.035em; font-weight: 750; margin-bottom: 1rem; }
.auth-hero h2 span { background: linear-gradient(90deg, #a5b4fc, #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { color: #b9bfd6; font-size: 1.02rem; line-height: 1.6; max-width: 460px; }
.auth-features { list-style: none; margin: 2rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.auth-features li { display: flex; align-items: center; gap: .8rem; color: #dfe3f3; font-weight: 500; }
.auth-features .icon {
  width: 34px; height: 34px; padding: 8px; border-radius: 10px; color: #c7d2fe;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .1);
}
.auth-hero-foot { font-size: .8rem; color: #8189a6; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.auth-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { display: none; color: var(--text); padding: 0 0 1.5rem; }
.auth-card .brand:hover { color: var(--text); }
.auth-brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.08rem; margin-bottom: 1.5rem; }
.auth-title { font-size: 1.7rem; letter-spacing: -.03em; margin-bottom: .35rem; }
.auth-lead { color: var(--muted); margin-bottom: 1.6rem; }
.auth-card form .btn-primary { min-height: 44px; font-size: .95rem; }
.auth-card input[type="email"], .auth-card input[type="password"], .auth-card input[type="text"] { min-height: 44px; }
.auth-links { margin-top: 1.1rem; font-size: .9rem; }
.auth-note { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; }

.install-main {
  min-height: 100vh; display: flex; justify-content: center; padding: 2.5rem 1rem;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(99, 102, 241, .35), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(168, 85, 247, .3), transparent 60%),
    #0b1020;
}
.install-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-xl);
  padding: 2rem 2.2rem 1.75rem; width: 100%; max-width: 860px; align-self: flex-start;
}
.install-card .auth-brand img { border-radius: 9px; }

.error-page { max-width: 560px; margin: 4rem auto; text-align: center; }
.error-code {
  font-size: 5.5rem; font-weight: 800; letter-spacing: -.06em; line-height: 1; margin: 0 0 .75rem;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-page .actions { margin-top: 1.5rem; }
.auth-card .error-page { margin: 0 auto; }

/* ------------------------------------------------------------- Responsiv */
@media (max-width: 1180px) {
  .ticket-layout { grid-template-columns: minmax(0, 1fr); }
  .ticket-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 1rem; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 0 1rem; gap: .65rem; }
  .brand-mobile { display: inline-flex; }
  .brand-mobile .brand-name { max-width: 34vw; }
  .topbar-search { max-width: none; }
  .topbar-new { display: inline-flex; }
  .mobile-nav { display: block; }
  .mobile-nav > summary { cursor: pointer; }
  .mobile-nav-panel {
    position: absolute; top: 100%; left: 0; right: 0; height: calc(100dvh - var(--topbar-h));
    overflow-y: auto; padding: 1rem .9rem 1.5rem;
    background: var(--nav-glow), var(--nav-bg); color: var(--nav-text);
    border-top: 1px solid var(--nav-border); box-shadow: var(--shadow-xl);
    animation: slide-down .22s var(--ease);
  }
  .mobile-nav-panel .nav li a.active::before { left: -.9rem; }
  .main { padding: 1.25rem 1rem 3rem; }
  .grid-2, .grid-wide-left { grid-template-columns: minmax(0, 1fr); }
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-card .brand { display: flex; }
}
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  body { font-size: 15px; }
  h1, .hello h1 { font-size: 1.4rem; }
  .ticket-title h1 { font-size: 1.3rem; }
  .topbar-search kbd { display: none !important; }
  .brand-mobile .brand-name { display: none; }
  .tabs button .icon { display: none; }
  .topbar-search input[type="search"] { padding-right: .75rem; }
  .card { padding: 1rem; border-radius: var(--radius); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .tile { padding: .85rem .9rem; }
  .tile-icon { width: 32px; height: 32px; border-radius: 10px; }
  .tile-icon .icon { width: 16px; height: 16px; }
  .tile-count { font-size: 1.6rem; }
  .tile-desc { display: none; }
  .page-actions { width: 100%; }
  .toolbar .field { min-width: 0; flex: 1 1 100%; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chips { display: flex; }
  /* Tabellen als Karten */
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: .75rem .9rem; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: .18rem 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .ticket-table td[data-label="Betreff"]::before { content: none; }
  .ticket-table td[data-label="Betreff"] { min-width: 0; }
  .due-cell { flex-direction: row; align-items: center; gap: .4rem; vertical-align: middle; }
  .ticket-table td[data-label="Betreff"] { padding-bottom: .4rem; }
  .table td.actions { text-align: left; white-space: normal; padding-top: .5rem; }
  .timeline::before { left: 15px; }
  .msg { grid-template-columns: 32px minmax(0, 1fr); gap: .6rem; }
  .msg-avatar { width: 32px; height: 32px; font-size: .68rem; }
  .event { grid-template-columns: 32px minmax(0, 1fr); gap: .6rem; }
  .event time { grid-column: 2; }
  .msg-bubble { padding: .8rem .85rem; }
  .ticket-side { grid-template-columns: minmax(0, 1fr); }
  .form-inline .field { min-width: 0; flex: 1 1 100%; }
  .props-wide { grid-template-columns: minmax(0, 1fr); }
  .props-wide dd { margin-bottom: .45rem; }
  .tabs { display: flex; }
  .tabs button { flex: 1; justify-content: center; padding: .5rem .5rem; }
  .install-card { padding: 1.4rem 1.1rem; border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .editor, .page-actions, .ticket-side form, .next-links, .skip-link { display: none !important; }
  .app { display: block; }
  .ticket-layout { display: block; }
  body { background: #fff; color: #000; }
  .card, .msg-bubble, .tile { box-shadow: none; }
  .timeline::before { display: none; }
}
