/* ================================================================
   Berichte WebApp – Glass-UI Design System
   Variables, Components, Layouts, Themes (Hell/Dunkel)
   ================================================================ */

/* ---- CSS Custom Properties (Hell = Default) ---- */
:root,
[data-theme="hell"] {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.12);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;

    --bg: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: rgba(255, 255, 255, 0.85);
    --surface-active: rgba(255, 255, 255, 0.95);
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);

    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-bg-strong: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-blur: blur(20px);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

    --sidebar-width: 260px;
    --topbar-height: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

[data-theme="dunkel"] {
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --surface-active: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);

    --text: #e2e8f0;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-bg-strong: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-blur: blur(20px);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Hintergrund-Effekt */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 10%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(34, 197, 94, 0.03) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

[data-theme="dunkel"] body::before {
    background:
        radial-gradient(ellipse at 20% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(34, 197, 94, 0.06) 0%, transparent 50%);
}

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

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* ---- Glass Components ---- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* ---- Loading Screen ---- */
.loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 9999;
    gap: 1rem;
    color: var(--text-muted);
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.login-container .form-row-between {
    margin-bottom: 20px;
}

.login-header h1 {
    display: inline-flex;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    vertical-align: middle;
}

.sidebar-logo {
    display: inline-flex;
    font-size: 1.2rem;
    font-weight: 700;
    vertical-align: middle;
}

#app-logo {
    height: 40px;
    margin-right: 10px;
}

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

