:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #dde3e9;
    --text: #1d2733;
    --muted: #6b7885;
    --accent: #14568c;
    --accent-soft: #e8f0f8;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --warn: #8a5a00;
    --warn-soft: #fff4e0;
    --ok: #1c6b3c;
    --ok-soft: #e6f4ea;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

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

/* --- Navigation --- */
.sidebar {
    width: 232px; flex: 0 0 232px;
    background: #10243a; color: #cfdcea;
    display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar__brand { font-size: 18px; font-weight: 700; color: #fff; padding: 4px 10px 20px; }
.sidebar__brand span { color: #6ea8dc; }
.sidebar__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar__item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 6px;
    color: #cfdcea; text-decoration: none; font-size: 14.5px;
}
.sidebar__item:hover { background: rgba(255, 255, 255, .07); }
.sidebar__item.is-active { background: #1d6fb8; color: #fff; }
.sidebar__item.is-disabled { color: #6b7f95; cursor: not-allowed; }
.sidebar__item.is-disabled:hover { background: none; }
.sidebar__hint {
    margin-left: auto; font-size: 10.5px; font-style: normal;
    text-transform: uppercase; letter-spacing: .04em;
    background: rgba(255, 255, 255, .08); padding: 2px 6px; border-radius: 4px;
}
.icon { width: 18px; height: 18px; flex: 0 0 18px; }

/* --- Rahmen --- */
.app__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 14px 24px;
}
.topbar__title { margin: 0; font-size: 19px; font-weight: 650; }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar__name { color: var(--muted); font-size: 14px; }
.topbar__logout { margin: 0; }
.content { padding: 22px 24px 48px; max-width: 1240px; }

/* --- Bausteine --- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.card__title { margin: 0 0 14px; font-size: 15px; font-weight: 650; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; border: 1px solid transparent;
    background: var(--accent); color: #fff; font: inherit; font-size: 14px;
    cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost { background: none; color: var(--muted); border-color: var(--border); }
.btn--danger { background: var(--danger); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tbody tr:hover { background: #fafbfc; }
.table a { color: var(--accent); text-decoration: none; font-weight: 550; }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge--neutral { background: #eef1f4; color: #4a5867; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: #46535f; }
.field input, .field select, .field textarea {
    font: inherit; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: 6px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 12.5px; }
.field__hint { color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { margin: 0; }

.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.flash--erfolg { background: var(--ok-soft); color: var(--ok); }
.flash--fehler { background: var(--danger-soft); color: var(--danger); }
.flash--hinweis { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 8px; }

.due--overdue { color: var(--danger); font-weight: 600; }
.due--today { color: var(--warn); font-weight: 600; }
.due--soon { color: var(--warn); }
.due--none { color: var(--muted); }

.meta { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; font-size: 14px; }

/* --- Login --- */
.login { display: grid; place-items: center; min-height: 100vh; }
.login__card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 36px 34px; width: 360px; text-align: center;
}
.login__card h1 { margin: 0 0 6px; font-size: 22px; }
.login__card p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* --- Firmen-Autocomplete --- */
.autocomplete { position: relative; }
.autocomplete__list {
    position: absolute; z-index: 20; top: 100%; left: 0; right: 0;
    margin: 2px 0 0; padding: 4px; list-style: none;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 6px; box-shadow: 0 6px 18px rgba(16, 36, 58, .12);
    max-height: 240px; overflow-y: auto;
}
.autocomplete__list li { padding: 7px 9px; border-radius: 4px; cursor: pointer; font-size: 14px; }
.autocomplete__list li:hover { background: var(--accent-soft); }

/* --- Ticket-Detail --- */
.ticket-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ticket-head__number { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.ticket-head__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ticket-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 980px) { .ticket-columns { grid-template-columns: 1fr; } }

.inline-form { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
.inline-form .field { margin: 0; }

/* --- Verlauf --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { border-left: 2px solid var(--border); padding: 0 0 18px 16px; position: relative; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
    content: ''; position: absolute; left: -6px; top: 4px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--surface);
}
.timeline > li.is-system::before { background: var(--border); }
.timeline__head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; }
.timeline__when { color: var(--muted); }
.timeline__note { margin: 6px 0 0; font-size: 14.5px; }
.timeline__note p:first-child { margin-top: 0; }
.timeline__note p:last-child { margin-bottom: 0; }
.timeline > li.is-system .timeline__note { color: var(--muted); font-size: 13.5px; }

/* --- Kontingent --- */
.quota__bar { height: 8px; border-radius: 999px; background: #e9edf1; overflow: hidden; margin: 10px 0 6px; }
.quota__fill { height: 100%; background: var(--ok); }
.quota__fill.is-warning { background: var(--warn); }
.quota__fill.is-over { background: var(--danger); }
.quota__numbers { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* --- WYSIWYG --- */
.editor { border: 1px solid var(--border); border-radius: 6px; background: #fff; overflow: hidden; }
.editor__toolbar { display: flex; gap: 2px; padding: 5px; border-bottom: 1px solid var(--border); background: #fafbfc; }
.editor__toolbar button {
    border: 1px solid transparent; background: none; cursor: pointer;
    padding: 4px 9px; border-radius: 4px; font: inherit; font-size: 14px; color: #46535f;
}
.editor__toolbar button:hover { background: var(--accent-soft); border-color: var(--border); }
.editor__area { min-height: 110px; padding: 10px 12px; outline: none; font-size: 14.5px; }
.editor__area:empty::before { content: attr(data-placeholder); color: var(--muted); }

/* --- Eingang-Tabs --- */
.tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs__item {
    padding: 9px 14px; text-decoration: none; color: var(--muted);
    font-size: 14.5px; font-weight: 550; border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Dashboard-KPIs --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; text-decoration: none; color: inherit;
    display: flex; flex-direction: column; gap: 2px;
}
.kpi:hover { border-color: var(--accent); }
.kpi__value { font-size: 26px; font-weight: 650; line-height: 1.1; }
.kpi__label { font-size: 13px; color: var(--muted); }
