/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
    --primary: #667eea;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-600: #4b5563;
    --bg: #f5f5f5;
    --bg-secondary: #ffffff;
    --text: #333333;
    --border: #e5e7eb;

    /* Semantic Badge Colors */
    --badge-success-bg: #d1fae5;
    --badge-success-text: #065f46;
    --badge-danger-bg: #fee2e2;
    --badge-danger-text: #991b1b;
    --badge-info-bg: #dbeafe;
    --badge-info-text: #1e40af;
    --badge-warning-bg: #fef3c7;
    --badge-warning-text: #92400e;
    --badge-purple-bg: #ede9fe;
    --badge-purple-text: #5b21b6;
}

body.dark-mode {
    --primary: #818cf8;
    --bg: #1f2937;
    --bg-secondary: #111827;
    --text: #f9fafb;
    --border: #374151;
    --gray-50: #374151;
    --gray-100: #4b5563;
    --gray-200: #6b7280;

    /* Dark Badge Colors */
    --badge-success-bg: #064e3b;
    --badge-success-text: #6ee7b7;
    --badge-danger-bg: #7f1d1d;
    --badge-danger-text: #fca5a5;
    --badge-info-bg: #1e3a5f;
    --badge-info-text: #93c5fd;
    --badge-warning-bg: #78350f;
    --badge-warning-text: #fde68a;
    --badge-purple-bg: #4c1d95;
    --badge-purple-text: #c4b5fd;
}

/* ========================================
   Base
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* ========================================
   Header & Navigation
   ======================================== */
.header {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 16px rgba(79, 70, 229, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 22px;
}

.header-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 4px;
}

.nav-tab {
    padding: 6px 16px;
    border-radius: 6px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    background: rgba(255,255,255,0.1);
}

.nav-tab:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.nav-tab.active {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200); }

.header .btn-primary { background: white; color: var(--primary); }
.header .btn-secondary { background: rgba(255,255,255,0.2); color: white; border: none; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-purple { background: var(--purple); color: white; }
.btn-small { padding: 6px 10px; font-size: 12px; }

/* Icon-only Button (Header) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.btn-icon:active {
    transform: translateY(0);
    background: rgba(255,255,255,0.2);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Layout
   ======================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
}

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

/* ========================================
   Stats Grid / Dashboard
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--gray-50);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

body.dark-mode .stat-card { background: var(--gray-100); }

.stat-card h3 {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 22px;
    font-weight: bold;
    color: var(--primary);
}
.stat-card .value.stat-warning { color: #dc2626; }

.stats-grid-extended {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.dashboard-progress { margin-bottom: 16px; }
.dashboard-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--gray-600);
}
.progress-bar-track {
    background: var(--gray-200);
    border-radius: 8px;
    height: 10px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #818cf8);
    border-radius: 8px;
    transition: width 0.5s ease;
}

/* ========================================
   Calendar
   ======================================== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.calendar-nav {
    display: flex;
    gap: 8px;
}

.calendar-nav button {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    padding: 6px;
    color: var(--gray-600);
}

.calendar-day {
    aspect-ratio: 1;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-day:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.calendar-day.other-month {
    opacity: 0.15;
    pointer-events: none;
}

.calendar-day.today {
    background: #e0e7ff;
    border-color: var(--primary);
    font-weight: bold;
}

body.dark-mode .calendar-day.today {
    background: #4338ca;
}

.calendar-day.selected {
    background: var(--primary);
    color: white;
    border: 3px solid #1e40af;
    font-weight: bold;
    box-shadow: 0 0 0 2px white, 0 0 0 5px #4338ca;
}

.calendar-day.weekend {
    background: #e5e7eb;
}

body.dark-mode .calendar-day.weekend {
    background: var(--gray-100);
}

.calendar-day.few-notes {
    background: #fee2e2;
    border-color: #ef4444;
}

.calendar-day.many-notes {
    background: #d1fae5;
    border-color: #10b981;
}

.calendar-day.selected.few-notes,
.calendar-day.selected.many-notes,
.calendar-day.selected.weekend {
    background: var(--primary);
    color: white;
    border: 3px solid #1e40af;
    box-shadow: 0 0 0 2px white, 0 0 0 5px #4338ca;
}

.calendar-legend {
    display: flex;
    gap: 15px;
    margin-top: 12px;
    flex-wrap: wrap;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-red { background: #fee2e2; border-color: #ef4444; }
.legend-green { background: #d1fae5; border-color: #10b981; }
.legend-gray { background: #e5e7eb; border-color: var(--gray-200); }

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

.form-group textarea,
.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

body.dark-mode .form-group textarea,
body.dark-mode .form-group input,
body.dark-mode .form-group select {
    background: var(--gray-100);
    color: var(--text);
    border-color: var(--border);
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #fef3c7;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
}

body.dark-mode .checkbox-group {
    background: #78350f;
}

input[type="file"] {
    padding: 8px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    width: 100%;
    font-size: 13px;
    cursor: pointer;
}

body.dark-mode input[type="file"] {
    background: var(--gray-100);
    color: var(--text);
    border-color: var(--border);
}

/* ========================================
   Notes
   ======================================== */
.notes-list {
    min-height: 400px;
    overflow-y: auto;
}

.note-item {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

body.dark-mode .note-item {
    background: var(--gray-100);
}

.note-item:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.note-item.ai-corrected {
    background: #d1fae5;
    border-color: var(--success);
}

body.dark-mode .note-item.ai-corrected {
    background: #064e3b;
}

.note-item.free-day {
    background: #e5e7eb;
}

body.dark-mode .note-item.free-day {
    background: #4b5563;
}

.note-item.location-warning {
    border: 3px solid #f59e0b;
    background: #fef3c7;
    position: relative;
}

body.dark-mode .note-item.location-warning {
    background: #78350f;
}

.note-item.location-warning::before {
    content: '\26A0\FE0F';
    position: absolute;
    top: -10px;
    right: 10px;
    font-size: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.note-badges {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.note-badge {
    padding: 3px 8px;
    background: var(--success);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.note-badge.free {
    background: var(--gray-600);
}

.note-badge.warning {
    background: var(--warning);
}

.note-text {
    margin-bottom: 10px;
    line-height: 1.6;
    font-size: 14px;
}

.note-text.editable {
    border: 2px dashed var(--primary);
    padding: 8px;
    border-radius: 4px;
    cursor: text;
    background: white;
}

.note-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-600);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--success);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-weight: 600;
    animation: slideIn 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
}

.toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    margin-left: auto;
}

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

/* ========================================
   Modals
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-600);
    line-height: 1;
}

/* ========================================
   Loading Spinner
   ======================================== */
.loading {
    text-align: center;
    padding: 15px;
    display: none;
}

.loading.show { display: block; }

.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   Misc
   ======================================== */
/* Utility Classes */
.btn-block { width: 100%; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.card-hint { font-size: 13px; color: var(--gray-600); margin-bottom: 12px; }
.loading-text { font-size: 13px; }
.form-label-small { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: block; }
.form-hint { color: var(--gray-600); display: block; }
.checkbox-label { margin: 0; cursor: pointer; font-weight: normal; }
.templates-section { display: none; }
.export-actions { display: flex; gap: 8px; margin-top: 15px; }
.export-actions .btn { flex: 1; }
.export-preview-entry { padding: 8px; margin: 5px 0; border-radius: 4px; font-size: 13px; }
.export-preview-freeday { background: var(--gray-200); }

/* Bulk Mode & Preview */
.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 2px solid var(--primary);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}
.bulk-action-buttons { display: flex; gap: 8px; }

.calendar-day.bulk-selected {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}
.calendar-day .bulk-checkbox {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

#bulkModeToggle {
    font-size: 14px;
    padding: 4px 8px;
}
#bulkModeToggle.active {
    background: var(--primary);
    color: white;
    border-radius: 6px;
}

