:root {
    --bg-dark: #0f172a;
    --panel-glass: rgba(30, 41, 59, 0.7);
    --brand-accent: #10b981;
    --brand-accent-hover: #059669;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;

    /* Variables de tipografía y espaciado fluido (Responsive sin Media Queries excesivos) */
    --spacing-panel: clamp(1.5rem, 5vw, 3rem);
    --font-h1: clamp(1.5rem, 4vw, 2rem);
    --font-h2: clamp(1.25rem, 3vw, 1.75rem);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, sans-serif;
}

body.staff-layout {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100dvh;
    /* 'dvh' previene saltos por la barra de navegación móvil en iOS/Android */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Authentication Screens */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: clamp(1rem, 5vw, 2rem);
    /* Padding dinámico que evita colisión en móviles pequeños */
}

.glass-panel {
    background: var(--panel-glass);
    padding: var(--spacing-panel);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Soporte crítico para WebKit (iOS) */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.glass-panel-wide {
    max-width: 550px;
}

.brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-header h2 {
    color: var(--brand-accent);
    font-size: var(--font-h2);
}

.brand-header p {
    color: var(--text-muted);
    font-size: clamp(0.875rem, 2vw, 1rem);
    margin-top: 0.25rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.875rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    color: white;
    outline: none;
    transition: all 0.3s ease;
    font-size: 16px;
    /* Evita el zoom automático en inputs de iOS Safari */
}

.form-group input:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--brand-accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-accent-hover);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.875rem;
    white-space: nowrap;
}

.btn-danger:hover {
    background: #dc2626;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

.auth-links a {
    color: var(--brand-accent);
    text-decoration: none;
    transition: color 0.2s;
}

.auth-links a:hover {
    color: var(--brand-accent-hover);
    text-decoration: underline;
}

/* Dashboard UI */
.staff-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 5vw, 2.5rem);
    background: var(--panel-glass);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    /* Flujo elástico para pantallas muy pequeñas */
    gap: 1rem;
}

.staff-navbar .brand {
    font-size: clamp(1.1rem, 3vw, 1.25rem);
    font-weight: 700;
    display: flex;
    align-items: center;
}

.staff-navbar .badge {
    background: var(--brand-accent);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: white;
    margin-left: 0.5rem;
    letter-spacing: 0.5px;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1.5rem);
    flex-wrap: wrap;
}

#activeUserLabel {
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
    color: #cbd5e1;
}

.dashboard-core {
    padding: clamp(1.5rem, 5vw, 3rem);
    flex-grow: 1;
    width: 100%;
    max-width: 1440px;
    /* Limite ultra-wide */
    margin: 0 auto;
}

.dashboard-core header h2 {
    font-size: var(--font-h1);
    margin-bottom: 0.5rem;
}

.dashboard-core header p {
    font-size: clamp(0.9rem, 2vw, 1rem);
}

/* Grid Responsive Avanzado (No-Media-Query Math Technique) */
.grid-8-modules {
    display: grid;
    /* El algoritmo min() asegura que la tarjeta se encoja al 100% del padre si es menor a 260px, resolviendo overflows en < 320px */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: clamp(1rem, 3vw, 2rem);
}

.module-card {
    background: #1e293b;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.module-card:hover {
    transform: translateY(-5px);
    border-color: var(--brand-accent);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    background: #1e293b;
}

.module-card i {
    font-size: clamp(2rem, 5vw, 2.8rem);
    display: block;
    margin-bottom: 1rem;
    font-style: normal;
}

.module-card h3 {
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    font-weight: 600;
    color: #f1f5f9;
}

