* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    min-height: 100vh;
    color: #0f172a;
}

a {
    color: var(--brand-secondary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1720px, 96%);
    margin: 0 auto;
}

.topbar {
    background: var(--brand-primary);
    color: #fff;
    border-bottom: 4px solid var(--brand-secondary);
    /* FEAT-036: Header bleibt beim Scrollen oben sichtbar. z-index über
       Inhalt/Dropdowns (Spalten-Picker z-index:50). */
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-weight: 700;
}

.brand img {
    height: 38px;
    width: auto;
    display: block;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: #fff;
    font-weight: 600;
}

/* FEAT-036: Brand+Burger-Balken. Desktop: display:contents -> der Wrapper
   verschwindet, Brand bleibt direktes Flex-Kind der Topbar (Layout unverändert,
   Brand links / Nav rechts). Mobil (siehe Media-Query): eigener Flex-Balken. */
.topbar-bar {
    display: contents;
}

/* FEAT-035: Mobile-Navigation (Hamburger). Desktop: Toggle ausgeblendet,
   Nav wie bisher inline. Überschreibt die globale `button`-Optik (transparent
   statt Brand-Hintergrund) per höherer Klassen-Spezifität. */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.nav-toggle-bar {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

@media (max-width: 900px) {
    .topbar-inner {
        flex-wrap: wrap;
        min-height: 64px;
    }
    /* FEAT-036: Brand + Burger als eigener Balken auf einer Ebene. Eigener
       nowrap-Flex-Kontext -> der Burger bleibt rechts auf Zeile 1, egal wie
       viel Platz; nur ein sehr langer Titel bricht INNERHALB der Brand um. */
    .topbar-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 1rem;
        flex-basis: 100%;
        width: 100%;
    }
    .brand {
        min-width: 0; /* langer Titel bricht intern um, statt den Burger zu verdrängen */
    }
    .nav-toggle {
        display: inline-flex;
        flex-shrink: 0;
    }
    .nav-collapsible {
        display: none;
        flex-basis: 100%;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.25rem 0 0.6rem;
    }
    .nav-collapsible.is-open {
        display: flex;
        /* Sticky-Header: lange Admin-Nav scrollt in sich statt den Viewport zu sprengen. */
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }
    .nav-collapsible > form {
        width: 100%;
        margin: 0;
    }
    .nav-collapsible > a,
    .nav-collapsible .link-button {
        display: block;
        width: 100%;
        text-align: left;
        padding: 0.7rem 0.25rem;
        min-height: 44px;
        border-top: 1px solid rgba(255, 255, 255, 0.14);
    }
}

.link-button {
    border: 0;
    background: transparent;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    min-height: auto;
}

.page-content {
    padding: 2rem 0 3rem;
}

