/* =========================================================================
   cryo-ticket – Designsystem
   Dunkles Interface mit Eis-Akzent. Keine externen Abhängigkeiten:
   Schriften kommen aus dem System, Icons sind CSS-Masken (data: URI).
   ========================================================================= */

:root {
    color-scheme: dark;

    /* Flächen */
    --bg:            #0d1116;
    --bg-elevated:   #141a21;
    --surface:       #171e26;
    --surface-2:     #1d262f;
    --surface-hover: #212c37;
    --line:          #253039;
    --line-soft:     #1c242c;

    /* Text */
    --text:      #e6edf3;
    --text-mute: #93a4b3;
    --text-dim:  #64758a;

    /* Akzent (Eis) */
    --accent:        #38bdf8;
    --accent-strong: #0ea5e9;
    --accent-soft:   rgba(56, 189, 248, .14);
    --accent-line:   rgba(56, 189, 248, .38);

    /* Semantik */
    --green:  #34d399;  --green-soft:  rgba(52, 211, 153, .14);
    --amber:  #fbbf24;  --amber-soft:  rgba(251, 191, 36, .14);
    --red:    #f87171;  --red-soft:    rgba(248, 113, 113, .14);
    --violet: #a78bfa;  --violet-soft: rgba(167, 139, 250, .14);
    --blue:   #60a5fa;  --blue-soft:   rgba(96, 165, 250, .14);
    --slate:  #94a3b8;  --slate-soft:  rgba(148, 163, 184, .13);

    --radius:    10px;
    --radius-sm: 7px;
    --radius-lg: 14px;
    --shadow:    0 10px 30px rgba(0, 0, 0, .45);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);

    --sidebar-w: 236px;
    --topbar-h:  58px;

    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* Das hidden-Attribut muss jede display-Regel schlagen. Ohne !important
   gewinnt z. B. ".modal-backdrop { display: flex }" gegen die Browserregel
   "[hidden] { display: none }" (gleiche Spezifitaet, spaetere Quelle) – das
   Modal laege dann dauerhaft ueber der Seite. Sichtbarkeit wird ausschliesslich
   ueber el.hidden geschaltet, nie ueber style.display. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p  { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3641; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #35424f; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------- Icons */

.ico {
    display: inline-block;
    width: 16px; height: 16px;
    flex: 0 0 auto;
    background-color: currentColor;
    -webkit-mask: var(--i) center / contain no-repeat;
            mask: var(--i) center / contain no-repeat;
}
.ico-grid    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E"); }
.ico-list    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E"); }
.ico-user    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.ico-users   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); }
.ico-building{ --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='2' width='16' height='20' rx='2'/%3E%3Cpath d='M9 22v-4h6v4'/%3E%3Cpath d='M8 6h.01M16 6h.01M8 10h.01M16 10h.01M8 14h.01M16 14h.01M12 6h.01M12 10h.01M12 14h.01'/%3E%3C/svg%3E"); }
.ico-cog     { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E"); }
.ico-dot     { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3C/svg%3E"); width: 10px; height: 10px; }
.ico-menu    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='3' y1='6' x2='21' y2='6'/%3E%3Cline x1='3' y1='12' x2='21' y2='12'/%3E%3Cline x1='3' y1='18' x2='21' y2='18'/%3E%3C/svg%3E"); }
.ico-logout  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E"); }
.ico-plus    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E"); }
.ico-search  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); }
.ico-back    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='19' y1='12' x2='5' y2='12'/%3E%3Cpolyline points='12 19 5 12 12 5'/%3E%3C/svg%3E"); }
.ico-clip    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48'/%3E%3C/svg%3E"); }
.ico-trash   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E"); }
.ico-edit    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'/%3E%3Cpath d='M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4z'/%3E%3C/svg%3E"); }
.ico-check   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.ico-chevron { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); width: 14px; height: 14px; }
.ico-shield  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
.ico-clock   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E"); }
.ico-inbox   { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E"); }
.ico-filter  { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3'/%3E%3C/svg%3E"); }
.ico-book    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/%3E%3C/svg%3E"); }
.ico-plug    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 2v6M15 2v6'/%3E%3Cpath d='M6 8h12v3a6 6 0 0 1-6 6 6 6 0 0 1-6-6z'/%3E%3Cpath d='M12 17v5'/%3E%3C/svg%3E"); }
.ico-mail    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpolyline points='2 6 12 13 22 6'/%3E%3C/svg%3E"); }
.ico-chat    { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8z'/%3E%3C/svg%3E"); }
.ico-download{ --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E"); }

/* --------------------------------------------------------------- Layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--bg-elevated);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    overflow-y: auto;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    font-size: 16px; font-weight: 700; letter-spacing: -.2px;
}
.brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: linear-gradient(140deg, var(--accent) 0%, #6366f1 100%);
    box-shadow: 0 0 14px rgba(56, 189, 248, .45);
}
.brand-name span { color: var(--accent); }

.nav { padding: 14px 10px 24px; }
.nav-label {
    font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
    color: var(--text-dim);
    padding: 0 10px; margin: 16px 0 6px;
}
.nav-label:first-child { margin-top: 0; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-mute);
    font-size: 13.5px; font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: inset 2px 0 0 var(--accent);
}
.nav-item .ico { opacity: .85; }

.shell {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    flex: 0 0 var(--topbar-h);
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    background: rgba(13, 17, 22, .82);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
/* Nur für Vorleseprogramme: sichtbar ist der Titel im Seiteninhalt. */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.lang-switch {
    display: flex; gap: 2px; padding: 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.lang-switch a {
    padding: 3px 8px; border-radius: 5px;
    font-size: 11px; font-weight: 700; letter-spacing: .04em;
    color: var(--text-dim);
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a.is-active { background: var(--accent-soft); color: var(--accent); }

.main { padding: 24px 26px 56px; flex: 1; min-width: 0; }

.burger { display: none; }
.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(0, 0, 0, .55);
}

/* -------------------------------------------------------------- Avatare */

.avatar {
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; letter-spacing: .02em;
    color: #06121b;
}
.avatar.sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 9.5px; }
.avatar.lg { width: 44px; height: 44px; flex-basis: 44px; font-size: 15px; }
.avatar.c0 { background: #38bdf8; } .avatar.c1 { background: #34d399; }
.avatar.c2 { background: #fbbf24; } .avatar.c3 { background: #f87171; }
.avatar.c4 { background: #a78bfa; } .avatar.c5 { background: #f472b6; }
.avatar.c6 { background: #4ade80; } .avatar.c7 { background: #fb923c; }

.avatar-btn {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 9px 4px 4px;
    background: transparent; border: 1px solid transparent; border-radius: 999px;
    color: var(--text); font: inherit; cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.avatar-btn:hover { background: var(--surface); border-color: var(--line); }
.avatar-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.avatar-name { font-size: 12.5px; font-weight: 600; }
.avatar-role { font-size: 10.5px; color: var(--text-dim); }

/* ------------------------------------------------------------ Dropdowns */

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
    min-width: 210px; padding: 5px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    max-height: 320px; overflow-y: auto;
}
.dropdown-menu.align-right { left: auto; right: 0; }
/* Am unteren Rand (Nachrichtenfeld) nach oben aufklappen, damit das Menue
   nicht aus dem sichtbaren Bereich faellt. */
.dropdown-menu.drop-up { top: auto; bottom: calc(100% + 8px); }
.dropdown-menu { overscroll-behavior: contain; }
.dropdown-menu form { margin: 0; }
.dropdown-item {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 8px 10px;
    background: none; border: 0; border-radius: var(--radius-sm);
    color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.is-active { background: var(--accent-soft); color: var(--accent); }
.dropdown-sep { height: 1px; margin: 5px 2px; background: var(--line); }
.dropdown-head {
    padding: 7px 10px 4px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim);
}
.dropdown-item .sub { display: block; font-size: 11px; color: var(--text-dim); }
/* Suchfeld in einem langen Auswahlmenue (Anfragender im Ticket).
   Das Menue scrollt bereits (max-height weiter oben); das Feld bleibt beim
   Scrollen oben stehen. */
.dropdown-search {
    position: sticky;
    top: -5px;
    z-index: 1;
    margin: -5px -5px 4px;
    padding: 6px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.dropdown-search .input { height: 30px; font-size: 12.5px; }
.dropdown-empty { margin: 0; padding: 10px 12px; font-size: 12px; color: var(--text-dim); }

/* --------------------------------------------------------------- Knöpfe */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text); font: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover  { background: var(--surface-hover); border-color: #2f3d49; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-strong); border-color: var(--accent-strong); color: #04121c; font-weight: 600;
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-mute); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-danger { background: var(--red-soft); border-color: rgba(248, 113, 113, .3); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, .22); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--text-mute); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* -------------------------------------------------------------- Formular */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label {
    display: block; margin-bottom: 5px;
    font-size: 12px; font-weight: 600; color: var(--text-mute);
}
.hint { margin-top: 5px; font-size: 11.5px; color: var(--text-dim); }
.req { color: var(--red); }

.input, .select, .textarea {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit; font-size: 13.5px;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: #2f3d49; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.6; }

.select {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a4b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 15px;
}
.select option { background: var(--surface); color: var(--text); }

.input.has-error, .select.has-error, .textarea.has-error {
    border-color: rgba(248, 113, 113, .55);
    box-shadow: 0 0 0 3px var(--red-soft);
}
.field-error { margin-top: 5px; font-size: 12px; color: var(--red); }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--accent-strong); cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Anleitungen und Konfigurationsschnipsel auf der Seite "Anbindungen". */
.code-block {
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--text-dim);
    overflow-x: auto;
    white-space: pre;
}
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 12.5px; line-height: 1.9; color: var(--text-mute); }
.steps li { margin-bottom: 2px; }
.steps strong { color: var(--text); }

/* ---------------------------------------------------------------- Karten */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    /* Kein overflow:hidden! Das schnitt aufgeklappte Dropdown-Menues ab, die
       ueber den Kartenrand hinausragen (Anfragender, Sichtbarkeit, Status
       beim Senden). Die Rundung uebernehmen stattdessen die Randelemente. */
}
.card > .table-wrap:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.card > .card-head:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card + .card { margin-top: 18px; }
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 13.5px; font-weight: 600; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* -------------------------------------------------------------- Kopfzeile */

.page-head {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h2 { font-size: 21px; font-weight: 650; letter-spacing: -.3px; }
.page-head .spacer { margin-left: auto; }
.page-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* --------------------------------------------------------------- Tabelle */

.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    position: sticky; top: 0; z-index: 5;
    padding: 9px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-dim); text-align: left; white-space: nowrap;
}
table.data th a { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
table.data th a:hover { color: var(--text); }
table.data th .sort-arrow { font-size: 9px; color: var(--accent); }
table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
table.data tbody tr { transition: background .1s ease; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data td.num { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
table.data td.right, table.data th.right { text-align: right; }
table.data td.nowrap { white-space: nowrap; }
.cell-strong { font-weight: 550; color: var(--text); }
.cell-mute   { color: var(--text-dim); font-size: 12px; }

.person { display: flex; align-items: center; gap: 8px; min-width: 0; }
.person-text { min-width: 0; }
.person-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub  { display: block; font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- Badges */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }

.badge-new         { background: var(--blue-soft);   color: var(--blue);   border-color: rgba(96, 165, 250, .28); }
.badge-open        { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-in_progress { background: var(--amber-soft);  color: var(--amber);  border-color: rgba(251, 191, 36, .28); }
.badge-waiting     { background: var(--violet-soft); color: var(--violet); border-color: rgba(167, 139, 250, .28); }
.badge-solved      { background: var(--green-soft);  color: var(--green);  border-color: rgba(52, 211, 153, .28); }
.badge-closed      { background: var(--slate-soft);  color: var(--slate);  border-color: rgba(148, 163, 184, .25); }

.badge-p1 { background: var(--slate-soft);  color: var(--slate);  border-color: rgba(148, 163, 184, .25); }
.badge-p2 { background: var(--blue-soft);   color: var(--blue);   border-color: rgba(96, 165, 250, .28); }
.badge-p3 { background: var(--amber-soft);  color: var(--amber);  border-color: rgba(251, 191, 36, .28); }
.badge-p4 { background: var(--red-soft);    color: var(--red);    border-color: rgba(248, 113, 113, .3); }

.badge-role-admin { background: var(--violet-soft); color: var(--violet); border-color: rgba(167, 139, 250, .28); }
.badge-role-agent { background: var(--slate-soft);  color: var(--slate);  border-color: rgba(148, 163, 184, .25); }
.badge-active     { background: var(--green-soft);  color: var(--green);  border-color: rgba(52, 211, 153, .28); }
.badge-inactive   { background: var(--slate-soft);  color: var(--text-dim); border-color: var(--line); }
.badge-overdue    { background: var(--red-soft);    color: var(--red);    border-color: rgba(248, 113, 113, .3); }

.tag {
    display: inline-block; padding: 1px 7px;
    border-radius: 5px; font-size: 10.5px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
    background: var(--amber-soft); color: var(--amber);
}

/* ------------------------------------------------------------ Meldungen */

.flash-stack { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid; font-size: 13px;
    animation: flash-in .22s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-5px); } }
.flash span { flex: 1; }
.flash-success { background: var(--green-soft); border-color: rgba(52, 211, 153, .3); color: var(--green); }
.flash-error   { background: var(--red-soft);   border-color: rgba(248, 113, 113, .3); color: var(--red); }
.flash-info    { background: var(--accent-soft);border-color: var(--accent-line);      color: var(--accent); }
.flash-close {
    background: none; border: 0; color: inherit; opacity: .6;
    font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.flash-close:hover { opacity: 1; }

.alert {
    padding: 11px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface-2);
    font-size: 13px; color: var(--text-mute);
}
.alert.warn { background: var(--amber-soft); border-color: rgba(251, 191, 36, .28); color: var(--amber); }

/* ------------------------------------------------------------ Leerzustand */

.empty {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 56px 20px; text-align: center; color: var(--text-dim);
}
.empty .ico { width: 32px; height: 32px; opacity: .35; margin-bottom: 4px; }
.empty h3 { font-size: 14px; color: var(--text-mute); font-weight: 600; }
.empty p { font-size: 12.5px; }

/* ------------------------------------------------------------- Dashboard */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px; margin-bottom: 18px;
}
.stat {
    display: block;
    padding: 16px 18px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
    position: relative; overflow: hidden;
    transition: border-color .14s ease, transform .14s ease;
}
a.stat:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.stat::after {
    content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
    background: var(--accent); opacity: .85;
}
.stat.g::after { background: var(--green); }
.stat.a::after { background: var(--amber); }
.stat.r::after { background: var(--red); }
.stat.v::after { background: var(--violet); }
.stat-label {
    font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-dim);
}
.stat-value { font-size: 30px; font-weight: 650; letter-spacing: -1px; line-height: 1.15; margin-top: 4px; }
.stat-foot { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* Zustand der Anbindungen auf der Übersicht: eine Reihe kleiner Kacheln,
   die nur erscheinen, wenn es etwas zu sagen gibt. */
.health { display: flex; flex-wrap: wrap; gap: 10px; }
.health-item {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 9px 14px 9px 12px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); text-decoration: none;
}
.health-item:hover { border-color: var(--text-dim); }
.health-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.health-item.is-ok    .health-dot { background: var(--green); }
.health-item.is-warn  .health-dot { background: var(--amber); }
.health-item.is-error .health-dot { background: var(--red); }
.health-text { display: flex; flex-direction: column; line-height: 1.35; }
.health-text .t { font-size: 12.5px; font-weight: 600; color: var(--text); }
.health-text .d { font-size: 11.5px; color: var(--text-dim); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.grid-2 .card + .card { margin-top: 0; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 40px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-name { color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .35s ease; min-width: 2px; }
.bar-fill.b-new { background: var(--blue); } .bar-fill.b-open { background: var(--accent); }
.bar-fill.b-in_progress { background: var(--amber); } .bar-fill.b-waiting { background: var(--violet); }
.bar-fill.b-solved { background: var(--green); } .bar-fill.b-closed { background: var(--slate); }
.bar-fill.b-src-web { background: var(--slate); }  .bar-fill.b-src-email { background: var(--blue); }
.bar-fill.b-src-discord { background: var(--violet); } .bar-fill.b-src-portal { background: var(--green); }
.bar-fill.b-p1 { background: var(--slate); } .bar-fill.b-p2 { background: var(--blue); }
.bar-fill.b-p3 { background: var(--amber); } .bar-fill.b-p4 { background: var(--red); }
.bar-value { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--text-mute); }

/* ------------------------------------------------------------ Filterleiste */

.filters {
    display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
    padding: 14px 16px; margin-bottom: 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filters .field { margin: 0; }
.filters .grow { flex: 1 1 220px; min-width: 180px; }
.filters .w-sm { width: 150px; }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search-box .input { padding-left: 32px; }

.pagination {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-top: 1px solid var(--line);
    font-size: 12.5px; color: var(--text-dim);
}
.pagination .spacer { margin-left: auto; }

/* ------------------------------------------------------ Ticket-Detailseite */

.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }

.thread {
    display: flex; flex-direction: column;
    max-height: calc(100vh - var(--topbar-h) - 190px);
    min-height: 340px;
}
.thread-scroll {
    flex: 1;
    min-height: 0;              /* ohne dies wachsen Flex-Kinder statt zu scrollen */
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    display: flex; flex-direction: column; gap: 12px;
}

/* Beitraege laufen ueber die volle Breite und sind linksbuendig – ein
   Ticketverlauf ist ein Protokoll, kein Chat. Die Rolle steckt im farbigen
   Balken links, nicht in der Ausrichtung. */
.msg {
    display: flex; gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--slate);
    border-radius: var(--radius-sm);
}
.msg-body { flex: 1; min-width: 0; }
.msg-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 5px; font-size: 12px;
}
.msg-author { font-weight: 600; }
/* Erreichbarkeit des Anfragenden neben dem Namen: Adresse oder Discord-Name. */
.msg-contact { font-size: 11.5px; color: var(--text-dim); }

/* Zitierte Vorgeschichte aus Mailantworten: standardmäßig eingeklappt. */
.quote-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 8px; padding: 3px 9px 3px 6px;
    background: none; border: 1px solid var(--line); border-radius: 999px;
    font: inherit; font-size: 11.5px; color: var(--text-dim); cursor: pointer;
}
.quote-toggle:hover { color: var(--text-mute); border-color: var(--text-dim); }
.quote-toggle .ico { width: 12px; height: 12px; transition: transform .15s ease; }
.quote-toggle.is-open .ico { transform: rotate(180deg); }
.msg-quoted {
    margin-top: 8px; padding-left: 11px;
    border-left: 2px solid var(--line);
    color: var(--text-dim); font-size: 12.5px;
}

/* Herkunft eines Tickets in der Liste – bewusst zurückhaltend, die Spalte
   gehört dem Namen des Anfragenden. */
.tag.src-web     { background: var(--slate-soft);  color: var(--slate);  }
.tag.src-email   { background: var(--blue-soft);   color: var(--blue);   }
.tag.src-discord { background: var(--violet-soft); color: var(--violet); }
.tag.src-portal  { background: var(--green-soft);  color: var(--green);  }
.person-name .tag { margin-left: 6px; vertical-align: 1px; }

/* ------------------------------------------------------ Wissensdatenbank */
.kb-list { display: flex; flex-direction: column; }
.kb-item {
    display: block; padding: 15px 18px;
    border-bottom: 1px solid var(--line-soft); text-decoration: none;
}
.kb-item:last-child { border-bottom: 0; }
.kb-item:hover { background: var(--surface-hover); }
.kb-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.kb-excerpt {
    display: block; margin-top: 3px;
    font-size: 12.5px; color: var(--text-mute);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-meta { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 11.5px; color: var(--text-dim); }
.kb-meta .tag { background: var(--accent-soft); color: var(--accent); }

/* Der Text ist reiner Text – Zeilenumbrüche bleiben, Markup gibt es nicht. */
.kb-body { font-size: 13.5px; line-height: 1.7; color: var(--text-mute); white-space: pre-wrap; word-break: break-word; }
.kb-editor { min-height: 340px; font-family: inherit; line-height: 1.7; }

/* -------------------------------------------------------------- Reiter */
/* Untergliederung einer Seite (Anbindungen: Mail / Discord). Die Auswahl
   ist ein Link, kein Skript – damit übersteht sie ein Formularabsenden. */
.tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 18px;
    padding-bottom: 0;
    border-bottom: 1px solid var(--line);
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    margin-bottom: -1px;
    border: 1px solid transparent;
    border-bottom-color: transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mute);
    text-decoration: none;
}
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab.is-active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
    border-bottom-color: var(--surface);
}
.tab .ico { width: 15px; height: 15px; }