.preview-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
}
.preview-entry:last-child { border-bottom: none; }
.preview-entry input[type="checkbox"] {
    margin-top: 4px;
    accent-color: var(--primary);
}
.preview-entry textarea {
    flex: 1;
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
}
.preview-entry .preview-source {
    font-size: 11px;
    color: var(--gray-600);
    white-space: nowrap;
    margin-top: 4px;
}
.preview-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Story Arc Components */
.story-arc-section { margin-bottom: 24px; }
.story-arc-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}
.story-arc-section-header h3 { font-size: 15px; margin: 0; }

.arc-template-card {
    background: var(--bg);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}
.arc-template-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.arc-template-card.row-inactive { opacity: 0.5; }

.arc-template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.arc-template-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.arc-steps-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
}
.arc-step-badge {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
    border-radius: 6px;
    display: inline-block;
}

.arc-step-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.arc-step-num {
    font-weight: 700;
    font-size: 13px;
    color: var(--gray-600);
    min-width: 20px;
    text-align: center;
}
.arc-step-field {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
}
.arc-step-field:focus {
    border-color: var(--primary);
    outline: none;
}

.arc-progress {
    background: var(--gray-200);
    border-radius: 6px;
    height: 6px;
    overflow: hidden;
    margin: 8px 0;
}
.arc-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #818cf8);
    border-radius: 6px;
    transition: width 0.3s;
}

.arc-detail-info p { margin: 4px 0; font-size: 14px; }
.arc-resolved-steps { margin-top: 8px; }
.arc-resolved-step {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-200);
}
.arc-resolved-step:last-child { border-bottom: none; }

.hint {
    font-size: 11px;
    color: var(--gray-600);
    margin-top: 5px;
}

.maintenance-config {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
}

.maintenance-config select {
    padding: 6px 10px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
}

/* Templates */
.templates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.template-chip {
    padding: 6px 12px;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.template-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Undo Banner */
.undo-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    gap: 15px;
    z-index: 1000;
}

