:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #16161f;
    --border-color: #2a2a3a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    line-height: 1.5;
    overscroll-behavior: none;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.app-container { display: flex; min-height: 100vh; }

/* Desktop Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    margin-bottom: 32px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-section { margin-bottom: 24px; }

.nav-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 14px;
}

.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: var(--accent-gradient); color: white; }
.nav-item svg { width: 20px; height: 20px; opacity: 0.8; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.nav-item-text { display: inline; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    max-width: calc(100vw - 260px);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    gap: 16px;
}

.page-title { font-size: 28px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
    text-decoration: none;
    min-height: 44px;
    white-space: nowrap;
}

.btn-primary { background: var(--accent-gradient); color: white; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-card); border-color: var(--text-muted); }
.btn-group { display: flex; gap: 12px; flex-wrap: wrap; }

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

/* FAB - Floating Action Button for mobile */
.fab {
    display: none;
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 99;
    align-items: center;
    justify-content: center;
}

.fab svg { width: 24px; height: 24px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

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

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

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.2s;
}

.stat-card:hover { border-color: var(--accent-primary); transform: translateY(-2px); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 20px;
}

.stat-icon.flights { background: rgba(99, 102, 241, 0.15); color: #6366f1; }
.stat-icon.distance { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.stat-icon.countries { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.stat-icon.airlines { background: rgba(236, 72, 153, 0.15); color: #ec4899; }
.stat-icon.aircraft { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.stat-icon.time { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }

.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { color: var(--text-secondary); font-size: 14px; }

.stat-card-wide { grid-column: span 2; }

.stat-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 10px;
    font-size: 18px;
    line-height: 1;
}

.flag-emoji {
    cursor: default;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
    display: inline-block;
}

/* Distance Stats */
.distance-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.distance-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.distance-stat-card.highlight {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: rgba(99, 102, 241, 0.3);
}

.distance-stat-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.distance-stat-content {
    flex: 1;
    min-width: 0;
}

.distance-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.distance-stat-route {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.distance-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-secondary);
    margin-bottom: 2px;
}

.distance-stat-meta {
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    .distance-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .distance-stat-card {
        padding: 14px;
    }
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.chart-container { height: 300px; position: relative; }

/* Desktop Table */
.flights-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.flights-table { width: 100%; border-collapse: collapse; }

.flights-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.flights-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.flights-table tbody tr { transition: background 0.15s; }
.flights-table tbody tr:hover { background: var(--bg-tertiary); }

.route-cell { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.route-from, .route-to { font-weight: 500; }
.route-arrow { color: var(--text-muted); font-size: 18px; }

.airline-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.aircraft-type { color: var(--text-secondary); font-size: 13px; }

/* Mobile Flight Cards (hidden on desktop) */
.flight-cards { display: none; }

.flight-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

.flight-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.flight-card-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.flight-card-year {
    font-size: 11px;
    color: var(--text-muted);
}

.flight-card-actions {
    display: flex;
    gap: 4px;
}

.flight-card-route {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.flight-card-route .route-arrow {
    font-size: 16px;
}

.flight-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.flight-card-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
}

.flight-card-tag.airline {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-secondary);
}

/* Filters */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    min-height: 48px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.filter-select {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    min-width: 140px;
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23606070' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.filter-select:focus { outline: none; border-color: var(--accent-primary); }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    padding: 20px;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover { background: var(--bg-card); color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
}

/* Form */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full-width { grid-column: span 2; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.form-input {
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
    min-height: 48px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

/* Page sections */
.page-section { display: none; }
.page-section.active { display: block; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1001;
    max-width: calc(100vw - 40px);
    text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

/* Action buttons */
.action-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover, .action-btn:active { background: var(--bg-tertiary); color: var(--text-primary); }
.action-btn.delete:hover, .action-btn.delete:active { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* Top Routes List */
.route-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

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

.route-list-rank {
    color: var(--text-muted);
    font-size: 14px;
    min-width: 28px;
}

.route-list-count {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    white-space: nowrap;
}

/* ==================== */
/* MAP STYLES           */
/* ==================== */
.map-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: calc(100vh - 280px);
    min-height: 400px;
}

#flightMap {
    width: 100%;
    height: 100%;
    background: #1a1a2e;
}

.map-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.map-filters .filter-select {
    min-width: 140px;
}

.map-stats {
    display: flex;
    gap: 16px;
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 14px;
}

.map-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.map-stats span::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
}

.map-stats span:last-child::before {
    background: var(--success);
}

/* Leaflet customizations */
.leaflet-container {
    background: #1a1a2e;
    font-family: 'Inter', sans-serif;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.leaflet-popup-content {
    margin: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.leaflet-popup-tip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-tertiary) !important;
}

.leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.leaflet-control-attribution {
    background: rgba(22, 22, 31, 0.8) !important;
    color: var(--text-muted) !important;
    font-size: 10px;
}

.leaflet-control-attribution a {
    color: var(--accent-secondary) !important;
}

/* Airport marker */
.airport-marker {
    background: var(--accent-primary);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Flight popup */
.flight-popup {
    min-width: 180px;
}

.flight-popup-route {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.flight-popup-info {
    color: var(--text-secondary);
    font-size: 12px;
}

.flight-popup-info div {
    margin-bottom: 4px;
}

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

.airport-popup-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.airport-popup-code {
    color: var(--accent-secondary);
    font-size: 13px;
    margin-bottom: 6px;
}

.airport-popup-count {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ==================== */
/* INLINE EDITOR        */
/* ==================== */
.inline-editor {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 260px;
    max-height: 320px;
    z-index: 1000;
    overflow: hidden;
}

.inline-editor.active {
    display: block;
}

.inline-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.inline-editor-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.inline-editor-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.inline-editor-close:hover {
    color: var(--text-primary);
}

.inline-editor-search {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.inline-editor-search::placeholder {
    color: var(--text-muted);
}

.inline-editor-options {
    max-height: 180px;
    overflow-y: auto;
}

.inline-editor-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.inline-editor-option:hover {
    background: var(--bg-tertiary);
}

.inline-editor-option.selected {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-secondary);
}

.inline-editor-option-clear {
    color: var(--text-muted);
    font-style: italic;
}

.inline-editor-add {
    display: none;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-top: 1px solid var(--border-color);
    color: var(--accent-secondary);
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.inline-editor-add.visible {
    display: flex;
}

.inline-editor-add:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Editable airline badge */
.airline-badge.editable {
    cursor: pointer;
    transition: all 0.15s;
}

.airline-badge.editable:hover {
    background: var(--accent-primary);
    color: white;
}

.airline-badge.editable.empty {
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}

.airline-badge.editable.empty:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    background: rgba(99, 102, 241, 0.1);
}

/* Editable code badge */
.code-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
    margin-left: 4px;
}

.code-badge:hover {
    background: var(--accent-primary);
    color: white;
}

.code-badge.empty {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-weight: 400;
    font-size: 10px;
}

.code-badge.empty:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    background: rgba(99, 102, 241, 0.1);
}

/* Flight card tag editable */
.flight-card-tag.editable {
    cursor: pointer;
}

.flight-card-tag.editable:hover {
    background: var(--accent-primary);
    color: white;
}

.flight-card-tag.editable.empty {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
}

.flight-card-tag.editable.empty:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    background: rgba(99, 102, 241, 0.1);
}

/* Editable table field */
.editable-field {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
    display: inline-block;
}

.editable-field:hover {
    background: var(--accent-primary);
    color: white;
}

.editable-field.empty {
    color: var(--text-muted);
    font-style: italic;
    background: transparent;
    border: 1px dashed var(--border-color);
    font-size: 12px;
}

.editable-field.empty:hover {
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    background: rgba(99, 102, 241, 0.1);
    font-style: normal;
}

/* ==================== */
/* TABLET STYLES        */
/* ==================== */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==================== */
/* MOBILE STYLES        */
/* ==================== */
@media (max-width: 768px) {
    /* Hide desktop sidebar */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 8px 8px calc(8px + var(--safe-bottom));
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: var(--bg-secondary);
        z-index: 100;
    }

    .logo { display: none; }
    .nav-section { margin-bottom: 0; display: contents; }
    .nav-label { display: none; }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        font-size: 11px;
        min-width: 64px;
        border-radius: var(--radius-md);
    }

    .nav-item svg { width: 24px; height: 24px; }
    .nav-item-text { display: block; }

    /* Main content adjustments */
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 16px;
        padding-bottom: calc(100px + var(--safe-bottom));
    }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 20px;
    }

    .page-header .btn { display: none; }

    .page-title { font-size: 24px; }
    .page-subtitle { font-size: 13px; }

    /* Show FAB on mobile */
    .fab { display: flex; }

    /* Stats grid - 2 columns on mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-bottom: 12px;
    }

    .stat-value { font-size: 24px; }
    .stat-label { font-size: 12px; }

    /* Charts */
    .charts-grid {
        gap: 16px;
        margin-bottom: 20px;
    }

    .chart-container { height: 250px; }

    .card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Hide table, show cards */
    .flights-table-container { display: none; }
    .flight-cards { display: block; }

    /* Filters */
    .filters-bar {
        flex-direction: column;
        gap: 12px;
    }

    .search-wrapper {
        min-width: 100%;
    }

    .filter-select {
        width: 100%;
        min-width: 100%;
    }

    /* Modal - full screen on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 16px 20px;
        padding-bottom: calc(16px + var(--safe-bottom));
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .form-group.full-width { grid-column: span 1; }

    /* Toast position */
    .toast {
        bottom: calc(100px + var(--safe-bottom));
        left: 20px;
        right: 20px;
        transform: translateX(0) translateY(100px);
        max-width: none;
    }

    .toast.show {
        transform: translateX(0) translateY(0);
    }

    /* Route cell stacking */
    .flight-card-route {
        flex-wrap: wrap;
    }

    /* Button groups stack */
    .btn-group {
        width: 100%;
    }

    .btn-group .btn {
        flex: 1;
    }

    /* Route list items */
    .route-list-item {
        flex-wrap: wrap;
    }

    .route-list-item .route-cell {
        flex: 1;
        min-width: 0;
    }

    /* Map mobile styles */
    .map-container {
        height: calc(100vh - 240px);
        min-height: 350px;
        border-radius: var(--radius-md);
    }

    .map-filters {
        gap: 8px;
    }

    .map-filters .filter-select {
        min-width: 100%;
        flex: 1;
    }

    .map-stats {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        margin-top: 4px;
    }
}

/* ==================== */
/* SMALL MOBILE         */
/* ==================== */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 14px;
    }

    .stat-icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .stat-content {
        flex: 1;
    }

    .stat-value {
        font-size: 22px;
    }

    .nav-item {
        padding: 8px 8px;
        min-width: 56px;
        font-size: 10px;
    }

    .nav-item svg {
        width: 22px;
        height: 22px;
    }
}

