:root {
    --app-bg: #eef3f8;
    --panel-bg: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e2e8f0;
    --line-dark: #cbd5e1;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1f5f8b;
    --primary-2: #2d8cc8;
    --success: #168a52;
    --danger: #dc3545;
    --warning: #f59e0b;
    --radius: 14px;
    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
}

html,
body {
    height: 100%;
}

.app-body {
    margin: 0;
    background: var(--app-bg);
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    font-size: 14px;
}

/* HEADER */

.app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.app-navbar {
    background: linear-gradient(135deg, #071d35, #0f3a66);
    min-height: 64px;
    box-shadow: 0 6px 22px rgba(2, 8, 23, 0.28);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.app-brand {
    color: #ffffff !important;
    font-weight: 900;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.03em;
    text-decoration: none;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, rgba(59,130,246,.35), rgba(255,255,255,.12));
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-nav {
    gap: 4px;
}

.app-nav-link {
    color: rgba(255,255,255,0.86) !important;
    font-weight: 700;
    padding: 9px 12px !important;
    border-radius: 12px;
    font-size: 0.91rem;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all .15s ease;
}

    .app-nav-link:hover {
        background: rgba(255,255,255,0.10);
        color: #ffffff !important;
    }

    .app-nav-link.active {
        background: #2563eb;
        color: #ffffff !important;
        box-shadow: 0 6px 16px rgba(37,99,235,.35);
    }

.nav-upload {
    background: rgba(22, 138, 82, 0.18);
    color: #dcfce7 !important;
}

    .nav-upload:hover {
        background: rgba(22, 138, 82, 0.28);
    }

    .nav-upload.active {
        background: #16a34a;
    }

.nav-icon {
    font-size: 0.95rem;
}

.app-user-nav {
    gap: 8px;
}

.app-user-badge {
    background: rgba(255,255,255,0.10);
    color: #ffffff;
    padding: 8px 13px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.12);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 999px;
    box-shadow: 0 0 0 3px rgba(34,197,94,.18);
    flex: 0 0 auto;
}

.app-logout-btn {
    background: rgba(255,255,255,0.92);
    color: #0f172a;
    border: none;
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 0.84rem;
    font-weight: 800;
}

    .app-logout-btn:hover {
        background: #ffffff;
    }

.app-toggler {
    background: rgba(255,255,255,0.92);
    border-radius: 10px;
    border: none;
}

/* SHELL */

.app-shell {
    padding: 14px;
    min-height: calc(100vh - 100px);
}

.app-main {
    background: #f8fafc;
    border-radius: 18px;
    padding: 14px;
    box-shadow: var(--shadow-md);
    min-height: calc(100vh - 128px);
}

.app-footer {
    padding: 10px 24px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--muted);
}

/* DMS LAYOUT */

.dms-layout {
    display: grid;
    grid-template-columns: 300px minmax(560px, 1fr) 430px;
    gap: 14px;
    height: calc(100vh - 142px);
    min-height: 650px;
}

.dms-list,
.dms-details {
    background: var(--panel-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.75);
}

.dms-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.dms-details {
    display: flex;
    flex-direction: column;
}

/* EXPLORER SIDEBAR */

.dms-sidebar {
    padding: 6px;
    background: #f4f6f8;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: none;
    overflow-y: auto;
    font-size: 0.82rem;
}

.sidebar-header {
    padding: 7px 6px;
    margin-bottom: 5px;
    border-bottom: 1px solid #d1d5db;
}

    .sidebar-header h5 {
        font-size: 0.9rem;
        margin: 0;
        font-weight: 800;
    }

    .sidebar-header span {
        font-size: 0.75rem;
        color: #6b7280;
    }

.tree-tools {
    padding: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #d1d5db;
}

    .tree-tools .form-control {
        font-size: 0.78rem;
        height: 28px;
        border-radius: 4px;
    }

.tree-tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 5px;
}

    .tree-tool-buttons .btn {
        font-size: 0.74rem;
        padding: 3px 6px;
    }

.sidebar-actions {
    display: none;
}

