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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    border-radius: 12px 12px 0 0;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.controls {
    background: #f5f5f5;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.controls h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: #333;
}

.filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

label input[type="number"],
label input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
}

label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
}

button:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

.table-wrapper {
    overflow-x: visible;
    padding: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

thead {
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
}

/* La fila de columnas queda fija arriba al hacer scroll */
thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
}

td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: #f9f9f9;
}

tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.status-open {
    color: #4caf50;
    font-weight: 600;
}

.status-closed {
    color: #ff9800;
    font-weight: 600;
}

.loading {
    text-align: center;
    color: #999;
    font-style: italic;
}

.checks-cell {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.check-btn {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 4px;
    background: #e0e0e0;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.check-btn.checked {
    background: #4caf50;
    color: white;
}

.check-btn:hover {
    transform: scale(1.05);
}

.time-cell {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #666;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    label {
        width: 100%;
    }

    label input,
    button {
        width: 100%;
    }

    /* Los botones DENTRO de la tabla no deben estirarse al 100% */
    table td button {
        width: auto;
    }

    .table-wrapper {
        padding: 10px;
        overflow-x: visible;
    }

    /* La cabecera de la tabla se oculta: cada fila pasa a ser una ficha */
    table thead {
        display: none;
    }

    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 14px;
        border: 1px solid #e0e0e0;
        border-radius: 10px;
        padding: 6px 4px;
        background: white;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    }

    tbody tr:nth-child(even) {
        background-color: white;
    }

    /* Cada celda: etiqueta a la izquierda (del data-label) y valor a la derecha */
    table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 12px;
        border-bottom: 1px solid #f0f0f0;
        text-align: right;
        font-size: 1.05em;
    }

    table td:last-child {
        border-bottom: none;
    }

    table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #667eea;
        text-align: left;
        flex-shrink: 0;
    }

    /* La celda del vuelo (con foto e insignias) alineada a la izquierda */
    table td[data-label="Vuelo"] {
        text-align: left;
    }
    .callsign-cell {
        justify-content: flex-end;
    }

    .checks-cell {
        justify-content: flex-end;
    }

    .btn-photo {
        min-width: 40px;
        min-height: 36px;
        font-size: 1.2em;
    }
}

/* Badge LOCAL para Boadilla */
.badge-local {
    display: inline-block;
    background: #ff6b6b;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    margin-left: 8px;
    animation: pulse 2s infinite;
}

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

/* Botón visual (humo) */
.check-btn[data-check="visual"] {
    background: #9ca3af;
}

.check-btn[data-check="visual"].checked {
    background: #6366f1;
    color: white;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6);
}

.check-btn[data-check="visual"]:hover {
    background: #6b7280;
}

/* ===== Cabecera con grid: stats izquierda, mapa derecha ===== */
.header-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: center;
    margin-top: 20px;
}

/* Cuadro de estadísticas */
.stats-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-card {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.25);
}

.stat-value {
    font-size: 1.6em;
    font-weight: 700;
    color: white;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.78em;
    color: rgba(255,255,255,0.85);
    margin-top: 4px;
}

/* Botón de mapa grande a la derecha */
.map-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.map-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(255,255,255,0.95);
    color: #4c1d95;
    text-decoration: none;
    padding: 20px 28px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1em;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-width: 130px;
}

.map-button:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 10px 28px rgba(0,0,0,0.35);
}

.map-icon { font-size: 2.4em; }

.usage-line {
    font-size: 0.75em;
    text-align: center;
    color: white;
    line-height: 1.4;
}

/* ===== Paginación ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: #764ba2;
}

.pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

#pageInfo {
    font-weight: 600;
    color: #4c1d95;
}

.page-size-label {
    font-size: 0.9em;
    color: #555;
}

.page-size-label select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

/* Responsive: en móvil, stats y mapa en columna */
@media (max-width: 900px) {
    .header-grid {
        grid-template-columns: 1fr;
    }
    .stats-box {
        grid-template-columns: repeat(2, 1fr);
    }
    .map-button {
        flex-direction: row;
    }
}

/* ===== Columna Visual ===== */
.visual-col { text-align: center; }

.visual-tag {
    display: inline-block;
    background: #6366f1;
    color: white;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 0.82em;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    white-space: nowrap;
}

.mark-visual-btn {
    padding: 6px 12px;
    font-size: 0.82em;
    border: 1px dashed #9ca3af;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mark-visual-btn:hover {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
}

