:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --sidebar: #101827;
    --sidebar-soft: #1b2638;
    --primary: #1f5eff;
    --primary-dark: #1649ca;
    --text: #172033;
    --muted: #6b7280;
    --border: #dde3ec;
    --danger: #c83232;
    --success: #197447;
    --warning: #b4670b;
    --radius: 14px;
    --shadow: 0 8px 28px rgba(25, 39, 68, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

button,
input {
    font: inherit;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    background: var(--sidebar);
    color: white;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand span {
    margin-top: 3px;
    color: #aeb8c8;
    font-size: 13px;
}

.sidebar-logo,
.login-logo {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 22px;
    font-weight: bold;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 24px;
}

.sidebar-nav a {
    padding: 12px 14px;
    border-radius: 10px;
    color: #c7d0de;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-soft);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-box strong,
.user-box span {
    display: block;
}

.user-box span {
    margin-top: 3px;
    overflow: hidden;
    color: #aeb8c8;
    font-size: 12px;
    text-overflow: ellipsis;
}

.logout-button {
    width: 100%;
    margin-top: 14px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 9px;
    background: transparent;
    color: white;
    cursor: pointer;
}

.main-content {
    width: calc(100% - 250px);
    margin-left: 250px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 94px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: white;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.date-time {
    text-align: right;
}

.date-time strong,
.date-time span {
    display: block;
}

.date-time span {
    margin-top: 4px;
    color: var(--muted);
}

.notification-button {
    position: relative;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    cursor: pointer;
}

.notification-button span {
    position: absolute;
    top: -5px;
    right: -5px;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: white;
    font-size: 11px;
}

.page-content {
    padding: 28px 32px 40px;
}

.search-panel,
.panel,
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.search-panel {
    padding: 22px;
}

.search-panel label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.search-row {
    display: flex;
    gap: 12px;
}

.search-row input {
    flex: 1;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.button {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.button-primary {
    background: var(--primary);
    color: white;
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-full {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.stat-card {
    padding: 20px;
}

.stat-card span,
.stat-card strong,
.stat-card small {
    display: block;
}

.stat-card span {
    color: var(--muted);
}

.stat-card strong {
    margin: 10px 0 6px;
    font-size: 30px;
}

.stat-card small {
    color: var(--muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
    gap: 20px;
    margin-top: 20px;
}

.panel {
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.table-wrapper {
    overflow-x: auto;
}

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

th,
td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.tag,
.status {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
}

.tag-blue {
    background: #e8efff;
    color: #2455bd;
}

.tag-green {
    background: #e6f6ed;
    color: #197447;
}

.tag-red {
    background: #fdeaea;
    color: #b82f2f;
}

.status-open {
    background: #eef2f7;
    color: #455166;
}

.status-progress {
    background: #fff1da;
    color: var(--warning);
}

.status-overdue {
    background: #fdeaea;
    color: var(--danger);
}

.task-list,
.calendar-list {
    padding: 10px 20px 20px;
}

.task-item,
.calendar-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.task-item strong,
.task-item span,
.calendar-item strong,
.calendar-item span {
    display: block;
}

.task-item div > span,
.calendar-item div > span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.calendar-date {
    min-width: 52px;
    padding: 8px;
    border-radius: 10px;
    background: #edf2ff;
    text-align: center;
}

.calendar-date strong {
    font-size: 20px;
}

.calendar-date span {
    margin-top: 1px !important;
    color: var(--primary) !important;
    font-size: 11px !important;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 20px;
}

.quick-actions a {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8faff;
    color: var(--text);
    font-weight: bold;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top right, rgba(31, 94, 255, 0.18), transparent 35%),
        #eef2f8;
}

.login-card {
    width: min(430px, 100%);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: white;
    box-shadow: 0 20px 60px rgba(24, 37, 62, 0.14);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.login-brand h1 {
    margin: 0;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 20px;
    color: var(--muted);
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 10px;
}

.alert-error {
    background: #fdeaea;
    color: var(--danger);
}

.login-note {
    margin: 22px 0 0;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        align-items: flex-start;
        gap: 18px;
        padding: 20px;
    }

    .page-content {
        padding: 20px;
    }

    .date-time {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-row {
        display: grid;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}
.button-secondary {
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
}

.case-link {
    font-weight: bold;
}

.case-header-card {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    box-shadow: var(--shadow);
}

.case-header-card h2 {
    margin: 12px 0 8px;
}

.case-header-card p {
    margin: 0;
    color: var(--muted);
}

.case-badges {
    display: flex;
    gap: 8px;
}

.case-header-actions {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.case-overview-grid,
.case-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 20px;
}

.detail-grid span,
.detail-grid strong {
    display: block;
}

.detail-grid span {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}

.note-box {
    padding: 20px;
}

.note-box p {
    line-height: 1.6;
}

.note-box span {
    color: var(--muted);
    font-size: 13px;
}

.document-list,
.activity-list {
    padding: 10px 20px 20px;
}

.document-item,
.activity-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.document-item strong,
.document-item span,
.activity-item strong,
.activity-item span {
    display: block;
}

.document-item span,
.activity-item span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.document-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .case-header-card {
        display: block;
    }

    .case-header-actions {
        margin-top: 20px;
    }

    .case-overview-grid,
    .case-content-grid {
        grid-template-columns: 1fr;
    }
}

/* Einheitliche Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
}

/* Notizformular */
.note-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.note-form > label:first-child {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.note-form textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.note-form textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.note-form .checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
}

.note-form .checkbox-row input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.note-form .button {
    align-self: flex-start;
}

/* Gespeicherte Notizen */
.note-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.note-list .note-box {
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background: #f8fafc;
}

.note-list .note-box p {
    margin: 10px 0 0;
    color: #1e293b;
    line-height: 1.55;
    white-space: pre-wrap;
}

.note-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.note-meta strong {
    color: #0f172a;
}

.note-meta span {
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}

.empty-state {
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    text-align: center;
}

.success-message,
.error-message {
    margin: 20px 20px 0;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
}

.success-message {
    border: 1px solid #86efac;
    background: #f0fdf4;
    color: #166534;
}

.error-message {
    border: 1px solid #fca5a5;
    background: #fef2f2;
    color: #991b1b;
}

.error-message ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

@media (max-width: 700px) {
    .note-meta {
        flex-direction: column;
        gap: 4px;
    }

    .note-meta span {
        white-space: normal;
    }
}


/* Formular: Kunde und erster Fall */
.case-create-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.form-section {
    overflow: visible;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 22px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    font: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}

.form-field textarea {
    min-height: 100px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
}

.form-global-error {
    margin: 0 0 20px;
}

[hidden] {
    display: none !important;
}

@media (max-width: 800px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-field-full {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .form-actions .button {
        width: 100%;
    }
}


/* Dokument-Upload */
.document-upload-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.document-upload-form input[type="file"] {
    padding: 9px;
    background: #f8fafc;
}

.document-upload-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-start;
}

.document-item p {
    margin: 8px 0 0;
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 800px) {
    .document-upload-form {
        grid-template-columns: 1fr;
    }

    .document-upload-actions {
        grid-column: auto;
    }
}

/* Kundendetailseite */
.customer-layout {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.customer-note {
    margin: 0 22px 22px;
    padding: 16px;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background: #f8fafc;
}

.customer-note p {
    margin: 8px 0 0;
    color: #475569;
    line-height: 1.5;
}

/* Fallliste */
.customer-cases {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 20px;
}

.customer-case {
    position: relative;
    overflow: visible;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.customer-case:hover {
    border-color: #b8c7dc;
    box-shadow: 0 7px 20px rgba(15, 23, 42, 0.08);
}

/* Kopfzeile des Falls */
.customer-case summary {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 74px;
    padding: 18px 22px;
    list-style: none;
    cursor: pointer;
    background: #ffffff;
    border-radius: 12px;
}

.customer-case summary::-webkit-details-marker {
    display: none;
}

.customer-case summary::marker {
    content: "";
}

/* Runder Button exakt auf der unteren Trennlinie */
.customer-case summary::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    z-index: 20;
    width: 34px;
    height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
    transform: translate(-50%, -50%);
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

/* Chevron im Kreis */
.customer-case summary::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    z-index: 21;
    width: 8px;
    height: 8px;
    border-right: 2px solid #475569;
    border-bottom: 2px solid #475569;
    transform: translate(-50%, -70%) rotate(45deg);
    pointer-events: none;
    transition:
        transform 0.18s ease,
        border-color 0.18s ease;
}

.customer-case summary:hover::before {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 5px 16px rgba(37, 99, 235, 0.20);
}

.customer-case summary:hover::after {
    border-color: #2563eb;
}

/* Geöffneter Fall */
.customer-case[open] summary {
    border-bottom: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    background: #fbfdff;
}

.customer-case[open] summary::before {
    border-color: #2563eb;
    background: #2563eb;
}

.customer-case[open] summary::after {
    border-color: #ffffff;
    transform: translate(-50%, -30%) rotate(225deg);
}

/* Inhalt der Kopfzeile */
.customer-case-summary-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.customer-case-summary-main strong {
    color: #0f172a;
    font-size: 14px;
    white-space: nowrap;
}

.customer-case-summary-main span {
    overflow: hidden;
    color: #334155;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-case-summary-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* Aufgeklappter Inhalt */
.customer-case-details {
    position: relative;
    z-index: 1;
    padding: 34px 22px 22px;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
}

.customer-case-description {
    margin-top: 18px;
    padding: 14px;
    border-radius: 8px;
    background: #f8fafc;
}

.customer-case-description p {
    margin: 7px 0 0;
    color: #475569;
    line-height: 1.5;
}

.customer-case-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

@media (max-width: 800px) {
    .customer-case summary {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 16px 16px 20px;
    }

    .customer-case-summary-main {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .customer-case-summary-main strong,
    .customer-case-summary-main span {
        white-space: normal;
    }

    .customer-case-summary-meta {
        justify-content: flex-start;
    }

    .customer-case-actions {
        flex-direction: column;
    }

    .customer-case-actions .button {
        width: 100%;
    }
}