.sidebar-all,
.folder-toggle,
.akte-toggle,
.akte-link,
.bereich-link,
.mail-year-toggle,
.mail-month-link,
.area-toggle,
.sub-area-link {
    min-height: 24px;
    padding: 3px 6px;
    margin: 1px 0;
    border-radius: 3px;
    background: transparent;
    color: #111827;
    box-shadow: none;
    border: none;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-all,
.akte-link,
.bereich-link,
.mail-month-link,
.sub-area-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-toggle,
.akte-toggle,
.mail-year-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.area-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 6px;
    align-items: center;
    text-align: left;
    cursor: pointer;
}

    .sidebar-all:hover,
    .folder-toggle:hover,
    .akte-toggle:hover,
    .akte-link:hover,
    .bereich-link:hover,
    .mail-year-toggle:hover,
    .mail-month-link:hover,
    .area-toggle:hover,
    .sub-area-link:hover {
        background: #e5e7eb;
        color: #111827;
    }

.sidebar-all.active,
.akte-link.active,
.bereich-link.active,
.mail-month-link.active,
.sub-area-link.active {
    background: #2563eb;
    color: #ffffff;
}

.folder-block {
    margin-bottom: 2px;
}

.akte-wrapper {
    margin-left: 12px;
    padding-left: 8px;
    border-left: 1px dotted #9ca3af;
}

.bereiche {
    margin-left: 14px;
    padding-left: 8px;
    border-left: 1px dotted #9ca3af;
}

.area-tree-node {
    margin: 1px 0;
}

.area-child-list {
    margin-left: 14px;
    padding-left: 8px;
    border-left: 1px dotted #9ca3af;
}

.sub-area-link {
    font-size: 0.8rem;
}

.mail-tree {
    margin-left: 0;
}

.mail-year-node {
    margin-left: 14px;
    padding-left: 8px;
    border-left: 1px dotted #9ca3af;
}

.mail-month-link {
    margin-left: 14px;
}