/* ---- Login Page ---- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input::placeholder { color: var(--text-muted); opacity: 0.6; }

.form-row { display: flex; gap: 1rem; align-items: center; }
.form-row-between { justify-content: space-between; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.link-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color var(--transition);
}

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

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    text-decoration: none;
    line-height: 1.4;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-link {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
}

.btn-link:hover { color: var(--primary); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
    line-height: 1;
}

.btn-icon:hover { background: var(--surface); color: var(--text); }

.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ---- Messages ---- */
.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.message.success {
    background: var(--success-light);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.message.error {
    background: var(--error-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.message.warning {
    background: var(--warning-light);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

/* ---- App Layout ---- */
.page { height: 100vh; }

#page-app {
    display: flex;
    height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-close-btn { display: none; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-icon { font-size: 1.1rem; }

.nav-section {
    margin-top: 1rem;
}

.nav-section-title {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 1rem 0.25rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(4px);
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

#sidebar-toggle { display: none; }

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    flex: 1;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--error);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    line-height: 1.4;
}

/* ---- Content Area ---- */
.content-area {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.welcome-card,
.placeholder-card {
    padding: 2rem;
}

.welcome-card h2 {
    margin-bottom: 0.5rem;
}

/* ---- View Header ---- */
.view-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.view-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.view-header-left { display: flex; align-items: center; gap: 0.75rem; }
.view-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.badge-count {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.search-input {
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    width: 200px;
    transition: border-color var(--transition);
}

.search-input:focus { border-color: var(--primary); }

.filter-select {
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
}

/* ---- Data Tables ---- */
.table-container {
    overflow-x: auto;
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr.row-inactive { opacity: 0.5; }

.data-table .text-center { text-align: center; }
.data-table .cell-primary { font-weight: 600; }

.table-separator td {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* ---- Status Badges ---- */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-aktiv { background: var(--success-light); color: var(--success); }
.status-inaktiv { background: var(--error-light); color: var(--error); }
.status-offen { background: var(--warning-light); color: var(--warning); }
.status-kundendienst_beendet { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.status-abgeschlossen { background: var(--success-light); color: var(--success); }
.status-nacharbeit { background: rgba(239, 68, 68, 0.12); color: #f97316; }

.badge-neutral {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-active);
    color: var(--text-secondary);
}

/* ---- Role Badges ---- */
.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.role-master_admin { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.role-firmen_admin { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.role-geschaeftsfuehrung { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.role-bueromitarbeiter { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.role-aussendienst { background: rgba(99, 102, 241, 0.15); color: #6366f1; }

.badge-draft {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    margin-left: 0.35rem;
    vertical-align: middle;
}

/* ---- Dynamic Rows ---- */
.dynamic-row {
    position: relative;
}

.dynamic-row .btn-zeile-entfernen {
    flex-shrink: 0;
}

/* ---- Month Navigation ---- */
.month-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
}

.month-label {
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 180px;
    text-align: center;
}

/* ---- Flags (U/K/F) ---- */
.flag {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.flag-urlaub { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.flag-krank { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.flag-feiertag { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.row-abwesend {
    background: var(--surface) !important;
    opacity: 0.7;
}

/* ---- Netto Display ---- */
.netto-display {
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

/* ---- Stats Highlight ---- */
.stat-highlight {
    border-color: var(--primary);
}

/* ---- Table Footer ---- */
.data-table tfoot td {
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--border);
    font-size: 0.875rem;
}

/* ================================================================
   Phase 6: Signature Pad + Handwriting Overlay
   ================================================================ */

/* ---- Signature Pad ---- */
.signature-pad {
    margin-top: 0.5rem;
}

.signature-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.signature-canvas-wrap {
    position: relative;
    width: 100%;
    height: 150px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    cursor: crosshair;
    touch-action: none;
    overflow: hidden;
}

.signature-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.signature-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
    user-select: none;
}

.signature-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.signature-name-input {
    max-width: 200px;
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

/* ---- Handwriting Overlay ---- */
.hw-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

.hw-overlay.hidden {
    display: none;
}

.hw-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 2;
}

.hw-toolbar-left,
.hw-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.hw-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.hw-tool-btn:hover {
    background: var(--primary-light);
}

.hw-tool-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.hw-btn-done {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
    font-weight: 600;
}

.hw-btn-cancel {
    color: var(--text-muted) !important;
}

.hw-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}

/* Pen size dots */
.hw-dot {
    display: block;
    border-radius: 50%;
    background: currentColor;
}

.hw-dot-s { width: 4px; height: 4px; }
.hw-dot-m { width: 7px; height: 7px; }
.hw-dot-l { width: 11px; height: 11px; }

/* Color buttons */
.hw-color-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s;
}

.hw-color-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

/* Canvas Area */
.hw-canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    touch-action: none;
    background: #e8e8e8;
}

[data-theme="dark"] .hw-canvas-area,
[data-theme="dunkel"] .hw-canvas-area {
    background: #2a2a2a;
}

.hw-canvas-area canvas {
    position: absolute;
    top: 0;
    left: 0;
    /* width/height set by JS (A4 proportions) */
    cursor: crosshair;
    touch-action: none;
    background: #ffffff;
    transform-origin: top left;
    will-change: transform;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

/* Zoom controls */
.hw-zoom-label {
    display: inline-block;
    min-width: 3em;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    line-height: 2rem;
    vertical-align: middle;
}

/* Text area at bottom */
.hw-text-area {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.hw-text-area textarea {
    width: 100%;
    font-size: 0.9rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    resize: vertical;
}

/* ---- Handwriting Toggle Button (inline in forms) ---- */
.hw-toggle-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.hw-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.hw-toggle-btn.active,
.hw-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.hw-preview-img {
    max-width: 100%;
    max-height: 120px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* ---- Mobile Adjustments ---- */
@media (max-width: 768px) {
    .signature-canvas-wrap {
        height: 120px;
    }

    .signature-toolbar {
        flex-wrap: wrap;
    }

    .signature-name-input {
        max-width: 100%;
        flex: 1;
    }

    .hw-toolbar {
        padding: 0.35rem 0.5rem;
    }

    .hw-tool-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.8rem;
        padding: 0 0.35rem;
    }
}

/* ================================================================
   Phase 7: Dashboard Widgets
   ================================================================ */

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dashboard-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

/* ---- Widget Grid ---- */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

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

/* ---- Widget Card ---- */
.widget {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.widget-header {
    padding: 1rem 1.25rem 0.5rem;
}

.widget-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0;
}

.widget-body {
    padding: 0.5rem 1.25rem 1.25rem;
    flex: 1;
}

.widget-empty {
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.9rem;
}

/* ---- Widget List ---- */
.widget-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.widget-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}

a.widget-list-item:hover {
    background: var(--surface);
    margin: 0 -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.widget-list-item:last-child {
    border-bottom: none;
}

.widget-list-primary {
    font-weight: 600;
    font-size: 0.9rem;
}

.widget-list-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.widget-list-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.widget-list-warn {
    border-left: 3px solid var(--error);
    padding-left: 0.75rem;
}

/* ---- Widget Table ---- */
.widget-table-wrap {
    overflow-x: auto;
    margin: 0 -0.5rem;
}

.widget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.widget-table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.widget-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.widget-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Mini Bar Chart ---- */
.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 100px;
    padding-top: 0.5rem;
}

.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 80px;
    width: 100%;
}

.chart-bar {
    flex: 1;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
}

.chart-bar-kb {
    background: var(--primary);
}

.chart-bar-tb {
    background: var(--success);
    opacity: 0.7;
}

.chart-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.chart-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-dot-kb { background: var(--primary); }
.chart-dot-tb { background: var(--success); opacity: 0.7; }

/* ---- Text Colors ---- */
.text-error {
    color: var(--error);
    font-weight: 600;
}

.text-center {
    text-align: center;
}

/* ---- Modal Overlay ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
}

.modal-dialog {
    width: 90%;
    max-width: 480px;
    padding: 1.5rem;
}

.modal-dialog h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.pdf-link {
    text-decoration: none;
    cursor: pointer;
}

/* ---- Action Buttons ---- */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.btn-danger { color: var(--error) !important; }
.btn-danger:hover { background: var(--error-light) !important; }

/* ---- Form Sections ---- */
.form-sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-section {
    padding: 1.5rem;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

/* ---- Logo Preview ---- */
.logo-preview {
    max-width: 200px;
    max-height: 80px;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0.5rem;
}

/* ---- Loading Text ---- */
.loading-text {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

/* ---- Info Grid (Profil) ---- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.info-value {
    font-size: 0.9rem;
    color: var(--text);
}

/* ---- Stats Grid (Einstellungen) ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    transform: translateX(110%);
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.toast-show { transform: translateX(0); }
.toast-hide { transform: translateX(110%); opacity: 0; }

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-message { flex: 1; }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    line-height: 1;
}

/* ---- Auto-Save Indikator ---- */
.autosave-indicator {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 100;
    transition: opacity 0.3s;
}

/* ================================================================
   Responsive
   ================================================================ */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn { display: block; }
    #sidebar-toggle { display: block; }

    .main-content {
        margin-left: 0;
    }
}

/* Smartphone */
@media (max-width: 768px) {
    .login-card {
        padding: 1.5rem;
    }

    .content-area {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        max-width: none;
    }

    /* View header stacking */
    .view-header {
        flex-direction: column;
        align-items: stretch;
    }

    .view-header-right {
        margin-left: 0;
        flex-direction: column;
    }

    .search-input { width: 100%; }
    .filter-select { width: 100%; }

    /* Table → Card view on mobile */
    .data-table thead { display: none; }

    .data-table tbody tr {
        display: block;
        padding: 1rem;
        margin-bottom: 0.5rem;
        background: var(--surface);
        border-radius: var(--radius);
        border: 1px solid var(--border);
    }

    .data-table tbody tr:hover { background: var(--surface-hover); }

    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.3rem 0;
        border-bottom: none;
        font-size: 0.85rem;
    }

    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        margin-right: 1rem;
    }

    .table-separator { display: none; }

    .action-buttons {
        justify-content: flex-end;
        padding-top: 0.5rem;
    }

    .form-section { padding: 1rem; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
}

/* ================================================================
   Phase 9: Benachrichtigungen
   ================================================================ */

/* ---- Badge im Header ---- */
.btn-icon {
    position: relative;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--error);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---- Notification Panel (Dropdown) ---- */
.notif-panel {
    position: fixed;
    z-index: 7000;
    width: 380px;
    max-height: 480px;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.notif-panel.hidden {
    display: none;
}

.notif-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.notif-panel-title {
    font-weight: 700;
    font-size: 0.9rem;
}

.notif-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.notif-panel-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
}

.notif-show-all {
    font-size: 0.82rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.notif-show-all:hover {
    text-decoration: underline;
}

.notif-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- Notification Item ---- */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background: var(--surface);
}

.notif-item.notif-unread {
    background: rgba(102, 126, 234, 0.06);
    border-left: 3px solid var(--primary);
    padding-left: calc(1rem - 3px);
}

.notif-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.notif-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notif-title {
    font-weight: 600;
    font-size: 0.82rem;
    line-height: 1.3;
}

.notif-message {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.notif-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.2rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.notif-item:hover .notif-delete {
    opacity: 1;
}

.notif-delete:hover {
    color: var(--error);
}

/* ---- Notification Full Page ---- */
.notif-page-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.notif-page-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.notif-page-item.notif-unread {
    border-left: 4px solid var(--primary);
    background: rgba(102, 126, 234, 0.04);
}

.notif-page-left {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.notif-icon-lg {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.notif-page-title {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.notif-page-msg {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.notif-page-time {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.notif-page-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    align-items: center;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .notif-panel {
        width: calc(100vw - 1rem);
        right: 0.5rem !important;
        max-height: 70vh;
    }

    .notif-page-item {
        flex-direction: column;
        gap: 0.5rem;
    }

    .notif-page-actions {
        align-self: flex-end;
    }
}

/* ================================================================
   Phase 10: Export
   ================================================================ */

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.25rem;
}

.export-card h3 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
}

.export-card .text-muted {
    font-size: 0.82rem;
    margin-bottom: 1rem;
}

.export-filters {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

/* ================================================================
   Phase 11: Offline & Sync
   ================================================================ */

/* ---- Offline Status Bar ---- */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--warning, #f39c12);
    color: #fff;
    padding: 0.4rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.offline-bar.hidden {
    transform: translateY(-100%);
    pointer-events: none;
}

.offline-bar-icon {
    font-size: 1rem;
}

.offline-bar-sync {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
}

.offline-bar-sync.hidden {
    display: none;
}

.sync-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- Offline-Indikatoren an Formularen ---- */
body.is-offline .btn-primary::after {
    content: ' (offline)';
    font-size: 0.7rem;
    opacity: 0.7;
}

/* ========================================================================
   Phase E+H: UI-Verbesserungen
   ======================================================================== */

/* E4: Copyright Footer */
.app-copyright-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted, #888);
    background: var(--bg-secondary, rgba(248,250,252,0.85));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid var(--border, #e2e8f0);
    z-index: 90;
    pointer-events: none;
}

/* Platz für Footer am Seitenende */
.main-content,
#page-app .app-main {
    padding-bottom: 36px;
}

/* E5: Offline-Icon statt Bar */
.offline-icon-indicator {
    display: none;
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    background: none;
    border: none;
    color: var(--text);
}

.offline-icon-indicator.active {
    display: inline-flex;
}

.offline-icon-indicator .offline-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* E6: Push Bell Badge */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.notifications-btn {
    position: relative;
}

/* H1: Export Cards Padding */
.export-card {
    padding: 1.5rem !important;
}

.export-card h3 {
    margin-bottom: 0.5rem;
}

.export-filters {
    margin-top: 0.75rem;
}

.export-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* E9: Mobile Verbesserungen */
@media (max-width: 768px) {
    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.4rem;
    }

    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .action-buttons .btn {
        min-height: 36px;
        min-width: 36px;
        padding: 0.25rem 0.5rem;
    }

    .form-row {
        flex-direction: column;
    }

    .view-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .view-header-right {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-dialog {
        width: 95% !important;
        max-width: 95% !important;
        margin: 0.5rem;
    }

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

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

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .hw-toolbar {
        flex-direction: column;
        gap: 0.25rem;
    }

    .hw-toolbar-left,
    .hw-toolbar-right {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Touch targets */
    .btn,
    button {
        min-height: 40px;
    }

    .app-copyright-footer {
        height: 24px;
        font-size: 0.6rem;
    }
}

/* E7: PWA Install Button */
#pwa-install-btn {
    display: none;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    background: var(--primary, #3b82f6);
    color: #fff;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

#pwa-install-btn.visible {
    display: inline-flex;
}

#pwa-install-btn:hover {
    opacity: 0.9;
}

/* ====================================================================
   Autocomplete Dropdown (Kundensuche)
   ==================================================================== */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.autocomplete-dropdown .ac-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #e2e8f0);
    transition: background 0.1s;
}

.autocomplete-dropdown .ac-item:last-child {
    border-bottom: none;
}

.autocomplete-dropdown .ac-item:hover,
.autocomplete-dropdown .ac-item:focus {
    background: var(--bg-hover, #f1f5f9);
}

.autocomplete-dropdown.hidden {
    display: none;
}