/* Degradación elegante para resoluciones hostiles (Smartphones legacy en portrait) */
@media (max-width: 480px) {
    .staff-navbar {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .user-controls {
        width: 100%;
        justify-content: center;
        flex-direction: column;
        margin-top: 0.5rem;
    }

    .btn-danger {
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.875rem;
    }

    .dashboard-core {
        padding-top: 1.5rem;
    }
}

/* =======================================================
   UTILITIES PARA LOGIN/REGISTRO (Sobreescribiendo LogIn raíz)
   ======================================================= */

.staff-form-wide {
    max-width: 500px !important;
    padding: 25px !important;
}

.staff-auth-title {
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 24px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    /* Estilo ameno y orgánico (Acorde a Agricultura/Cordami) */
    background: linear-gradient(135deg, #15803d 0%, #22c55e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
}

.staff-return-wrapper {
    margin-top: 15px;
    text-align: center;
}

.staff-return-link {
    color: #28a745 !important;
    text-decoration: none !important;
    font-weight: 500;
    transition: color 0.2s;
}

.staff-return-link:hover {
    color: #218838 !important;
    text-decoration: underline !important;
}

/* =========================================================
   STAFF UI OVERRIDES (Zero-Green / Corporate Blue Mode)
   ========================================================= */

/* 1. Cambio de borde verde a borde izquierdo azul */
.dashboard-grid .dash-card {
    border-top: none !important;
    border-left: 4px solid #2a5298 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dashboard-grid .dash-card:hover {
    border-left: 6px solid #1e3c72 !important;
    box-shadow: 0 10px 25px rgba(42, 82, 152, 0.12) !important;
    transform: translateY(-4px);
    background: #ffffff;
    cursor: pointer;
}

.dashboard-grid .dash-card:hover h3 {
    color: #1e3c72 !important;
}

/* 2. Resaltado jerárquico del Usuario (Profile Badge) */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(42, 82, 152, 0.06);
    padding: 6px 18px 6px 6px;
    border-radius: 50px;
    border: 1px solid rgba(42, 82, 152, 0.15);
    transition: background 0.3s;
    white-space: nowrap;
}

.user-profile-badge:hover {
    background: rgba(42, 82, 152, 0.1);
}

.user-avatar-circle {
    width: 32px;
    height: 32px;
    background: #2a5298;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

#activeUserLabel {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    white-space: nowrap;
}

/* =========================================================
   STAFF INTERNAL MODULES (Agenda, Forms, Layouts)
   ========================================================= */

.module-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 55px;
    height: 55px;
    background: rgba(42, 82, 152, 0.1);
    color: #1e3c72;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(42, 82, 152, 0.2);
    cursor: pointer;
}

.btn-back svg {
    width: 28px;
    height: 28px;
}

.btn-back:hover {
    background: #1e3c72;
    color: #fff;
    transform: translateX(-3px);
}

.staff-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 25px;
}

.staff-form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

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

.staff-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.staff-form-group input,
.staff-form-group select,
.staff-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.staff-form-group input:focus,
.staff-form-group select:focus,
.staff-form-group textarea:focus {
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.15);
}

.staff-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.staff-action-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Glass form container overrides */
.glass-panel.light-glass {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
}

/* =========================================================
   AGENDA LIST ITEMS & STATUS UI
   ========================================================= */