.akte-counter {
    background: #d1d5db;
    color: #111827;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.active .akte-counter,
.akte-link.active .akte-counter,
.bereich-link.active .akte-counter,
.mail-month-link.active .akte-counter,
.sub-area-link.active .akte-counter {
    background: rgba(255,255,255,0.25);
    color: #ffffff;
}

.area-toggle .akte-counter {
    margin-left: auto;
}

.collapse-icon {
    color: #6b7280;
    font-size: 0.75rem;
}

.bereich-add {
    display: none !important;
}

.empty-folder {
    color: #6b7280;
    font-size: 0.78rem;
    padding: 3px 6px;
    margin-left: 14px;
}

.tree-match {
    background: #f97316 !important;
    color: #ffffff !important;
}

.tree-hidden {
    display: none !important;
}

/* LISTE */

.list-header,
.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

    .list-header h3,
    .details-header h5 {
        margin: 0;
        font-weight: 800;
    }

    .list-header span {
        color: var(--muted);
        font-size: 0.82rem;
    }

.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    background: #ffffff;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

    .search-box .form-control {
        border-radius: 10px;
        border-color: var(--line-dark);
    }

    .search-box .btn {
        border-radius: 10px;
        font-weight: 700;
    }

.dms-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 12px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

    .dms-breadcrumb a {
        color: #2563eb;
        text-decoration: none;
        font-weight: 800;
    }

    .dms-breadcrumb strong {
        color: var(--text);
    }

/* AREA ACTION BAR */

.area-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #1f5f8b, #2563eb);
    color: #ffffff;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

    .area-action-bar span {
        color: #dbeafe;
        font-weight: 700;
    }

.area-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

    .area-action-buttons .btn {
        font-weight: 700;
        border-radius: 8px;
    }

/* TOOLBAR */

.document-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.document-stats {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.document-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* DROPZONE */

.drop-zone {
    border: 2px dashed #93c5fd;
    background: #eff6ff;
    color: #1e40af;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    text-align: center;
    transition: all 0.15s ease;
}

    .drop-zone strong {
        display: block;
        font-weight: 800;
    }

    .drop-zone span {
        display: block;
        font-size: 0.85rem;
        color: #64748b;
    }

    .drop-zone.drag-active {
        background: #dbeafe;
        border-color: #2563eb;
        transform: scale(1.01);
    }

/* TABLE */

.document-table {
    border-radius: 12px;
    overflow: auto;
    flex: 1;
    border: 1px solid var(--line);
    background: #ffffff;
}

    .document-table table {
        margin-bottom: 0;
    }

    .document-table thead th {
        position: sticky;
        top: 0;
        z-index: 3;
        background: #ffffff;
        border-bottom: 1px solid var(--line);
        color: #334155;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        padding: 11px 9px;
    }

    .document-table tbody td {
        padding: 12px 9px;
        vertical-align: middle;
    }

.document-row {
    cursor: pointer;
    border-bottom: 1px solid #edf2f7;
}

    .document-row:hover {
        background: #f8fafc;
    }

    .document-row.selected {
        background: #eef6ff !important;
        box-shadow: inset 4px 0 0 #2563eb;
    }

.doc-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .doc-title strong {
        display: block;
        font-weight: 800;
    }

    .doc-title small {
        color: var(--muted);
        display: block;
        font-size: 0.8rem;
    }

/* DETAILS */

.details-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    margin: 0;
    background: #ffffff;
}

.details-content {
    padding: 14px;
    overflow-y: auto;
    height: 100%;
}

.empty-details {
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.empty-icon {
    font-size: 42px;
    margin-bottom: 10px;
}

.loading-box {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

.document-detail-panel {
    min-width: 0;
}

.detail-title {
    margin-bottom: 10px;
}

    .detail-title h5 {
        font-weight: 800;
        margin-bottom: 2px;
        line-height: 1.25;
    }

    .detail-title span {
        color: var(--muted);
        font-size: 0.82rem;
        word-break: break-word;
    }

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 10px 0 12px 0;
}

    .detail-actions .btn {
        border-radius: 9px;
        font-weight: 700;
    }

.detail-meta {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.meta-row {
    display: grid;
    grid-template-columns: 112px 1fr;
    border-bottom: 1px solid var(--line);
}

    .meta-row:last-child {
        border-bottom: none;
    }

    .meta-row label {
        background: #f8fafc;
        padding: 8px 9px;
        font-weight: 800;
        color: #334155;
        margin: 0;
    }

    .meta-row span {
        padding: 8px 9px;
        color: var(--text);
        word-break: break-word;
    }

.description-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 11px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
}

    .description-box label {
        font-weight: 800;
        margin-bottom: 6px;
        display: block;
    }

    .description-box p {
        margin: 0;
    }

.preview-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.preview-header {
    background: #f8fafc;
    padding: 9px 12px;
    font-weight: 800;
    border-bottom: 1px solid var(--line);
}

.pdf-preview {
    width: 100%;
    height: calc(100vh - 360px);
    min-height: 480px;
    border: none;
}

.image-preview {
    width: 100%;
    height: auto;
    display: block;
}

.no-preview,
.office-preview {
    text-align: center;
    padding: 34px 18px;
    color: var(--muted);
}

.history-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.history-entry {
    padding: 10px 12px;
    border-top: 1px solid var(--line);
}

    .history-entry:first-child {
        border-top: none;
    }

    .history-entry strong {
        display: block;
        font-weight: 800;
    }

    .history-entry span {
        color: var(--muted);
        font-size: 0.8rem;
    }

    .history-entry p {
        margin: 4px 0 0 0;
        color: #334155;
    }

/* TABS */

.document-tabs {
    margin-top: 10px;
    border-bottom: 1px solid var(--line);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}

    .document-tabs .nav-link {
        font-size: 0.86rem;
        font-weight: 800;
        color: #2563eb;
        border-radius: 10px 10px 0 0;
        white-space: nowrap;
        padding: 8px 12px;
    }

        .document-tabs .nav-link.active {
            color: var(--text);
            background: #ffffff;
            border-color: var(--line) var(--line) #ffffff;
        }

.document-tab-content {
    border: 1px solid var(--line);
    border-top: none;
    padding: 12px;
    background: #ffffff;
    border-radius: 0 0 12px 12px;
}

/* MAIL */

.mail-attachment-row,
.mail-attachment-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

    .mail-attachment-form select {
        min-width: 180px;
    }

/* FORMULARE */

.upload-page {
    max-width: 1100px;
    margin: 0 auto;
}

.upload-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(226, 232, 240, 0.75);
}

.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

    .upload-header h3 {
        margin: 0;
        font-weight: 800;
    }

    .upload-header span {
        color: var(--muted);
    }

.side-box,
.upload-source-box {
    background: var(--panel-soft);
    border-radius: 14px;
    padding: 16px;
    border: 1px solid var(--line);
}

    .side-box h5,
    .upload-source-box h5 {
        font-weight: 800;
        margin-bottom: 14px;
    }

.upload-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

/* DASHBOARD */

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.dashboard-card,
.dashboard-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}

    .dashboard-card h2 {
        margin: 0;
        color: #0d6efd;
        font-size: 30px;
        font-weight: 800;
    }

    .dashboard-card span {
        color: var(--muted);
    }

