/* =============================================
   SKYLINE AVIATION — Design System
   ============================================= */

/* ---------- Tokens (Light Mode) ---------- */
:root {
    --primary: #2563eb;
    --primary-dark: #1e3a8a;
    --primary-light: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --border-light: rgba(229, 231, 235, 0.5);
    --text: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.92);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --radius-full: 9999px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 200ms ease;
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-alt: #162032;
    --border: #334155;
    --border-light: rgba(51, 65, 85, 0.5);
    --text: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --glass-bg: rgba(30, 41, 59, 0.95);
    --glass-border: rgba(51, 65, 85, 0.6);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.6);
}

[data-theme="dark"] .card {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .input,
[data-theme="dark"] .select {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .autocomplete-list {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="dark"] .autocomplete-item:hover { background: #1e293b; }

[data-theme="dark"] .tabs { background: #1e293b; }

[data-theme="dark"] .aircraft-card {
    background: var(--surface-alt);
    border-color: var(--border);
}

[data-theme="dark"] .modal-content {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .aircraft-form {
    background: var(--surface-alt);
}

/* btn-dark usa --text como fundo; no dark mode --text fica claro, então fixamos a cor */
[data-theme="dark"] .btn-dark {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
}
[data-theme="dark"] .btn-dark:hover:not(:disabled) {
    background: #334155;
}

/* Dark mode para controles Leaflet */
[data-theme="dark"] .leaflet-control-layers {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] .leaflet-control-layers label {
    color: #f1f5f9 !important;
}

/* Preferência automática do sistema (sobrescrita pelo toggle) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg: #0f172a;
        --surface: #1e293b;
        --surface-alt: #162032;
        --border: #334155;
        --border-light: rgba(51, 65, 85, 0.5);
        --text: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --text-faint: #64748b;
        --glass-bg: rgba(30, 41, 59, 0.95);
        --glass-border: rgba(51, 65, 85, 0.6);
    }
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    min-height: 100vh;
}

::selection { background: var(--primary); color: white; }
input, select, button { font-family: var(--font); }

/* ---------- Glass ---------- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

/* ---------- Inputs ---------- */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input::placeholder { color: var(--text-faint); font-weight: 500; }
/* Normaliza input[type=date] no iOS — evita altura maior que outros campos */
input[type="date"].input {
    -webkit-appearance: none;
    appearance: none;
    min-height: unset;
    line-height: normal;
    box-sizing: border-box;
}
.input-green:focus { border-color: var(--accent-green); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12); }
.input-blue:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.input-orange:focus { border-color: var(--accent-orange); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12); }
.input-error { border-color: var(--accent-red) !important; }

.input-green { color: var(--accent-green); }
.input-blue { color: var(--primary); }
.input-orange { color: var(--accent-orange); }

.select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    background: var(--surface);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}
.select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.label {
    display: block;
    font-size: 0.625rem;
    font-weight: 800;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-left: 0.5rem;
    margin-bottom: 0.25rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-success { background: var(--accent-green); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-danger { background: var(--accent-red); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-dark { background: var(--text); color: white; }
.btn-dark:hover:not(:disabled) { background: #1e293b; transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.btn-outline {
    background: transparent;
    border: 2px dashed var(--border);
    color: var(--text-faint);
    font-size: 0.5625rem;
}
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary); }

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-faint);
    padding: 0.375rem;
}
.btn-ghost:hover { color: var(--accent-red); }

.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn-sm { padding: 0.5rem 0.875rem; font-size: 0.5625rem; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    padding: 1.25rem;
}

.card-dark {
    background: #0f172a;
    color: white;
    border-radius: var(--radius-2xl);
    padding: 1.5rem;
    border-bottom: 4px solid var(--primary);
    box-shadow: var(--shadow-xl);
}

.card-dark .card-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.card-dark .card-value {
    font-size: 1.875rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-top: 0.25rem;
}

.card-dark .card-sub {
    font-size: 0.6875rem;
    color: var(--text-faint);
    margin-top: 0.375rem;
    font-weight: 500;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: var(--radius-lg);
    gap: 0.125rem;
}

.tab {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    color: var(--text-muted);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ---------- Map ---------- */
#map {
    height: 100vh;
    width: 100%;
    z-index: 1;
    background: var(--surface-alt);
}

/* Botão toggle de mapas */
.leaflet-right.leaflet-bottom .leaflet-control-layers {
    margin-bottom: 85px !important;
    margin-right: 24px !important;
    z-index: 1000 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.leaflet-control-layers-toggle {
    width: 44px !important;
    height: 44px !important;
    background: white !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    cursor: pointer !important;
    transition: all 200ms ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
}

/* Ícone de losango/diamante */
.leaflet-control-layers-toggle::before {
    content: '' !important;
    position: absolute !important;
    width: 12px !important;
    height: 12px !important;
    border: 2px solid #2563eb !important;
    transform: rotate(45deg) !important;
    border-radius: 1px !important;
}

.leaflet-control-layers-toggle:hover {
    background: #f0f9ff !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15) !important;
}

/* Lista de camadas (ao abrir) */
.leaflet-control-layers-list {
    background: white !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12) !important;
    padding: 0.75rem !important;
    margin-top: 0.5rem !important;
    margin-left: 0 !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
}

.leaflet-control-layers label {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
    color: #334155 !important;
    cursor: pointer !important;
}

.leaflet-control-layers label:last-child {
    margin-bottom: 0 !important;
}

.leaflet-control-layers input {
    cursor: pointer !important;
}

/* Dark mode */
[data-theme="dark"] .leaflet-control-layers-toggle {
    background: #1e293b !important;
}

[data-theme="dark"] .leaflet-control-layers-toggle::before {
    border-color: #60a5fa !important;
}

[data-theme="dark"] .leaflet-control-layers-toggle:hover {
    background: #334155 !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2) !important;
}

[data-theme="dark"] .leaflet-control-layers-list {
    background: #1e293b !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .leaflet-control-layers label {
    color: #cbd5e1 !important;
}

/* ---------- Panels ---------- */
.side-panel {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    width: 24rem;
    max-height: 90vh;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 2rem;
    overflow-y: auto;
    z-index: 1000;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.side-panel::-webkit-scrollbar { width: 4px; }
.side-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---------- Panel Mobile Components (base — ocultos no desktop) ---------- */
.panel-drag-handle {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 0.625rem 0 0.25rem;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
}
.panel-drag-bar {
    width: 2.5rem;
    height: 0.25rem;
    background: var(--border);
    border-radius: var(--radius-full);
    transition: background var(--transition);
}
.panel-drag-handle:active .panel-drag-bar { background: var(--text-faint); }

.panel-sticky-header { /* desktop: fluxo normal */ }
.panel-scroll-body   { /* desktop: fluxo normal */ }

/* ---------- Form Sections ---------- */
.form-sections {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.form-section {
    padding: 1rem 0;
}
.form-section:first-child {
    padding-top: 0.25rem;
}
.form-section-title {
    font-size: 0.5625rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-faint);
    margin-bottom: 0.75rem;
}
.form-divider {
    height: 1px;
    background: var(--border);
    opacity: 0.6;
    margin: 0;
}

/* Manter painel com glassmorphism em ambos os mapas para melhor contraste e legibilidade */

.user-badge {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1100;
}

.user-badge-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
}

/* ---------- Autocomplete ---------- */
.autocomplete-wrapper { position: relative; }

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.25rem;
    display: none;
}
.autocomplete-list.visible { display: block; }