.undo-banner.show { display: flex; }

/* Keyboard Shortcuts */
.keyboard-shortcuts {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 10px;
    padding: 10px;
    background: var(--gray-50);
    border-radius: 6px;
}

body.dark-mode .keyboard-shortcuts {
    background: var(--gray-100);
}

.keyboard-shortcuts kbd {
    padding: 2px 6px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
}

body.dark-mode .keyboard-shortcuts kbd {
    background: var(--gray-200);
}

/* ========================================
   Stammdaten Styles
   ======================================== */
.stammdaten-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.stammdaten-stats {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--gray-600);
}

.stammdaten-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stammdaten-stats .stat-value {
    font-weight: 700;
    color: var(--primary);
}

/* Tab Switcher */
.tab-switcher {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.dark-mode .tab-switcher {
    background: var(--gray-100);
}

body.dark-mode .tab-btn.active {
    background: var(--primary);
}

/* Stammdaten Actions */
.stammdaten-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

body.dark-mode .search-box input {
    background: var(--gray-100);
    color: var(--text);
    border-color: var(--border);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Stammdaten Table */
.table-container {
    overflow-x: auto;
}

.stammdaten-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.stammdaten-table thead th {
    background: var(--gray-100);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

body.dark-mode .stammdaten-table thead th {
    background: var(--gray-100);
    border-color: var(--border);
}

.stammdaten-table tbody td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}

body.dark-mode .stammdaten-table tbody td {
    border-color: var(--border);
}

.stammdaten-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

body.dark-mode .stammdaten-table tbody tr:hover {
    background: rgba(129, 140, 248, 0.1);
}

.stammdaten-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

.stammdaten-table .actions-cell .btn + .btn {
    margin-left: 6px;
}

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

body.dark-mode .btn-secondary {
    background: var(--gray-200);
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode .btn-secondary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

body.dark-mode .header .btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
}

/* ========================================
   Badges (shared base + semantic variants)
   ======================================== */
.badge-base,
.internet-badge,
.status-badge,
.ort-badge,
.freq-badge,
.prio-badge,
.loc-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.internet-badge.yes { background: var(--badge-success-bg); color: var(--badge-success-text); }
.internet-badge.no { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.status-badge.active { background: var(--badge-success-bg); color: var(--badge-success-text); }
.status-badge.inactive { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.ort-badge { background: var(--gray-200); color: var(--gray-600); }
.ort-badge.homeoffice { background: var(--badge-info-bg); color: var(--badge-info-text); }
.ort-badge.vor-ort { background: var(--badge-warning-bg); color: var(--badge-warning-text); }

.freq-badge { background: var(--gray-200); color: var(--gray-600); }
.freq-badge.daily { background: var(--badge-info-bg); color: var(--badge-info-text); }
.freq-badge.weekly { background: var(--badge-success-bg); color: var(--badge-success-text); }
.freq-badge.biweekly { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.freq-badge.monthly { background: var(--badge-purple-bg); color: var(--badge-purple-text); }

.prio-badge { background: var(--gray-200); color: var(--gray-600); }
.prio-badge.low { background: var(--badge-success-bg); color: var(--badge-success-text); }
.prio-badge.medium { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.prio-badge.high { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.loc-badge { background: var(--gray-200); color: var(--gray-600); }
.loc-badge.remote { background: var(--badge-info-bg); color: var(--badge-info-text); }
.loc-badge.onsite { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.loc-badge.both { background: var(--badge-purple-bg); color: var(--badge-purple-text); }

.row-inactive {
    opacity: 0.5;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

/* ========================================
   Login Page
   ======================================== */
body.login-page {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.login-page.dark-mode {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
}

.login-container {
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-container .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-container .logo svg {
    width: 80px;
    height: 80px;
    color: var(--primary);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 24px;
}

.login-container p {
    text-align: center;
    color: var(--gray-600);
    margin-bottom: 30px;
}

.login-container input[type="password"] {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 24px;
    text-align: center;
    letter-spacing: 10px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
    background: var(--bg-secondary);
    color: var(--text);
}

.login-container input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-container button[type="submit"] {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.login-container button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.login-container button[type="submit"]:active {
    transform: translateY(0);
}

.login-container button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-container .error {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.login-container .error.show {
    display: block;
}

.login-container .rate-limit-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
    font-size: 14px;
}

.login-container .rate-limit-warning.show {
    display: block;
}

.login-container .loading {
    display: none;
    text-align: center;
    margin-top: 10px;
}

.login-container .loading.show {
    display: block;
}

.login-container .spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.login-dark-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        width: 100%;
    }

    .nav-tabs {
        width: 100%;
    }

    .nav-tab {
        flex: 1;
        text-align: center;
    }

    .header-buttons {
        width: 100%;
        justify-content: flex-end;
    }

    .stammdaten-actions {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .action-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .action-buttons .btn {
        flex: 1;
    }

    .tab-switcher {
        flex-direction: column;
    }
}