/* LOGIN */

.login-page {
    min-height: calc(100vh - 170px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 420px;
    background: #ffffff;
    border-radius: 22px;
    padding: 34px;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.14);
}

.login-logo {
    width: 66px;
    height: 66px;
    border-radius: 18px;
    background: #e0f2fe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 18px;
}

.login-card h3 {
    font-weight: 800;
    margin-bottom: 6px;
}

.login-card p {
    color: var(--muted);
    margin-bottom: 24px;
}

/* MOBILE */

.mobile-offcanvas {
    background: #f8fafc;
}

.mobile-user-box {
    background: #e0f2fe;
    color: #075985;
    padding: 12px;
    border-radius: 14px;
    margin-bottom: 15px;
    font-weight: 800;
    word-break: break-word;
}

.mobile-menu-link {
    display: block;
    padding: 13px 14px;
    margin-bottom: 8px;
    background: #ffffff;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

    .mobile-menu-link:hover {
        background: #e0f2fe;
        color: #0369a1;
    }

.mobile-docs {
    display: none;
}

.mobile-doc-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 13px;
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    cursor: pointer;
}

    .mobile-doc-card:hover {
        background: #f1f5f9;
    }

.mobile-doc-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.mobile-doc-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

    .mobile-doc-info strong {
        font-size: 0.94rem;
        font-weight: 800;
    }

    .mobile-doc-info span {
        color: var(--muted);
        font-size: 0.8rem;
        word-break: break-word;
    }

    .mobile-doc-info small {
        color: #94a3b8;
        font-size: 0.76rem;
    }

/* RESPONSIVE */

@media (max-width: 1400px) {
    .dms-layout {
        grid-template-columns: 280px minmax(480px, 1fr) 390px;
    }
}

@media (max-width: 1200px) {
    .dms-layout {
        grid-template-columns: 280px 1fr;
        height: auto;
    }

    .dms-details {
        grid-column: 1 / -1;
        min-height: 500px;
    }

    .details-content {
        height: auto;
        max-height: none;
    }

    .pdf-preview {
        height: 620px;
    }
}

@media (max-width: 992px) {
    .desktop-menu {
        display: none !important;
    }

    .app-shell {
        padding: 10px;
    }

    .app-main {
        padding: 10px;
        border-radius: 14px;
    }

    .dms-layout {
        display: block;
        min-height: unset;
    }

    .dms-sidebar {
        margin-bottom: 12px;
        max-height: 360px;
    }

    .dms-list {
        margin-bottom: 12px;
    }

    .dms-details {
        margin-top: 12px;
    }

    .document-table {
        display: none !important;
    }

    .mobile-docs {
        display: block !important;
    }

    .search-box,
    .document-toolbar,
    .area-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

        .search-box button,
        .document-actions .btn,
        .area-action-buttons .btn {
            width: 100%;
        }

    .document-detail-panel .pdf-preview,
    .document-detail-panel .preview-box iframe {
        display: none;
    }

    .document-detail-panel .preview-box::after {
        content: "PDF bitte über Download öffnen.";
        display: block;
        padding: 20px;
        text-align: center;
        color: var(--muted);
    }

    .dashboard-cards {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 576px) {
    .app-navbar {
        min-height: 56px;
    }

    .app-brand {
        font-size: 1.1rem;
    }

    .brand-icon {
        width: 32px;
        height: 32px;
    }

    .meta-row {
        grid-template-columns: 1fr;
    }

        .meta-row label {
            border-bottom: 1px solid var(--line);
        }
}