/* -------------------------------------------------- Offene Tickets (Reiter) */
/* Mehrere Tickets gleichzeitig offen halten, ohne den Umweg über die Liste. */
/* Liegt in der Kopfzeile, direkt neben dem Suchfeld – damit die offenen
   Tickets von jeder Seite aus sichtbar und erreichbar bleiben. */
.ticket-tabs {
    display: flex; align-items: center; gap: 4px;
    /* Nimmt den Platz zwischen Menüknopf und rechter Gruppe ein. */
    flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: thin;
}
.ticket-tabs::-webkit-scrollbar { height: 4px; }
.ticket-tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.ticket-tab {
    display: inline-flex; align-items: center; flex: 0 0 auto;
    max-width: 190px; height: 30px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.ticket-tab a {
    display: inline-flex; align-items: center; gap: 6px;
    min-width: 0; padding: 0 3px 0 9px; height: 100%;
    font-size: 12px; color: var(--text-mute); text-decoration: none;
}
.ticket-tab a:hover { color: var(--text); }
.ticket-tab .num { font-weight: 600; }
.ticket-tab .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-tab .dot {
    flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%;
    /* Die Farbe je Status kommt aus dem Nonce-Block (Appearance). */
    background: var(--text-dim);
}
.ticket-tab button {
    padding: 0 7px 0 3px; height: 100%;
    background: none; border: 0;
    font: inherit; font-size: 14px; line-height: 1;
    color: var(--text-dim); cursor: pointer;
}
.ticket-tab button:hover { color: var(--red); }
.ticket-tab.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
}
.ticket-tab.is-active a { color: var(--text); }
/* Zeile unter den Filtern: die Ansicht als eigenen Filter sichern. */
.filter-save {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: -6px 0 16px;
    font-size: 12px;
}
.filter-save-form { display: flex; gap: 6px; }
.filter-save-form .input { height: 30px; width: 190px; font-size: 12.5px; }