.card {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.card + .card {
    margin-top: 1rem;
}

/* FEAT-034: In Grid-Layouts übernimmt `gap` den Abstand zwischen Karten.
   Ohne diese Regel würde die globale `.card + .card`-Marge die zweite Karte
   im Grid zusätzlich 1rem nach unten schieben (Profil: Benachrichtigungsbox,
   Auswertungen: „Tickets je Bearbeiter" lagen tiefer als die erste Karte). */
.grid > .card + .card {
    margin-top: 0;
}

h1, h2, h3 {
    margin-top: 0;
}

/* FEAT-034: Lange, unbrechbare Zeichenketten (zusammengesetzte Titel wie
   „Treppenhausbeleuchtung", E-Mail-Adressen) sollen umbrechen, statt mobil
   aus dem Viewport zu ragen / horizontalen Overflow zu erzwingen.
   FEAT-036: `td` bewusst NICHT mehr per `word-break` brechen — das reduziert
   die min-content-Breite und quetscht Auto-Layout-Tabellen (Ticketnr./Titel
   brachen mittwort um). Tabellen scrollen mobil ohnehin via `overflow-x`
   (FEAT-024). `.badge` nur `overflow-wrap` (kein hartes Mittwort-Brechen). */
h1, h2, h3, h4, p {
    overflow-wrap: break-word;
    word-break: break-word;
}
.badge {
    overflow-wrap: break-word;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.92rem;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.62rem 0.95rem;
    min-height: 44px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    background: var(--brand-secondary);
    color: #fff;
}

.button-secondary {
    background: #475569;
}

.button-danger {
    background: #b91c1c;
}

.button-muted {
    background: #e2e8f0;
    color: #0f172a;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.alert {
    margin-bottom: 1rem;
    padding: 0.8rem 0.9rem;
    border-radius: 8px;
    border: 1px solid;
}

.alert.success {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.alert.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.alert ul {
    margin: 0;
    padding-left: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 0.88rem;
    color: #334155;
}

.table-sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    text-decoration: none;
}

.table-sort-link:hover {
    text-decoration: none;
    color: var(--brand-primary);
}

.table-sort-link.is-active {
    color: var(--brand-primary);
}

.table-sort-icon {
    font-size: 0.72rem;
    color: #64748b;
}

.badge {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #e2e8f0;
}

.badge-priority-high,
.badge-priority-urgent {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-priority-medium {
    background: #fef3c7;
    color: #92400e;
}

.badge-priority-low {
    background: #dcfce7;
    color: #166534;
}

.badge-status-new {
    background: #e2e8f0;
    color: #1e293b;
}

.badge-status-in_progress {
    background: #dbeafe;
    color: #1e3a8a;
}

.badge-status-to_approval {
    background: #fef9c3;
    color: #854d0e;
}

.badge-status-done {
    background: #dcfce7;
    color: #166534;
}

/* FEAT-026: Kategorie-Marker (Icon + Farbe aus den Stammdaten). */
.category-badge {
    --cat-color: #64748b;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.16rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.2;
    color: #334155;
    /* Statischer Fallback für Browser ohne color-mix() (Cascade nutzt dann diese Werte). */
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    background: color-mix(in srgb, var(--cat-color) 12%, #fff);
    border: 1px solid color-mix(in srgb, var(--cat-color) 35%, #fff);
}

.category-badge-icon {
    display: inline-flex;
    color: var(--cat-color);
}

.category-badge-icon svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

.category-badge-label {
    white-space: nowrap;
}

/* FEAT-031: Kategorie-Editor (Karte) + visuelle Icon-/Farb-Picker. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.category-editor.is-inactive {
    opacity: 0.65;
}

.category-editor-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.category-editor-head .drag-handle {
    cursor: grab;
    color: #94a3b8;
    user-select: none;
    font-size: 1.1rem;
    line-height: 1;
}

.category-editor-head .category-preview {
    display: inline-flex;
}

.category-editor-status {
    margin-left: auto;
}

.category-field {
    margin-bottom: 0.7rem;
}

.category-field > label,
.category-field .field-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #334155;
}

.category-actions {
    margin-top: 0.2rem;
}

.icon-picker,
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.icon-option,
.color-option {
    cursor: pointer;
    display: inline-flex;
}

/* Radios visuell verstecken, Auswahl ueber das Label/Tile sichtbar machen. */
.icon-option input,
.color-option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.icon-option-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid #dbe2ea;
    border-radius: 9px;
    background: #fff;
    color: #475569;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}

.icon-option-tile svg {
    width: 1.3rem;
    height: 1.3rem;
    display: block;
}

.icon-option-none {
    color: #94a3b8;
    font-size: 1.2rem;
}

.icon-option:hover .icon-option-tile {
    border-color: #94a3b8;
}

.icon-option input:checked + .icon-option-tile {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 35%, transparent);
    color: #0f172a;
}

.icon-option input:focus-visible + .icon-option-tile {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    border: 1px solid rgba(15, 23, 42, 0.15);
    transition: box-shadow 0.12s ease, transform 0.12s ease;
}

.swatch-none {
    background: #fff;
    color: #94a3b8;
    font-size: 1.1rem;
}

.color-option:hover .swatch {
    transform: scale(1.08);
}

.color-option input:checked + .swatch {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0f172a;
}

.color-option input:focus-visible + .swatch {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.ticket-status-counters {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0.8rem 0 0.6rem;
}

.ticket-status-counter {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
    padding: 0.35rem 0.7rem;
    border-radius: 0.5rem;
    background: #f1f5f9;
    font-size: 0.85rem;
}

.ticket-status-counter strong {
    font-size: 1rem;
    font-weight: 700;
}

a.ticket-status-counter {
    text-decoration: none;
    color: inherit;
    transition: background 120ms ease;
}

a.ticket-status-counter:hover {
    background: #e2e8f0;
}

a.ticket-status-counter.is-active {
    background: #0f172a;
    color: #f8fafc;
}

a.ticket-status-counter.is-active strong {
    color: #f8fafc !important;
}

.ticket-status-counter.is-new strong { color: #1e293b; }
.ticket-status-counter.is-in_progress strong { color: #1e3a8a; }
.ticket-status-counter.is-to_approval strong { color: #854d0e; }
.ticket-status-counter.is-done strong { color: #166534; }

/* FEAT-018: Anhang-Dropzone + Live-Vorschau */
.attachment-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.8rem;
    background: #f8fafc;
    transition: border-color 120ms ease, background 120ms ease;
}
.attachment-dropzone.is-dragover {
    border-color: #0f172a;
    background: #e0f2fe;
}
.attachment-dropzone-hint {
    margin: 0.4rem 0 0;
    color: #475569;
}
.attachment-previews {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.attachment-preview-item {
    position: relative;
    display: inline-flex;
}
.attachment-preview-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 0.4rem;
    border: 1px solid #e2e8f0;
}
.attachment-preview-file {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 1.8rem 0.35rem 0.6rem;
    background: #e2e8f0;
    border-radius: 999px;
    font-size: 0.78rem;
}
/* FEAT-021: Entfernen-Button pro Preview-Item */
/* Achtung: Die globale `button, .button`-Regel oben setzt min-height: 44px,
   padding: 0.62rem 0.95rem und font-weight: 700. Diese drei Werte muessen
   hier explizit zurueckgesetzt werden, sonst wird der Button vertikal oval. */
.attachment-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    min-height: 24px;
    max-height: 24px;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    background: #ffffff;
    color: #0f172a;
    font-size: 16px;
    font-weight: normal;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}
.attachment-preview-remove:hover,
.attachment-preview-remove:focus {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
    outline: none;
}
@media (pointer: coarse) {
    .attachment-preview-remove {
        width: 32px;
        height: 32px;
        min-width: 32px;
        max-width: 32px;
        min-height: 32px;
        max-height: 32px;
        top: -8px;
        right: -8px;
        font-size: 18px;
    }
}

/* FEAT-022: Spalten-Picker in der Ticket-Übersicht */
.column-picker {
    position: relative;
}
.column-picker > summary {
    list-style: none;
    cursor: pointer;
}
.column-picker > summary::-webkit-details-marker {
    display: none;
}
.column-picker-menu {
    position: absolute;
    top: calc(100% + 0.3rem);
    right: 0;
    z-index: 50;
    min-width: 220px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 0.6rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
}
.column-picker-menu label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.3rem 0.2rem;
    font-weight: normal;
    cursor: pointer;
    user-select: none;
}
.column-picker-menu label:hover {
    background: #f1f5f9;
    border-radius: 0.3rem;
}
.column-picker-menu input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.column-picker-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}
.column-picker-actions button {
    font-size: 0.78rem;
}

/* FEAT-016: Aktionen-Spalte sticky-right für Ticket-Übersicht */
table th.sticky-right,
table td.sticky-right {
    position: sticky;
    right: 0;
    background: #ffffff;
    box-shadow: -6px 0 6px -6px rgba(15, 23, 42, 0.15);
    z-index: 2;
}
table thead th.sticky-right {
    background: #f8fafc;
    z-index: 3;
}

.kanban {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    min-width: 1500px;
}

.kanban-scroll {
    overflow-x: auto;
    padding-bottom: 0.25rem;
    /* FEAT-024: Abstand zum Header, damit "Zur Ticketliste" auf Mobile nicht
       direkt auf den Kanban-Spalten klebt, wenn der Header-Flex umbricht. */
    margin-top: 1rem;
}

.kanban-column {
    border: 1px solid #d6dee7;
    border-radius: 12px;
    min-height: 420px;
    padding: 0.75rem;
}

.kanban-column h3 {
    margin: 0 0 0.75rem;
    font-size: 0.98rem;
}

.kanban-column[data-status="new"] {
    background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
    border-color: #bfdbfe;
}

.kanban-column[data-status="triage"] {
    background: linear-gradient(180deg, #fff7ed 0%, #fffbf5 100%);
    border-color: #fed7aa;
}

.kanban-column[data-status="in_progress"] {
    background: linear-gradient(180deg, #f0fdf4 0%, #f8fff9 100%);
    border-color: #bbf7d0;
}

.kanban-column[data-status="waiting_customer"] {
    background: linear-gradient(180deg, #fff7ed 0%, #fffaf0 100%);
    border-color: #fdba74;
}

.kanban-column[data-status="done"] {
    background: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
    border-color: #cbd5e1;
}

.kanban-list {
    min-height: 320px;
    display: grid;
    gap: 0.6rem;
}

.ticket-card {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-left: 4px solid #94a3b8;
    border-radius: 10px;
    padding: 0.6rem;
    cursor: grab;
}

.kanban-column[data-status="new"] .ticket-card {
    border-left-color: #3b82f6;
}

.kanban-column[data-status="triage"] .ticket-card {
    border-left-color: #f59e0b;
}

.kanban-column[data-status="in_progress"] .ticket-card {
    border-left-color: #10b981;
}

.kanban-column[data-status="waiting_customer"] .ticket-card {
    border-left-color: #f97316;
}

.kanban-column[data-status="done"] .ticket-card {
    border-left-color: #64748b;
}

.ticket-card.dragging {
    opacity: 0.45;
}

.ticket-card p {
    margin: 0.4rem 0;
    font-size: 0.9rem;
    color: #334155;
}

/* FEAT-028: Kanban-Karten-Redesign — Objektkürzel prominent, Ticket-Nr. dezent. */
.ticket-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ticket-card-object {
    /* Dominante Überschrift: das Objekt-/Projektkürzel (AC-1). */
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.25;
    color: #0f172a;
    min-width: 0;
    word-break: break-word;
}

.ticket-card-id {
    /* FEAT-033: Ticket-Nummer dezent unten rechts in der Aktionszeile.
       margin-left:auto schiebt sie rechtsbündig ans Kartenende; klein/
       gedämpft (AC-2 aus FEAT-028) und bricht nicht um. */
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #94a3b8;
    white-space: nowrap;
}

.ticket-card p.ticket-card-title {
    /* Titel sitzt direkt unter der Objekt-Überschrift; etwas enger als Default. */
    margin: 0.3rem 0 0;
}

.ticket-card-markers {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.45rem;
}

.ticket-card-meta {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    align-items: baseline;
    margin-top: 0.5rem;
}

.ticket-card-age {
    color: #94a3b8;
}

.ticket-card-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.55rem;
}

/* Quelle-Badge: neutrales Blau, klar vom Prioritäts-Badge unterscheidbar (AC-4). */
.badge-source {
    background: #e0f2fe;
    color: #075985;
}

.small {
    font-size: 0.84rem;
    color: #475569;
}

.stats {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.stat {
    border-left: 4px solid var(--brand-secondary);
    padding: 0.8rem;
    background: #fff;
    border-radius: 8px;
}

.stat strong {
    display: block;
    font-size: 1.5rem;
}

.time-report-filters {
    align-items: end;
}

.time-report-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.time-report-chart {
    display: grid;
    gap: 0.85rem;
}

.time-report-bar-card {
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    padding: 0.9rem;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(241, 245, 249, 0.9) 100%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 36%);
}

.time-report-bar-top {
    display: flex;
    justify-content: space-between;
    gap: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
}

.time-report-bar-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.time-report-bar-track {
    margin-top: 0.7rem;
    height: 14px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
}

.time-report-bar-fill {
    height: 100%;
    min-width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
}

.time-distribution-wrap {
    overflow-x: auto;
    padding-bottom: 0.35rem;
}

.time-distribution-chart {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid #dbe2ea;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(241, 245, 249, 0.9) 0%, rgba(255, 255, 255, 0.96) 100%),
        radial-gradient(circle at top right, rgba(15, 23, 42, 0.06), transparent 24%);
}

.time-distribution-scale {
    height: 320px;
    padding-top: 1.35rem;
    padding-bottom: 2.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
}

.time-distribution-scale-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: #64748b;
    transform: translateY(50%);
}

.time-distribution-plot-scroll {
    overflow-x: auto;
    overflow-y: hidden;
}

.time-distribution-plot {
    min-width: max-content;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(36px, 42px);
    gap: 0.65rem;
    align-items: end;
    height: 320px;
}

.time-distribution-column {
    display: grid;
    grid-template-rows: minmax(1.1rem, auto) 240px 2.2rem;
    gap: 0.45rem;
    align-items: end;
}

.time-distribution-column-value {
    min-height: 1.1rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    color: #0f172a;
}

.time-distribution-column-area {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 240px;
    border-bottom: 2px solid rgba(100, 116, 139, 0.26);
    background-image: repeating-linear-gradient(
        to top,
        rgba(148, 163, 184, 0.24) 0,
        rgba(148, 163, 184, 0.24) 1px,
        transparent 1px,
        transparent 25%
    );
    background-size: 100% 25%;
    background-position: bottom;
}

.time-distribution-column-bar {
    width: 18px;
    min-height: 0;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #9fd45f 0%, #77b83a 100%);
    box-shadow: 0 10px 18px rgba(119, 184, 58, 0.22);
}

.time-distribution-column-label {
    min-height: 2.2rem;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    color: #334155;
    white-space: nowrap;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    justify-self: center;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.project-summary-toggle {
    cursor: pointer;
    font-weight: 700;
    list-style: none;
}

.project-summary-toggle::-webkit-details-marker {
    display: none;
}

.project-list-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.project-filters {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    width: min(520px, 100%);
}

.project-list {
    display: grid;
    gap: 0.75rem;
}

.project-item {
    border: 1px solid #dbe2ea;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
}

.project-item[open] {
    border-color: #bcd0e2;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.project-item-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 0.85rem;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.project-item-summary::-webkit-details-marker {
    display: none;
}

.project-item-title {
    display: inline-flex;
    align-items: baseline;
    gap: 0.45rem;
}

.project-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.project-item-body {
    padding: 0 0.85rem 0.85rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.2rem;
}

.project-status-badge {
    color: #0f172a;
}

.project-status-active {
    background: #dcfce7;
    color: #166534;
}

.project-status-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.file-list {
    margin: 0;
    padding-left: 1rem;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.8rem;
    max-height: 560px;
    overflow-y: auto;
    background: linear-gradient(180deg, #f2efe9 0%, #ece8df 100%);
    background-image:
        radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.35), transparent 32%),
        radial-gradient(circle at 78% 76%, rgba(255, 255, 255, 0.2), transparent 28%);
}

.chat-panel {
    border: 1px solid #d8d5cf;
    border-radius: 12px;
    overflow: hidden;
    background: #f0f2f5;
}

.chat-message-row {
    display: flex;
    width: 100%;
}

.chat-message-row.is-own {
    justify-content: flex-end;
}

.chat-message-row.is-other {
    justify-content: flex-start;
}

.chat-message-bubble {
    position: relative;
    max-width: min(78%, 700px);
    background: #ffffff;
    border-radius: 8px;
    padding: 0.48rem 0.62rem 0.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.06);
}

.chat-message-row.is-own .chat-message-bubble {
    background: #dcf8c6;
    border-color: #bde9a2;
}

.chat-message-row.is-other .chat-message-bubble::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 10px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #ffffff;
}

.chat-message-row.is-own .chat-message-bubble::after {
    content: "";
    position: absolute;
    right: -7px;
    top: 10px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #dcf8c6;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    font-size: 0.76rem;
    color: #64748b;
}

.chat-author {
    color: #0f172a;
    font-size: 0.79rem;
}

.chat-time {
    white-space: nowrap;
    margin-left: auto;
    font-size: 0.72rem;
    color: #64748b;
}

.chat-body {
    margin: 0.3rem 0 0;
    white-space: pre-line;
    font-size: 0.92rem;
    line-height: 1.45;
}

.chat-attachments {
    margin-top: 0.45rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.chat-thumb {
    width: 156px;
    height: 112px;
    object-fit: cover;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    display: block;
    background: #fff;
}

.chat-file-link {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 0.33rem 0.5rem;
    background: #fff;
    font-size: 0.83rem;
}

.chat-composer {
    border-top: 1px solid #d7dce2;
    background: #f0f2f5;
    padding: 0.7rem;
}

.chat-composer-label {
    margin-bottom: 0.4rem;
    color: #334155;
}

.chat-composer-input {
    border-radius: 9px;
    background: #fff;
    min-height: 90px;
}

.chat-composer-footer {
    margin-top: 0.55rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.chat-file-input-wrap {
    min-width: 240px;
    flex: 1 1 auto;
}

.chat-send-button {
    background: var(--brand-secondary);
    color: #fff;
    min-width: 110px;
    border-radius: 999px;
}

.chat-send-button:hover {
    filter: brightness(0.95);
}

.pagination-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
}

.pagination-nav-simple {
    justify-content: flex-end;
}

.pagination-summary {
    margin: 0;
    font-size: 0.84rem;
    color: #475569;
}

.pagination-summary strong {
    color: #0f172a;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pagination-link,
.pagination-current,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.6rem;
    min-height: 2.6rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
}

.pagination-link {
    color: #0f172a;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pagination-link:hover {
    text-decoration: none;
    border-color: var(--brand-secondary);
    color: var(--brand-primary);
    background: #f8fbff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.12);
}

.pagination-link-prev,
.pagination-link-next {
    gap: 0.35rem;
    min-width: auto;
    white-space: nowrap;
}

.pagination-current {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: #fff;
}

.pagination-ellipsis {
    color: #64748b;
}

.pagination-link.is-disabled,
.pagination-link[aria-disabled="true"] {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #dbe2ea;
    cursor: not-allowed;
    box-shadow: none;
}

.pagination-arrow {
    font-size: 1rem;
    line-height: 1;
}

@media (max-width: 760px) {
    /* FEAT-024: Datentabellen ragten auf schmalen Viewports (Smartphone) aus dem
       Body heraus. display:block macht jede Tabelle im Hauptbereich zu einem eigenen
       horizontal scrollbaren Container, statt die ganze Seite zu verbreitern. */
    .page-content table {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.8rem 0;
    }

    .container {
        width: min(1720px, 94%);
    }

    .project-item-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .time-report-bar-top {
        align-items: flex-start;
    }

    .time-distribution-chart {
        grid-template-columns: 58px minmax(0, 1fr);
    }

    .time-distribution-plot {
        grid-auto-columns: minmax(28px, 34px);
        gap: 0.5rem;
    }

    .time-distribution-column-area {
        height: 180px;
    }

    .time-distribution-column {
        grid-template-rows: minmax(1rem, auto) 180px 2rem;
    }

    .time-distribution-column-bar {
        width: 14px;
    }

    .pagination-nav {
        align-items: stretch;
    }

    .pagination-summary {
        width: 100%;
    }

    .pagination-controls {
        width: 100%;
    }
}

/* FEAT-006: Aktivitäts-Stream + Mentions + Edit-Form */
.activity-thread .activity-entry {
    margin-bottom: 0.6rem;
}
.activity-event {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    padding: 0.4rem 0.8rem;
    font-size: 0.92rem;
    color: #555;
    background: #f7f7f9;
    border-left: 3px solid #d0d4dc;
    border-radius: 4px;
}
.activity-event .activity-icon {
    color: #9aa1ad;
}
.activity-event .activity-time {
    color: #888;
    font-size: 0.85rem;
}
.chat-edited {
    color: #888;
    font-size: 0.8rem;
    margin-left: 0.4rem;
}
.chat-actions {
    margin-top: 0.4rem;
}
.button-small {
    padding: 0.3rem 0.55rem;
    min-height: 36px;
    font-size: 0.8rem;
}
.activity-filter {
    display: flex;
    gap: 0.4rem;
}
span.mention {
    background: #e5edff;
    color: #1f3a8a;
    padding: 0 0.2rem;
    border-radius: 3px;
    font-weight: 500;
}
span.mention-inactive {
    background: #f0f0f0;
    color: #777;
    text-decoration: line-through;
}
.mention-dropdown {
    list-style: none;
    margin: 0;
    padding: 0.2rem 0;
    background: #fff;
    border: 1px solid #cfd4dd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-radius: 4px;
    max-height: 240px;
    overflow-y: auto;
}
.mention-option {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}
.mention-option.is-active,
.mention-option:hover {
    background: #e5edff;
}
.mention-option .mention-token {
    color: #6b7280;
    font-size: 0.85rem;
}

/* FEAT-039: Quellen-Zuordnung — Checkbox-Liste. Umgeht die globale Regel
   input{width:100%}, die Checkboxen sonst zerreißt (Muster analog
   .column-picker-menu). Responsive Karten-Optik mit Hover. */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.55rem 0.7rem;
    font-weight: normal;
    font-size: 0.95rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.checkbox-grid label:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.checkbox-grid input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    flex-shrink: 0;
    accent-color: #0f172a;
    cursor: pointer;
}
.checkbox-grid .muted {
    color: #94a3b8;
    font-size: 0.85rem;
}