/* Landscape phone adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .modal {
        max-height: 100vh;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Dark mode form inputs for iOS */
@supports (-webkit-touch-callout: none) {
    input[type="date"] {
        -webkit-appearance: none;
    }

    select {
        -webkit-appearance: none;
    }
}

/* Trends */
.trends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.trend-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.trend-year {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
}

.trend-count {
    color: var(--text-secondary);
    flex: 1;
}

.trend-up { color: #22c55e; font-weight: 500; }
.trend-down { color: #ef4444; font-weight: 500; }
.trend-neutral { color: var(--text-muted); }

/* Airlines & Alliances */
.airlines-alliances-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.airline-alliance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.airline-name {
    font-weight: 500;
    color: var(--text-primary);
}

.alliance-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* Seat Map */
.seatmap-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.seatmap-card {
    min-height: 600px;
}

.plane-container {
    display: flex;
    justify-content: center;
    padding: 30px 20px;
}

.plane-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #2d2d3a 0%, #1e1e28 100%);
    border-radius: 50px 50px 20px 20px;
    padding: 20px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.plane-nose {
    width: 120px;
    height: 60px;
    background: linear-gradient(180deg, #3d3d4a 0%, #2d2d3a 100%);
    border-radius: 60px 60px 0 0;
    margin-bottom: 10px;
    position: relative;
}

.plane-nose::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 25px;
    background: rgba(99, 102, 241, 0.3);
    border-radius: 30px 30px 0 0;
}

.plane-tail {
    width: 80px;
    height: 40px;
    background: linear-gradient(0deg, #3d3d4a 0%, #2d2d3a 100%);
    border-radius: 0 0 40px 40px;
    margin-top: 10px;
}

.cabin {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
}

.seat-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.row-number {
    width: 24px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
}

.seat {
    width: 28px;
    height: 28px;
    border-radius: 6px 6px 4px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    cursor: default;
    transition: transform 0.2s;
    border: 1px solid rgba(255,255,255,0.1);
}

.seat:hover {
    transform: scale(1.15);
    z-index: 10;
}

.seat.cold { background: #374151; color: #9ca3af; }
.seat.cool { background: #3b82f6; color: white; }
.seat.warm { background: #f59e0b; color: white; }
.seat.hot { background: #ef4444; color: white; box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }

.seat.aisle { margin: 0 8px; }

.seatmap-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.hot { background: #ef4444; }
.legend-color.warm { background: #f59e0b; }
.legend-color.cool { background: #3b82f6; }
.legend-color.cold { background: #374151; }

.seat-stats-grid {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.seat-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.seat-stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.seat-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

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

/* ==================== */
/* SORTABLE HEADERS     */
/* ==================== */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.sortable:hover {
    background: var(--bg-tertiary);
}

.sort-icon::after {
    content: '↕';
    margin-left: 6px;
    opacity: 0.4;
    font-size: 12px;
}

.sortable.sort-asc .sort-icon::after {
    content: '↑';
    opacity: 1;
    color: var(--accent-secondary);
}

.sortable.sort-desc .sort-icon::after {
    content: '↓';
    opacity: 1;
    color: var(--accent-secondary);
}

/* ==================== */
/* CO2 BADGES           */
/* ==================== */
.co2-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.co2-badge.co2-low {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.co2-badge.co2-medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.co2-badge.co2-high {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.co2-badge.co2-very-high {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.stat-icon.co2 {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.distance-cell {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

/* ==================== */
/* ENVIRONMENTAL STATS  */
/* ==================== */
.env-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.env-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.env-stat-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.env-stat-content {
    flex: 1;
    min-width: 0;
}

.env-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.env-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.env-stat-meta {
    font-size: 11px;
    color: var(--text-muted);
}

@media (max-width: 1200px) {
    .env-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .env-stat-card {
        padding: 14px;
    }
}

/* Flight card stats row */
.flight-card-stats {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.flight-card-stat {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==================== */
/* FLIGHT FREQUENCY     */
/* ==================== */
.freq-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.freq-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.freq-stat-card.overdue-card {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
}

.freq-stat-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.freq-stat-content {
    flex: 1;
    min-width: 0;
}

.freq-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.freq-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.freq-stat-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.freq-stat-meta .overdue {
    color: #ef4444;
    font-weight: 500;
}

.freq-by-year {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.freq-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.freq-year-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.freq-year-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.freq-year {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
}

.freq-value {
    color: var(--accent-secondary);
    font-weight: 500;
}

.freq-flights {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}

@media (max-width: 1200px) {
    .freq-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .freq-stat-card {
        padding: 14px;
    }

    .freq-year-list {
        grid-template-columns: 1fr;
    }
}