.tabs-close-all {
    flex: 0 0 auto; padding: 0 8px; height: 30px;
    background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; cursor: pointer;
}
.tabs-close-all:hover { color: var(--text-mute); border-color: var(--line); }

@media (max-width: 820px) {
    .ticket-tab { max-width: 116px; }
    .ticket-tab .txt { display: none; }
    .tabs-close-all { display: none; }
}

/* Suchfeld in der Kopfleiste, fester Platz oben rechts vor der Sprachauswahl. */
.topbar-search { position: relative; flex: 0 0 auto; width: 250px; }
.topbar-search .ico {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; background: var(--text-dim); pointer-events: none;
}
.topbar-search .input { height: 34px; padding-left: 32px; font-size: 13px; }
@media (max-width: 900px) { .topbar-search { width: 170px; } }
@media (max-width: 700px) { .topbar-search { display: none; } }

/* ------------------------------------------------------- Kundenportal */
/* Bewusst schlichter als die Bearbeiteroberfläche: eine Kopfzeile, eine
   zentrierte Spalte, keine Seitenleiste. */
.portal-shell { display: flex; flex-direction: column; min-height: 100vh; }
.portal-head {
    display: flex; align-items: center; gap: 20px;
    padding: 0 22px; height: 60px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.portal-head .brand { font-size: 15px; }
.portal-head .spacer { margin-left: auto; }
.portal-nav { display: flex; gap: 4px; }
.portal-nav a {
    padding: 7px 12px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; color: var(--text-mute); text-decoration: none;
}
.portal-nav a:hover { background: var(--surface-hover); color: var(--text); }
.portal-nav a.is-active { background: var(--accent-soft); color: var(--accent); }
.portal-main { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 26px 22px 40px; }
.portal-foot {
    padding: 16px 22px; border-top: 1px solid var(--line);
    font-size: 11.5px; color: var(--text-dim); text-align: center;
}
.portal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }

@media (max-width: 860px) {
    .portal-layout { grid-template-columns: minmax(0, 1fr); }
    .portal-head { gap: 12px; padding: 0 14px; }
    .portal-nav a { padding: 7px 9px; }
    .portal-main { padding: 18px 14px 30px; }
}
.msg-time { color: var(--text-dim); font-size: 11px; margin-left: auto; padding-left: 10px; }
.msg-text {
    font-size: 13.5px; line-height: 1.65;
    text-align: left;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.msg-text.is-empty { color: var(--text-dim); font-style: italic; }

.msg.customer { border-left-color: var(--slate); }
.msg.agent    { border-left-color: var(--accent); }
.msg.internal { border-left-color: var(--amber); background: rgba(251, 191, 36, .05); }

.composer { border-top: 1px solid var(--line); padding: 14px 18px; background: var(--surface); }
.composer .textarea { min-height: 84px; margin-bottom: 10px; }
.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-bar .spacer { margin-left: auto; }
.file-pick {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 11px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
    color: var(--text-mute); font-size: 12.5px; cursor: pointer;
}
.file-pick:hover { border-color: var(--accent-line); color: var(--accent); }
.file-pick input { display: none; }
.file-name { font-size: 12px; color: var(--accent); }

.side-list { display: flex; flex-direction: column; }
.side-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
}
.side-row:last-child { border-bottom: 0; }
.side-label { font-size: 11.5px; color: var(--text-dim); width: 84px; flex: 0 0 84px; }
.side-value { flex: 1; min-width: 0; }
.side-value .btn { width: 100%; justify-content: space-between; min-width: 0; overflow: hidden; }
/* Lange Werte (z. B. E-Mail-Adressen) abschneiden, statt die Karte zu sprengen. */
.side-value .btn > [data-field-label],
.side-value .btn > .badge,
.side-value .btn > .badge > [data-field-label] {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attach-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.attach-item:last-child { border-bottom: 0; }
.attach-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-size { color: var(--text-dim); font-size: 11px; }

.timeline { padding: 6px 16px 14px; }
.tl-item {
    position: relative;
    padding: 8px 0 8px 20px;
    font-size: 12.5px; color: var(--text-mute);
    border-left: 1px solid var(--line);
}
.tl-item:last-child { border-left-color: transparent; }
.tl-item::before {
    content: ''; position: absolute; left: -4.5px; top: 14px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--surface-2); border: 2px solid var(--line);
}
.tl-item.is-latest::before { background: var(--accent); border-color: var(--accent); }
.tl-time { display: block; font-size: 11px; color: var(--text-dim); }
.tl-item b { color: var(--text); font-weight: 600; }