/* Enlace de cerrar sesión */
.logout-link {
    color: rgba(255,255,255,0.9);
    font-size: 0.8em;
    text-decoration: none;
    background: rgba(255,255,255,0.15);
    padding: 5px 12px;
    border-radius: 6px;
    transition: background 0.2s ease;
}
.logout-link:hover {
    background: rgba(255,255,255,0.3);
}


/* Píldora de navegación (dashboard, etc.) */
.nav-pill {
    display: inline-block;
    color: #4c1d95;
    background: rgba(255,255,255,0.95);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}
.nav-pill:hover { transform: translateY(-2px); }


/* ===== Badges de etiquetas automáticas ===== */
.tag-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 700;
    margin-left: 4px;
    white-space: nowrap;
    color: white;
}
.tag-militar      { background: #3f6212; }
.tag-heli         { background: #0e7490; }
.tag-estado       { background: #6d28d9; }
.tag-desconocido  { background: #6b7280; }
.tag-raro         { background: #be185d; }
.tag-holding      { background: #c2410c; }
.tag-baja         { background: #b45309; }
.tag-otro         { background: #475569; }

/* ===== Modal de foto de aeronave (responsive) ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.modal-overlay.show {
    display: flex;
}
.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: #e0e0e0; }

.photo-container {
    position: relative;
    width: 100%;
    max-height: 400px;
    margin-bottom: 16px;
}
.photo-image {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    display: none;
}
.photo-image.show { display: block; }
.photo-placeholder {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background: #f5f5f5;
    border-radius: 8px;
    color: #999;
}
.photo-placeholder.show { display: block; }
.photo-loading {
    display: none;
    text-align: center;
    padding: 30px 20px;
    color: #667eea;
    font-weight: 600;
}
.photo-loading.show { display: block; }

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.btn-secondary {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ccc;
    background: white;
    color: #555;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: background 0.2s;
}
.btn-secondary:hover { background: #f5f5f5; }

/* En móvil: la modal ocupa casi toda la pantalla */
@media (max-width: 600px) {
    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        padding: 16px;
    }
    .photo-container {
        max-height: 300px;
    }
}

/* Celda de vuelo (callsign + insignias + foto) */
.callsign-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* Botón de foto en el listado */
.btn-photo {
    background: #eef1fb;
    border: 1px solid #d9def5;
    font-size: 1.05em;
    cursor: pointer;
    min-width: 34px;
    min-height: 30px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.btn-photo:hover { background: #dfe4f8; }
.btn-photo:active { background: #cfd6f4; }

/* ===== Control de auto-actualización ===== */
.auto-refresh-row {
    align-items: center;
    gap: 18px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px dashed #ddd;
}
.switch-label, .interval-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    color: #444;
}
.interval-label input[type="number"] {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
}

/* Interruptor deslizante */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: background 0.25s;
}
.slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .slider {
    background: #4caf50;
}
.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.refresh-status {
    font-size: 0.88em;
    color: #999;
    font-weight: 600;
}
.refresh-status.active {
    color: #4caf50;
}

/* Celda de fecha en el listado */
.date-cell { white-space: nowrap; font-size: 0.92em; color: #555; }

/* Insignia de zona propia del usuario */
.badge-zone {
    display: inline-block; background: #2e7d32; color: #fff;
    font-size: 0.7em; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap;
}

/* Controles de visibilidad de marcas (Fase 3) */
.vis-toggle { cursor: pointer; font-size: 0.95em; margin-left: 2px; user-select: none; opacity: 0.85; }
.vis-toggle:hover { opacity: 1; transform: scale(1.15); }
.mark-btn {
    padding: 5px 10px; border: 1px dashed #bbb; background: white; border-radius: 6px;
    cursor: pointer; font-size: 0.82em; color: #667eea; font-weight: 600;
}
.mark-btn:hover { background: #f5f3ff; border-color: #667eea; }

/* Nombres de marcadores públicos (enlace al perfil) */
.mark-by { font-size: 0.72em; color: #888; margin-top: 3px; }
.mark-by .mark-name { color: #667eea; text-decoration: none; font-weight: 600; }
.mark-by .mark-name:hover { text-decoration: underline; }

/* Origen/destino estimado de una estela */
.route-line { font-size: 0.72em; color: #667eea; margin-top: 3px; font-weight: 600; }