.autocomplete-item {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.autocomplete-item:hover { background: #f1f5f9; }
.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-icao {
    font-weight: 800;
    font-size: 0.8125rem;
    color: var(--primary);
}
.autocomplete-name {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ---------- Aircraft Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 300ms ease;
}
.modal-overlay.visible { opacity: 1; visibility: visible; }

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 32rem;
    max-height: 85vh;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(20px) scale(0.97);
    transition: transform 300ms ease;
    display: flex;
    flex-direction: column;
}
.modal-overlay.visible .modal-content { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
}

.modal-footer {
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--border);
}

/* Aircraft card inside modal */
.aircraft-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface-alt);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 0.625rem;
    transition: all var(--transition);
}
.aircraft-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); }

.aircraft-info h4 {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
}
.aircraft-info p {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}
.aircraft-info .aircraft-reg {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.5625rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-top: 0.375rem;
}

.aircraft-actions { display: flex; gap: 0.375rem; }

/* Aircraft form in modal */
.aircraft-form {
    display: none;
    padding: 1.25rem;
    background: var(--surface-alt);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--primary-light);
    margin-top: 0.75rem;
}
.aircraft-form.visible { display: block; }
.aircraft-form .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.aircraft-form .form-full { grid-column: 1 / -1; }
.aircraft-form .form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* ---------- Toast ---------- */
.sky-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: var(--shadow-xl);
    transition: transform 300ms ease, opacity 300ms ease;
    opacity: 0;
    max-width: 90vw;
}
.sky-toast.visible { transform: translateX(-50%) translateY(0); opacity: 1; }
.sky-toast-info { background: var(--primary); color: white; }
.sky-toast-success { background: var(--accent-green); color: white; }
.sky-toast-error { background: var(--accent-red); color: white; }
.sky-toast-warning { background: var(--accent-orange); color: white; }
.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0;
}
.toast-close:hover { opacity: 1; }