.subject-input {
    width: 100%; padding: 6px 10px; margin: -6px -10px;
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--text); font: inherit; font-size: 19px; font-weight: 600; letter-spacing: -.3px;
}
.subject-input:hover { border-color: var(--line); }
.subject-input:focus { outline: none; background: var(--bg); border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

/* -------------------------------------------------------------- Login */

.centered-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px;
    background:
        radial-gradient(1000px 520px at 50% -10%, rgba(56, 189, 248, .11), transparent 62%),
        radial-gradient(760px 420px at 88% 108%, rgba(99, 102, 241, .10), transparent 62%),
        var(--bg);
}
.login-card {
    width: 100%; max-width: 396px;
    padding: 34px 32px 30px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.login-brand {
    display: flex; align-items: center; gap: 11px; justify-content: center;
    margin-bottom: 22px; font-size: 19px; font-weight: 700; letter-spacing: -.3px;
}
.login-brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.login-brand span.ice { color: var(--accent); }
.login-card h1 { font-size: 19px; text-align: center; }
.login-card .sub { margin: 4px 0 22px; text-align: center; font-size: 13px; color: var(--text-dim); }
.login-card .btn { margin-top: 6px; }
.login-foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--text-dim); }
.login-lang { display: flex; justify-content: center; gap: 4px; margin-top: 14px; }
.login-lang a { padding: 3px 9px; border-radius: 5px; font-size: 11px; font-weight: 700; color: var(--text-dim); }
.login-lang a.is-active { background: var(--accent-soft); color: var(--accent); }

