:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #475569;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --background: #0f172a;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-radius: 16px;
    --glass-blur: blur(12px);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    background-image:
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
}

#app-container {
    width: 100%;
    max-width: 600px;
    /* Mobile first, optimized for tablet/small desktop */
    min-height: 100vh;
    position: relative;
}

/* Glassmorphism Utilities */
.glass-card,
.glass-panel,
.glass-nav {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.glass-card {
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 1rem;
}

/* Views Management */
.view {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    width: 100%;
    min-height: 100vh;
}

.view.active-view {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

/* --- Login View --- */
#view-login {
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.logo-container {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.5));
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Forms & Inputs */
.input-group {
    position: relative;
    margin-bottom: 1.2rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.input-group select {
    appearance: none;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition);
    border-radius: 50%;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--surface-border);
}

.divider::before {
    margin-right: .5em;
}

.divider::after {
    margin-left: .5em;
}

.error-message {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* --- Dashboard Nav --- */
.glass-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-top: none;
    border-left: none;
    border-right: none;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.nav-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    font-size: 0.9rem;
}

.dashboard-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
}

/* Date & Location Header */
.dashboard-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.date-selector,
.location-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
}

.date-selector i,
.location-selector i {
    color: var(--primary);
}

.date-input,
.select-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
    outline: none;
    cursor: pointer;
}

.date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.start-flight-card h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.flight-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.radio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.radio-card input {
    display: none;
}

.radio-card i {
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.radio-card span {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.radio-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.radio-card.active {
    background: rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
}

.radio-card.active i,
.radio-card.active span {
    color: var(--primary);
}

.legal-checkbox {
    margin: 1.5rem 0;
}

.legal-checkbox label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legal-checkbox input {
    display: none;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--surface-border);
    border-radius: 4px;
    display: inline-block;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
    margin-top: 2px;
}

.legal-checkbox input:checked+.custom-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.legal-checkbox input:checked+.custom-checkbox::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Log Section */
.log-section {
    margin-top: 1rem;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.section-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.badge {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.flight-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.flight-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    transition: var(--transition);
}

.flight-item:hover {
    transform: translateX(4px);
}

.flight-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.flight-pilot {
    font-weight: 600;
    font-size: 1rem;
}

.flight-model {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.flight-time {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.time-badge {
    font-family: monospace;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-done {
    background: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    border: 1px dashed var(--surface-border);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    transform: translateX(120%);
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 400px;
    transform: translateY(-20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.2rem;
}

/* Profile Dropdown */
.profile-dropdown {
    position: relative;
}

.btn-profile-trigger {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-profile-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.profile-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 260px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 1rem;
    z-index: 200;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease;
}

.profile-menu-section h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.profile-field {
    margin-bottom: 0.5rem;
}

.profile-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.profile-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: var(--transition);
    border-radius: 24px;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

@media (max-width: 640px) {
    .glass-card {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        width: 100%;
        text-align: center;
    }
}

/* Analyse Table */
.analyse-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.analyse-table td {
    color: var(--text-primary);
}

.analyse-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 700px) {
    #panel-statistik .glass-panel canvas {
        max-height: 200px;
    }

    #panel-statistik>div:nth-child(2) {
        grid-template-columns: 1fr !important;
    }
}