/* ---------- Spinner ---------- */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-dark { border-color: rgba(0,0,0,0.1); border-top-color: var(--primary); }

.loading-ring {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

/* ---------- Windy Modal ---------- */
.windy-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.windy-container {
    background: var(--surface);
    width: 100%;
    max-width: 72rem;
    height: 80vh;
    border-radius: var(--radius-2xl);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-xl);
}

/* ---------- Float Buttons ---------- */
.float-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1050;
}

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fade-in { animation: fadeIn 400ms ease; }
.animate-slide-up { animation: slideUp 400ms ease; }
.animate-pulse { animation: pulse 2s infinite; }

/* ---------- Print / Export PDF ---------- */
.print-area {
    display: none;
    /* Forçar cores claras independentemente do tema */
    --primary-dark: #003d82 !important;
    --primary-light: #2575d3 !important;
    --primary: #1a5fb4 !important;
    --accent-green: #10b981 !important;
    --accent-red: #ef4444 !important;
    --surface: #ffffff !important;
    --surface-alt: #f8f9fa !important;
    --text: #1f2937 !important;
    --text-secondary: #374151 !important;
    --text-muted: #6b7280 !important;
    --text-faint: #9ca3af !important;
    --border: #e5e7eb !important;
    --background: #ffffff !important;
    color: #1f2937 !important;
    background: white !important;
}

/* Garantir cores nos elementos do print-area */
.print-area .card {
    background: white !important;
    border: 2.5px solid #003d82 !important;
    border-radius: 16px !important;
}

.print-area h1, .print-area h2, .print-area h3, .print-area h4 {
    color: #003d82 !important;
}

.print-area p {
    color: #1f2937 !important;
}

.print-area svg {
    color: #003d82 !important;
}

.logo-panel { max-height: 35px; width: auto; object-fit: contain; }
.logo-pdf { max-height: 50px; width: auto; object-fit: contain; }

#pdf-map-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    object-position: center;
    background-color: var(--surface-alt);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    display: block;
}

/* Seção do mapa expande para preencher espaço disponível no A4 */
#pdf-map-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
#pdf-map-section #pdf-map-img {
    flex: 1;
    height: 100% !important;
    min-height: 120px;
}

.pdf-total-box {
    border: 5px solid #003d82 !important;
    padding: 0.4rem 1rem;
    border-radius: 1.25rem;
    background: white !important;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: auto;
}
.pdf-total-box h2 {
    line-height: 1;
    margin-bottom: 0.5rem;
    margin-top: 0;
    color: #003d82 !important;
}

.export-mode {
    display: flex !important;
    flex-direction: column;
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    /* A4 a 96 DPI: 210mm × 297mm = 794px × 1123px */
    width: 794px !important;
    height: 1123px !important;
    background: white !important;
    padding: 30px 38px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    z-index: -1;
    color: #1f2937 !important;
    font-family: 'Inter', sans-serif !important;
    /* Forçar cores claras para exportação */
    --primary-dark: #003d82 !important;
    --primary-light: #2575d3 !important;
    --primary: #1a5fb4 !important;
    --text: #1f2937 !important;
    --text-secondary: #374151 !important;
    --text-muted: #6b7280 !important;
    --text-faint: #9ca3af !important;
    --border: #e5e7eb !important;
    --surface: #ffffff !important;
    --surface-alt: #f8f9fa !important;
    --background: #ffffff !important;
}

