:root {
    /* Identidad Visual - Paleta de Colores Corporativos */
    --primary: #008299;
    /* Azul Petróleo - Gestión y Autoridad */
    --secondary: #799A3A;
    /* Verde Oliva - Sustentabilidad */
    --bronze: #8C7853;
    /* Bronce Envejecido - Patrimonio */
    --terracotta: #B35A3D;
    /* Terracota - Alertas y Acción */
    --neutral: #E5E0D8;
    /* Arena Neutra - Superficies */

    /* Variaciones y Colores de Apoyo */
    --white: #FFFFFF;
    --black: #1A1A1A;
    --text: #525851;
    --bg-light: #F9F8F6;
    --shadow: rgba(0, 0, 0, 0.1);

    /* Tipografía */
    --font-display: 'Montserrat', sans-serif;
    --font-body: 'Lato', sans-serif;

    /* Espaciado y Bordes */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --radius: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg-light);
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    margin-bottom: var(--spacing-sm);
}

p {
    margin-bottom: var(--spacing-sm);
    font-weight: 300;
    /* Lato Light */
}

/* Layout SPA Base */
#app {
    display: flex;
    min-height: 100vh;
}

aside {
    width: 260px;
    background-color: var(--primary);
    color: var(--white);
    padding: var(--spacing-lg) var(--spacing-sm);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    text-align: center;
    border-bottom: 2px solid var(--secondary);
    padding-bottom: var(--spacing-sm);
}

nav ul {
    list-style: none;
}

nav ul li {
    margin-bottom: var(--spacing-xs);
}

nav ul li a {
    color: var(--white);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    padding: var(--spacing-sm);
    display: block;
    border-radius: var(--radius);
    transition: var(--transition);
}

nav ul li a:hover,
nav ul li a.active {
    background-color: var(--secondary);
    transform: translateX(5px);
}

main {
    flex: 1;
    margin-left: 260px;
    padding: var(--spacing-lg);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    background-color: var(--white);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px var(--shadow);
}

.card {
    background-color: var(--white);
    padding: var(--spacing-md);
    border-radius: var(--radius);
    box-shadow: 0 2px 4px var(--shadow);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--secondary);
}

button {
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--white);
}

.btn-accent {
    background-color: var(--bronze);
    color: var(--white);
}

/* UI Enhancements */
.card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    border: 1px solid var(--neutral);
}

/* AI Chat Messages */
#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 10px 15px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.ai {
    background: #f0f4f8;
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th,
.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--neutral);
    text-align: left;
}

.data-table th {
    background: var(--bg-light);
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 12px;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    position: relative;
    padding: 0;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--neutral);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
    line-height: 1;
}

/* Prospect Form Grid */
.prospect-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    color: #666;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    border: 1px solid var(--neutral);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 130, 153, 0.1);
}

.col-full {
    grid-column: 1 / -1;
}

.log-container {
    background: #f8fafb;
    border: 1px solid var(--neutral);
    border-radius: 6px;
    height: 200px;
    overflow-y: auto;
    padding: 15px;
}

.log-entry {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--neutral);
}

/* --- MOBILE OPTIMIZATIONS (Consolidated) --- */
/* Reset & Utility */
.grid-split-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .grid-split-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.text-muted {
    color: #666;
}

.font-bold {
    font-weight: bold;
}

.text-xs {
    font-size: 0.75rem;
}

.text-center {
    text-align: center;
}

