:root {
    --color-bg:            #f1f5f9;
    --color-sidebar:       #1e293b;
    --color-sidebar-hover: #334155;
    --color-sidebar-active:#2563eb;
    --color-brand:         #2563eb;
    --color-brand-dark:    #1d4ed8;
    --color-white:         #ffffff;
    --color-text:          #0f172a;
    --color-text-muted:    #64748b;
    --color-border:        #e2e8f0;
    --color-danger:        #ef4444;
    --color-success:       #22c55e;
    --color-warning:       #f59e0b;
    --color-info:          #3b82f6;
    --radius:              8px;
    --shadow:              0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:           0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-sidebar);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37,99,235,0.40);
}

.brand-name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: rgba(255,255,255,0.7);
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--color-sidebar-active);
    color: #fff;
}

.sidebar-user {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-sidebar-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
}

.btn-logout {
    color: rgba(255,255,255,0.5);
    flex-shrink: 0;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s;
}
.btn-logout:hover { color: #fff; }

/* ── Main Content ── */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── Page Header ── */
.page-header {
    padding: 24px 28px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-top: 2px;
}

.page-body {
    padding: 20px 28px 28px;
    flex: 1;
}

/* ── Cards ── */
.card {
    background: var(--color-white);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--color-text);
}

.stat-value.brand { color: var(--color-brand); }
.stat-value.warning { color: var(--color-warning); }
.stat-value.success { color: var(--color-success); }
.stat-value.danger  { color: var(--color-danger); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-brand-dark); }

.btn-secondary { background: #f3f4f6; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: #e9eaf0; }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-warning { background: var(--color-warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Status Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-neu         { background: #fef9c3; color: #92400e; }
.badge-geprüft     { background: #e0f2fe; color: #0369a1; }
.badge-übertragen  { background: #d1fae5; color: #065f46; }
.badge-default     { background: #f3f4f6; color: #374151; }

/* ── Log-Level Badges ── */
.log-badge-info    { background: #dbeafe; color: #1e40af; }
.log-badge-warning { background: #fef3c7; color: #92400e; }
.log-badge-error   { background: #fee2e2; color: #991b1b; }

/* ── Log table row highlighting ── */
.log-row-error   td:first-child { border-left: 3px solid #ef4444; }
.log-row-warning td:first-child { border-left: 3px solid #f59e0b; }
.log-row-info    td:first-child { border-left: 3px solid #93c5fd; }

/* ── Table ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    background: #f7f7f7;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ── Toolbar / Filters ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input, .select-input, .text-input, textarea {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13.5px;
    background: var(--color-white);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.search-input:focus, .select-input:focus, .text-input:focus, textarea:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.search-input { min-width: 220px; }

/* ── Forms ── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* ── Split Screen ── */
.split-screen {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 0;
    height: calc(100vh - 80px);
    overflow: hidden;
}

.split-left {
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
    padding: 20px;
    background: var(--color-white);
}

.split-right {
    background: #e5e7eb;
    display: flex;
    flex-direction: column;
}

.split-right iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.split-right .no-pdf {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 15px;
}

/* ── Field Groups ── */
.field-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--color-text-muted);
    margin: 18px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.field-group-title:first-child { margin-top: 0; }

.storage-ref {
    background: #fef9c3;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.storage-ref.missing {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--color-danger);
}

.storage-ref-label {
    font-weight: 700;
    text-transform: capitalize;
}

/* ── Alert / Toast ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 13.5px;
    min-width: 260px;
    animation: slideIn 0.2s ease;
}

.toast-success { background: #166534; color: #fff; }
.toast-error   { background: #991b1b; color: #fff; }
.toast-warning { background: #92400e; color: #fff; }
.toast-info    { background: #1e40af; color: #fff; }

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--color-white);
    border-radius: 10px;
    padding: 28px;
    width: 420px;
    max-width: 95vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #2563eb 100%);
}

.login-box {
    background: var(--color-white);
    border-radius: 12px;
    padding: 40px 36px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

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

.login-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
    flex-shrink: 0;
}

.login-logo-text {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: 0.3px;
}

.login-logo-sub {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ── Empty State ── */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--color-text-muted);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.text-muted { color: var(--color-text-muted); }
.text-sm    { font-size: 12.5px; }
.mt-4       { margin-top: 16px; }
.mb-4       { margin-bottom: 16px; }
.flex       { display: flex; align-items: center; gap: 8px; }
.flex-wrap  { flex-wrap: wrap; }
.w-full     { width: 100%; }

.checkbox-col { width: 36px; text-align: center; }
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--color-brand); }

/* ── Geführte Tour ── */
.tour-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9000;
    pointer-events: all;
}

.tour-backdrop.tour-no-target {
    background: rgba(0, 0, 0, 0.55);
    animation: tourFadeIn 0.25s ease;
}

.tour-spotlight {
    position: fixed;
    z-index: 9001;
    pointer-events: none;
    box-shadow: 0 0 0 4px #2563eb, 0 0 0 9000px rgba(0,0,0,0.55);
    border-radius: 6px;
    background: transparent;
    transition: top 0.28s ease, left 0.28s ease, width 0.28s ease, height 0.28s ease;
    animation: tourSpotIn 0.25s ease;
}

.tour-popover {
    position: fixed;
    z-index: 9002;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 4px 12px rgba(0,0,0,0.12);
    padding: 22px 22px 18px;
    width: 320px;
    max-width: calc(100vw - 24px);
    animation: tourPopIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}

.tour-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.tour-step-badge {
    font-size: 11px;
    font-weight: 700;
    color: #2563eb;
    background: #eff6ff;
    border-radius: 99px;
    padding: 3px 10px;
    letter-spacing: 0.3px;
}

.tour-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.tour-close-btn:hover { color: #0f172a; }

.tour-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.tour-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
    line-height: 1.3;
}

.tour-text {
    font-size: 13.5px;
    color: #374151;
    line-height: 1.65;
    margin-bottom: 18px;
}

.tour-progress {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
}

.tour-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: background 0.2s, transform 0.2s;
}

.tour-progress-dot.active {
    background: #2563eb;
    transform: scale(1.15);
}

.tour-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.tour-btn-skip {
    font-size: 13px;
}

.tour-btn-next {
    background: #2563eb;
    color: #fff;
    font-size: 13px;
    min-width: 90px;
}
.tour-btn-next:hover { background: #1d4ed8; }

@keyframes tourFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tourSpotIn {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes tourPopIn {
    from { opacity: 0; transform: scale(0.88) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