@media print {
    :root {
        --background: #ffffff !important;
        --surface: #ffffff !important;
    }
    body {
        background-color: #ffffff !important;
        background: #ffffff !important;
    }
    @page {
        size: A4 portrait;
        margin: 0 !important;
    }
    html, body {
        width: 210mm !important;
        height: 280mm !important;
        max-height: 280mm !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
    }
    /* Remove todos os filhos diretos do body exceto o #print-area —
       visibility:hidden não remove do fluxo e gera segunda página no iOS */
    body > *:not(#print-area) { display: none !important; }
    #print-area {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        height: 280mm !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0.2cm 0.6cm !important;
        background: white !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    #print-area > * {
        flex-shrink: 0 !important;
    }
    #print-area #pdf-map-section {
        flex: 1 !important;
        flex-shrink: 1 !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    #print-area #pdf-map-img {
        flex: 1 !important;
        height: 100% !important;
        min-height: 80px !important;
        width: 100% !important;
        object-fit: cover !important;
    }
    .no-print { display: none !important; }

    /* ---- Mapa Leaflet inline (todos os dispositivos) ----
       _captureMapInline() move o #map real para dentro do print-area.
       A seção do mapa usa flex:1 para preencher o espaço disponível no A4.
       A ALTURA do #map NÃO é definida aqui — é controlada pelo estilo inline
       definido dinamicamente em JS (leitura do offsetHeight real após flex layout),
       garantindo que os tiles sejam carregados para as mesmas dimensões que
       serão usadas na impressão. */
    #print-area[data-inline-map] #pdf-map-section {
        flex: 1 !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
    }
    #print-area[data-inline-map] #map {
        /* SEM regra de height — o estilo inline do JS define a altura correta */
        width: 100% !important;
        display: block !important;
        position: relative !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        flex-shrink: 0 !important;
    }
    #print-area #map .leaflet-control-container,
    #print-area #map .leaflet-top,
    #print-area #map .leaflet-bottom {
        display: none !important;
    }
    #print-area #map .leaflet-tile {
        display: block !important;
    }
    #print-area #map .leaflet-pane {
        display: block !important;
    }
}

/* ---------- Login Page ---------- */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #312e81 100%);
    overflow: auto;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 26rem;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-2xl);
    padding: 2.5rem;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
    animation: slideUp 600ms ease;
}

.login-card .login-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    text-align: center;
    margin-bottom: 0.375rem;
}
.login-card .login-subtitle {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    margin-bottom: 2rem;
    font-weight: 500;
}

.login-card .input {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
    color: white;
}
.login-card .input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.login-card .input::placeholder { color: rgba(255,255,255,0.35); }

.login-card .label { color: rgba(255,255,255,0.5); }

.login-btn {
    width: 100%;
    padding: 0.875rem;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 0.5rem;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(37,99,235,0.35); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.login-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: rgba(255,255,255,0.25);
    font-size: 0.6875rem;
    font-weight: 600;
}
.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.1);
}

.login-toggle {
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}
.login-toggle a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}
.login-toggle a:hover { color: white; }

.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: none;
}
.login-error.visible { display: block; animation: slideUp 200ms ease; }