.error-card {
    max-width: 420px; padding: 40px 34px; text-align: center;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.error-code { font-size: 54px; font-weight: 700; letter-spacing: -2px; color: var(--accent); line-height: 1; }
.error-card h1 { margin: 8px 0 6px; font-size: 19px; }
.error-text { color: var(--text-mute); font-size: 13.5px; margin-bottom: 22px; }

/* ------------------------------------------------------------- Modale */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 90;
    display: flex; align-items: center; justify-content: center; padding: 24px;
    background: rgba(4, 8, 12, .68); backdrop-filter: blur(3px);
}
.modal {
    width: 100%; max-width: 520px; max-height: calc(100vh - 48px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
    animation: modal-in .16s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal-wide { max-width: 640px; }
.form-section {
    margin: 10px 0 2px;
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--text-dim);
    padding-bottom: 6px; border-bottom: 1px solid var(--line-soft);
}
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }

/* --------------------------------- Ersatz fuer blockierte style-Attribute */
/* Die Content-Security-Policy erlaubt kein style="..."; alles, was frueher
   dort stand, laeuft jetzt ueber diese Klassen bzw. ueber den per Nonce
   erlaubten <style>-Block im Kopf (siehe app/Style.php). */

.colw-56  { width: 56px; }
.colw-64  { width: 64px; }
.colw-90  { width: 90px; }
.colw-110 { width: 110px; }
.colw-120 { width: 120px; }
.colw-130 { width: 130px; }
.colw-150 { width: 150px; }
.colw-180 { width: 180px; }
.colw-190 { width: 190px; }
.colw-200 { width: 200px; }
.colw-220 { width: 220px; }

