:root {
    --primary-color: #e65100; /* Naranja corporativo profundo */
    --secondary-color: #fb8c00; /* Naranja claro */
    --accent-color: #ffb74d; /* Naranja vibrante/acento */
    --bg-color: #f4f7f6; /* Fondo gris muy claro */
    --surface-color: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);
    /* Sticky no invasivo */
    position: sticky;
    top: 0;
    z-index: 999;
    transition: padding 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
    will-change: padding, box-shadow;
}
.navbar.scrolled {
    padding: 0.55rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    background: linear-gradient(135deg, rgba(230, 81, 0, 0.96), rgba(245, 124, 0, 0.96));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s ease;
}
.navbar.scrolled .navbar-brand img {
    transform: scale(0.85);
}
.navbar-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}
.navbar-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}
.navbar-nav a:hover {
    color: white;
    text-shadow: 0 0 8px rgba(255,255,255,0.5);
}

/* Cards (Glassmorphism & Clean) */
.card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.5);
}
.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}
.card-title {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: #bf360c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230, 81, 0, 0.3);
}
.btn-secondary {
    background-color: #e0e0e0;
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #d5d5d5;
}
.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { background-color: #43a047; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: #e53935; }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    background-color: #f8f9fa;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}
.table tbody tr:hover {
    background-color: rgba(230, 81, 0, 0.03);
}

/* Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pendiente { background-color: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.badge-aprobado { background-color: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }
.badge-pagado { background-color: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.badge-comprobacion-enviada { background-color: #f3e5f5; color: #6a1b9a; border: 1px solid #e1bee7; }
.badge-revision-contable { background-color: #e1f5fe; color: #0277bd; border: 1px solid #b3e5fc; }
.badge-cerrado { background-color: #eceff1; color: #455a64; border: 1px solid #cfd8dc; }
.badge-rechazado { background-color: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.badge-cancelado { background-color: #424242; color: #ffffff; border: 1px solid #212121; }

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}
.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: var(--transition);
    box-sizing: border-box;
}
.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(251, 140, 0, 0.1);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}
.alert-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 40px;
    margin: 2rem 0;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-color);
}
.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -40px;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--surface-color);
    border: 3px solid var(--secondary-color);
}
.timeline-item.active::before {
    background-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(251, 140, 0, 0.2);
}
.timeline-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.timeline-content {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* ---------------------------------------------------
   LOADING OVERLAY & MAIL ANIMATION
   --------------------------------------------------- */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.mail-animation-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mail-icon-envelope {
    font-size: 5.5rem;
    color: var(--primary-color);
    position: absolute;
    z-index: 2;
    animation: envelopePulse 2.5s infinite ease-in-out;
}

.mail-icon-plane {
    font-size: 3rem;
    color: var(--secondary-color);
    position: absolute;
    z-index: 1;
    opacity: 0;
    animation: planeFly 2.5s infinite ease-in-out;
}

#loading-overlay h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    text-align: center;
}

#loading-overlay p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

@keyframes envelopePulse {
    0% { transform: scale(1); }
    10% { transform: scale(0.95); }
    20% { transform: scale(1.05); }
    30% { transform: scale(1); }
    100% { transform: scale(1); }
}

@keyframes planeFly {
    0% { transform: translate(-10px, 20px) scale(0.5); opacity: 0; }
    20% { transform: translate(-10px, 20px) scale(0.5); opacity: 0; }
    30% { opacity: 1; }
    60% { transform: translate(60px, -60px) scale(1.1); opacity: 1; }
    80% { transform: translate(100px, -100px) scale(1.3); opacity: 0; }
    100% { opacity: 0; }
}