/* ---------- Botão toggle mobile ---------- */
#btn-toggle-panel {
    display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {

    /* Mostrar toggle apenas em smartphones (data-device definido pelo JS) */
    [data-device="smartphone"] #btn-toggle-panel {
        display: flex;
        position: fixed;
        bottom: calc(var(--panel-toggle-bottom, 45vh) + 0.75rem);
        left: 50%;
        transform: translateX(-50%);
        z-index: 1100;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: var(--radius-full);
        padding: 0.5rem 1.25rem;
        font-size: 0.625rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        cursor: pointer;
        box-shadow: var(--shadow-lg);
        transition: bottom 0.35s cubic-bezier(0.32,0.72,0,1);
        white-space: nowrap;
    }

    /* ── Bottom sheet (apenas smartphone) ── */
    [data-device="smartphone"] .side-panel {
        top: auto !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: none !important;
        border-radius: 1.5rem 1.5rem 0 0 !important;
        padding: 0 !important;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.2) !important;
        overflow: hidden !important;
        z-index: 1000;
        display: flex !important;
        flex-direction: column !important;
        height: var(--panel-h, 56vh) !important;
        transition: height 0.35s cubic-bezier(0.32,0.72,0,1) !important;
    }

    /* Estados do painel (definidos via data-panel-state pelo JS) */
    [data-device="smartphone"] .side-panel[data-panel-state="collapsed"] { --panel-h: 64px; }
    [data-device="smartphone"] .side-panel[data-panel-state="half"]      { --panel-h: 56vh; }
    [data-device="smartphone"] .side-panel[data-panel-state="expanded"]  { --panel-h: 88vh; }

    /* ── Alça de arraste ── */
    [data-device="smartphone"] .panel-drag-handle {
        display: flex;
        flex-shrink: 0;
    }

    /* ── Header fixo no topo do painel ── */
    [data-device="smartphone"] .panel-sticky-header {
        flex-shrink: 0;
        padding: 0.375rem 1rem 0.5rem;
        border-bottom: 1px solid var(--border-light);
        background: var(--glass-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        margin-bottom: 0 !important;
    }

    /* Ocultar header e corpo quando colapsado */
    [data-device="smartphone"] .side-panel[data-panel-state="collapsed"] .panel-sticky-header,
    [data-device="smartphone"] .side-panel[data-panel-state="collapsed"] .panel-scroll-body {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.15s ease;
    }
    [data-device="smartphone"] .side-panel:not([data-panel-state="collapsed"]) .panel-sticky-header,
    [data-device="smartphone"] .side-panel:not([data-panel-state="collapsed"]) .panel-scroll-body {
        opacity: 1;
        pointer-events: auto;
        transition: opacity 0.2s ease 0.1s;
    }

    /* ── Corpo scrollável do formulário ── */
    [data-device="smartphone"] .panel-scroll-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.625rem 1rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
    [data-device="smartphone"] .panel-scroll-body::-webkit-scrollbar { display: none; }

    /* ── Espaçamento compacto no formulário ── */
    [data-device="smartphone"] .form-section { padding: 0.5rem 0; }
    [data-device="smartphone"] .form-section-title { margin-bottom: 0.4rem; }
    [data-device="smartphone"] .space-y-3 > * + * { margin-top: 0.5rem !important; }
    [data-device="smartphone"] .mb-3 { margin-bottom: 0.5rem; }
    [data-device="smartphone"] .tabs { margin-bottom: 0.5rem !important; }
    /* Horários: empilhados verticalmente no celular para evitar overflow do input[type=time] */
    [data-device="smartphone"] .horarios-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    [data-device="smartphone"] .horario-field { flex-direction: row; align-items: center; gap: 0.625rem; }
    [data-device="smartphone"] .horario-field .label { flex: 0 0 auto; width: 7.5rem; margin: 0; }
    [data-device="smartphone"] .horario-field .input {
        flex: 1;
        min-width: 0;
        padding: 0.5rem 0.75rem;
        min-height: 40px;
    }
    /* font-size >= 16px evita zoom automático do iOS ao focar inputs */
    [data-device="smartphone"] .input,
    [data-device="smartphone"] .select,
    [data-device="smartphone"] input,
    [data-device="smartphone"] select,
    [data-device="smartphone"] textarea {
        font-size: 16px !important;
        padding: 0.6rem 0.875rem;
        min-height: 44px;
    }
    [data-device="smartphone"] .btn { min-height: 44px; }

    /* ── Botões flutuantes seguem a altura do painel ── */
    [data-device="smartphone"] .float-btn {
        bottom: calc(var(--panel-h, 56vh) + 0.75rem) !important;
        right: 0.75rem !important;
        transition: bottom 0.35s cubic-bezier(0.32,0.72,0,1) !important;
    }
    [data-device="smartphone"] .leaflet-bottom.leaflet-right {
        bottom: calc(var(--panel-h, 56vh) + 0.75rem) !important;
        transition: bottom 0.35s cubic-bezier(0.32,0.72,0,1) !important;
    }

    /* ── Outros ajustes ── */
    [data-device="smartphone"] .user-badge { top: 0.75rem !important; right: 0.75rem !important; }
    [data-device="smartphone"] .user-badge-inner { transform: scale(0.85); }
    .login-card { padding: 1.75rem; }
}