.inline-form { display: inline; }
.grow-1 { flex: 1; min-width: 0; }
.icon-btn.xs { width: 26px; height: 26px; }
.icon-btn.xs .ico { width: 13px; height: 13px; }
.check-align { height: 37px; }
.note-sm { font-size: 12.5px; }

/* Sicherheitsampel in den Systemeinstellungen */
.check-row { display: flex; align-items: flex-start; gap: 9px; }
.check-mark { min-width: 22px; justify-content: center; }
.check-text { flex: 1; }
.check-text .t { font-size: 13px; }
.check-text .h { display: block; }

/* Farbwaehler in den Darstellungseinstellungen */
.swatch {
    width: 22px; height: 22px; flex: 0 0 22px;
    border-radius: 6px; border: 1px solid var(--line);
}
.color-row {
    display: grid;
    grid-template-columns: 150px 1fr 132px;
    align-items: center; gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
}
.color-row:last-child { border-bottom: 0; }
.color-row .preview { display: flex; align-items: center; gap: 9px; }
.color-pick { display: flex; align-items: center; gap: 7px; }
.color-pick input[type="color"] {
    width: 34px; height: 30px; padding: 2px;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius-sm); cursor: pointer;
}
.color-pick input[type="text"] {
    width: 88px; font-family: var(--mono); font-size: 12px;
    text-transform: lowercase;
}

/* -------------------------------------------------------------- Utilities */

.muted { color: var(--text-dim); }
.mono  { font-family: var(--mono); font-size: 12px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 18px; } .mb-2 { margin-bottom: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.text-right { text-align: right; }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 1080px) {
    .ticket-layout { grid-template-columns: 1fr; }
    .thread { max-height: none; }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: none; }
    .shell { margin-left: 0; }
    .burger { display: inline-flex; }
    .main { padding: 18px 15px 44px; }
    .topbar { padding: 0 14px; }
    .avatar-meta { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .msg { max-width: 96%; }
    .bar-row { grid-template-columns: 92px 1fr 34px; }
}

@media (min-width: 861px) {
    .sidebar-backdrop { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