.agenda-item {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(42, 82, 152, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.agenda-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
}

.agenda-item.done {
    border-left: 6px solid #10b981;
    opacity: 0.85;
}

.agenda-item.pending {
    border-left: 6px solid #f59e0b;
}

.agenda-item-content {
    flex-grow: 1;
}

.agenda-item-title {
    color: #1e3c72;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.agenda-item-meta {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.agenda-item-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.agenda-item-actions {
    margin-left: 20px;
}

.btn-toggle-status {
    padding: 8px 18px;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-status-pending {
    background: #fef3c7;
    color: #d97706;
}

.btn-status-pending:hover {
    background: #fde68a;
}

.btn-status-done {
    background: #d1fae5;
    color: #059669;
}

.btn-status-done:hover {
    background: #a7f3d0;
}

@media (max-width: 768px) {
    .staff-form-grid {
        grid-template-columns: 1fr;
    }

    .agenda-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .agenda-item-actions {
        margin-left: 0;
        width: 100%;
    }

    .btn-toggle-status {
        width: 100%;
    }
}

/* =========================================================
   CARNET CORPORATIVO (VERSIÓN DEFINITIVA IMAGEN FONDO)
   ========================================================= */

:root {
    --id-verde-oscuro: #166534;
    --id-verde-medio: #15803d;
    --id-verde-claro: #dcfce7;
    --id-text-black: #111827;
    --id-line-1: #15803d;
    /* Verde oscuro */
    --id-line-2: #86efac;
    /* Verde claro */
    --id-line-3: #3b82f6;
    /* Azul */
    --id-line-4: #eab308;
    /* Amarillo */
    --id-line-5: #78350f;
    /* Marrón */
    --id-footer-text-yellow: #fde047;
}

.carnet-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.carnet-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.carnet-modal-content {
    position: relative;
    width: 90%;
    max-width: 330px;
    perspective: 1000px;
}

.btn-close-carnet {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.btn-close-carnet:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.carnet-flip-box {
    width: 100%;
    height: 520px;
    margin: 0 auto;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.carnet-modal-content.flipped .carnet-flip-box {
    transform: rotateY(180deg);
}

.carnet-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =========================================
   DISEÑO ANVERSO (ID CARD EXACTA - PREMIUM MESH)
   ========================================= */

.id-card {
    background-image: url('../../img/carnet_frontal.webp');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Fotografía (Posicionamiento Absoluto Milimétrico - Proporción 5200x8300 de Corel) */
.id-photo-container {
    position: absolute;
    left: 30.5478%;
    top: 27.9059%;
    width: 37.2632%;
    height: 25.0040%;
    z-index: 10;
    margin: 0;
    padding: 0;
}

.id-photo-container .photo-frame {
    width: 100%;
    height: 100%;
    border: 2px solid #ffffff;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-frame .placeholder {
    font-size: 4rem;
    color: #94a3b8;
    font-weight: 900;
}

/* Valores Dinámicos de Identidad (Frente) */
.id-val {
    position: absolute;
    left: 5%;
    width: 90%;
    text-align: center;
    z-index: 10;
    margin: 0;
    padding: 0;
    line-height: 1.1;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
}

.id-name-val {
    top: 63.2%;
    font-size: 0.98rem;
    color: #0f172a;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.id-cedula-val {
    top: 69.8%;
    font-size: 0.92rem;
    color: #1e293b;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.id-cargo-val {
    top: 77.2%;
    font-size: 0.86rem;
    color: #15803d;
    /* Verde corporativo de alto impacto */
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Código QR (Posicionamiento Absoluto Milimétrico - Proporción 5200x8300 de Corel) */
.id-qr-code {
    position: absolute;
    left: 37.4%;
    top: 81.7%;
    width: 25.2%;
    height: 15.7%;
    z-index: 10;
    background: #ffffff;
    padding: 3px;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e2e8f0;
}

.id-qr-code img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Footer */
.id-footer {
    width: 100%;
    background: var(--id-verde-oscuro);
    padding: 8px 10px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.id-footer p:first-child {
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.5px;
}

.id-footer p:last-child {
    color: var(--id-footer-text-yellow);
    font-size: 0.65rem;
    font-weight: 800;
    margin: 2px 0 0 0;
    letter-spacing: 0.5px;
}

/* =========================================
   DISEÑO REVERSO
   ========================================= */
.carnet-back {
    transform: rotateY(180deg) translateY(-510px);
    background-image: url('../../img/carnet_reverso.webp');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.id-vence-val {
    position: absolute;
    top: 5.7%;
    left: 3.4%;
    width: 93.2%;
    height: 6.3%;
    background: #ffffff;
    /* Tapar vencimiento preimpreso */
    color: #111827;
    font-weight: 900;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 6px;
    z-index: 10;
}

.btn-flip-carnet {
    width: 100%;
    margin-top: 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-flip-carnet:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}