/* Media Query: Phones & Tablets Portrait */
@media (max-width: 768px) {

    /* 1. Layout Reset */
    #app {
        flex-direction: column;
    }

    main {
        margin-left: 0 !important;
        /* Reset desktop margin */
        padding: 10px !important;
        margin-top: 70px;
        /* Space for fixed header */
        width: 100%;
    }

    /* 2. Header / Sidebar as Top Bar */
    aside {
        width: 100%;
        height: 60px;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        padding: 0 15px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .logo {
        margin-bottom: 0;
        padding-bottom: 0;
        border: none;
        font-size: 1.2rem;
        text-align: left;
    }

    /* 3. Toggle Button */
    #mobile-menu-toggle {
        display: block !important;
    }

    /* 4. Navigation Menu (Collapsible) */
    aside nav {
        display: none;
        /* Hidden by default */
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: var(--primary);
        padding: 0;
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
    }

    aside nav.nav-open {
        display: block;
        /* Shown when toggled */
    }

    aside nav ul {
        display: flex;
        flex-direction: column;
    }

    aside nav ul li {
        margin: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    aside nav ul li a {
        border-radius: 0;
        padding: 15px;
    }

    /* 5. Content Adjustments */
    .card {
        padding: 15px !important;
        margin-bottom: 15px;
    }

    /* 6. Data Tables Scroll */
    div[id$="-container"],
    /* Catches inventory-container, etc */
    .table-container,
    .card>div:has(table),
    div[style*="overflow-x"] {
        overflow-x: auto !important;
        display: block;
        width: 100%;
    }

    .card table,
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px !important;
        font-size: 0.8rem !important;
    }

    /* 7. Forms & Buttons */
    .grid-split-2 {
        grid-template-columns: 1fr !important;
    }

    .btn-secondary,
    .btn-primary,
    .btn-accent {
        width: 100%;
        /* Full width buttons for touch */
        margin-bottom: 10px;
        padding: 12px;
    }

    /* Hide desktop header user info */
    header {
        display: none;
    }

    /* Fix modals */
    .modal-content {
        width: 95% !important;
        margin: 10px auto !important;
        padding: 15px !important;
        max-height: 85vh;
        overflow-y: auto;
    }
}

/* =====================================================
   TARJETA DE IDENTIFICACIÓN VIRTUAL - USER PROFILE
   ===================================================== */

.id-card {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.id-card-header {
    background: linear-gradient(90deg, var(--primary) 0%, #006680 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.id-card-logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.15em;
}

.id-card-badge {
    background: var(--secondary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.05em;
}

.id-card-body {
    padding: 25px;
    text-align: center;
}

.id-card-photo-container {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.id-card-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--secondary);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.id-card-photo-edit {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    border: 2px solid white;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.id-card-photo-edit:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.id-card-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: white;
    margin: 10px 0 5px 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.id-card-specialty {
    color: var(--secondary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.id-card-info {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    margin-top: 15px;
}

.id-card-info div {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    margin: 5px 0;
}

.id-card-info i {
    color: var(--secondary);
    width: 20px;
    margin-right: 8px;
}

.id-card-footer {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 20px;
    text-align: center;
}

.id-card-certs {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.cert-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bronze);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

/* Responsive para tarjeta de perfil */
@media (max-width: 900px) {
    #profile-container>div:first-child {
        grid-template-columns: 1fr !important;
    }

    .id-card {
        max-width: 350px;
        margin: 0 auto;
    }
}

/* Badges de Verificación de Perfil */
.id-card-verified {
    background: linear-gradient(90deg, #4caf50 0%, #2e7d32 100%);
    color: white;
    padding: 8px 15px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 0.1em;
}

.id-card-verified i {
    margin-right: 6px;
}

.id-card-pending {
    background: linear-gradient(90deg, #ff9800 0%, #f57c00 100%);
    color: white;
    padding: 8px 15px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.id-card-pending i {
    margin-right: 6px;
}

/* =====================================================
   IMÁGENES DE PORTADA EN TARJETAS DE DESARROLLO
   ===================================================== */

.dev-card-cover {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    position: relative;
    background: linear-gradient(135deg, var(--neutral) 0%, var(--bg-light) 100%);
}

.dev-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    background: var(--bg-light);
}

.dev-card-cover:hover img {
    transform: scale(1.05);
}

.dev-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.dev-card-placeholder i {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

.dev-card-placeholder span {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
    text-align: center;
    padding: 0 15px;
}