/* ---------- Botão Dark Mode ---------- */
#btn-dark-mode {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    border: 1.5px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}
#btn-dark-mode:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ---------- Modal Histórico ---------- */
.history-item {
    padding: 0.875rem 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 0.5rem;
    transition: all var(--transition);
}
.history-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}
.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}
.history-item-cliente {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}
.history-item-total {
    font-size: 0.875rem;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}
.history-item-meta {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.history-item-rota {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.375rem;
}
/* ---------- Barra de Filtros do Histórico ---------- */
.history-filter-bar {
    display: grid;
    grid-template-columns: 1fr 2fr 1.5fr auto;
    gap: 0.75rem;
    padding: 0.875rem 1.75rem 1rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    align-items: end;
}

.history-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-filter-input {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8125rem !important;
    border-radius: var(--radius-md) !important;
}

/* Remove setas do input number no Chrome */
.history-filter-input[type="number"]::-webkit-inner-spin-button,
.history-filter-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.history-filter-input[type="number"] { -moz-appearance: textfield; }

@media (max-width: 480px) {
    .history-filter-bar {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .history-filter-bar > :last-child {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    /* Aircraft card — empilha verticalmente em telas pequenas */
    .aircraft-card {
        flex-wrap: wrap;
        gap: 0.625rem;
    }
    .aircraft-card .aircraft-info {
        flex: 1 1 60%;
        min-width: 0;
    }
    .aircraft-card .aircraft-actions {
        flex: 0 0 auto;
        align-self: flex-end;
    }

    /* Formulário de aeronave — coluna única */
    .aircraft-form .form-grid {
        grid-template-columns: 1fr;
    }

    /* Histórico — cabeçalho do item quebra em duas linhas */
    .history-item-header {
        flex-wrap: wrap;
    }
    .history-item-cliente {
        flex: 1 1 100%;
    }
    .history-item-header > div {
        margin-left: auto;
    }
}

/* Botão PDF dentro do card de histórico */
.history-reprint-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary);
    font-size: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.history-reprint-btn:hover {
    background: var(--primary);
    color: white;
}

/* Botão excluir dentro do card de histórico */
.history-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-faint);
    font-size: 0.5rem;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.history-delete-btn:hover {
    border-color: var(--accent-red, #ef4444);
    color: var(--accent-red, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

.history-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-faint);
}
.history-empty svg { margin: 0 auto 0.75rem; display: block; }
.history-empty p { font-size: 0.8125rem; font-weight: 600; }
.history-empty small { font-size: 0.6875rem; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; }
.w-full { width: 100%; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }

/* Horários partida/chegada */
.horarios-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}
.horario-field { display: flex; flex-direction: column; gap: 0.25rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }

/* ---------- Aircraft Photo Upload ---------- */
#ac-foto, #ac-foto-interior {
    display: none;
}

/* Editor de posição da foto (exterior e interior compartilham o mesmo estilo) */
#foto-pos-container, #foto-interior-pos-container {
    width: 100%;
    aspect-ratio: 313 / 130;
    overflow: hidden;
    cursor: grab;
    border-radius: var(--radius-lg);
    border: 2px dashed var(--primary);
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
#foto-pos-container.pos-dragging,
#foto-interior-pos-container.pos-dragging { cursor: grabbing; }

#foto-pos-hint, #foto-interior-pos-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.55);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 100px;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.25s;
}
#foto-pos-container.pos-dragging #foto-pos-hint,
#foto-interior-pos-container.pos-dragging #foto-interior-pos-hint { opacity: 0; }

.ac-foto-btn {
    background: var(--primary-light);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.ac-foto-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#ac-foto-preview, #ac-foto-interior-preview {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    display: none;
    margin-top: 0.5rem;
}

#ac-foto-preview.visible, #ac-foto-interior-preview.visible {
    display: block;
}

/* Separador visual entre exterior e interior no formulário */
#secao-foto-interior {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

.aircraft-card-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    flex-shrink: 0;
    border: 1px solid var(--border);
    margin-right: 0.75rem;
}

#pdf-aeronave-img {
    width: 100%;
    height: 115px;
    object-fit: cover;
    object-position: center;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-top: 0.25rem;
    display: none;
}
