:root {
    --primary: #0f766e;
    --primary-light: #f0fdfa;
    --accent: #2dd4bf;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-body: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --error: #ef4444;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1),
        0 1px 2px -1px rgb(0 0 0 / 0.1);

    --sidebar-w: 260px;
    --sidebar-collapsed: 68px;
    --topbar-h: 64px;
    --footer-h: 46px;
    --sidebar-bg: #0d2c29;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-main);
    background: var(--bg-body);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ══════════════════════════════
   TOPBAR
══════════════════════════════ */
.topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    margin-right: 16px;
    border: none;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.sidebar-toggle:hover {
    background: #ccfbf1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #0f766e 0%, #2dd4bf 100%);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 700;
}

.user-role {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    background: #fef2f2;
    color: var(--error);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.logout-btn:hover {
    background: #fee2e2;
}

/* ══════════════════════════════
   LAYOUT
══════════════════════════════ */
.layout {
    display: flex;
    margin-top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h) - var(--footer-h));
    overflow: hidden;
}

/* ══════════════════════════════
   SIDEBAR
══════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 200;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

/* Perfil */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 14px;
    flex-shrink: 0;
}

.sp-avatar {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #0f766e 0%, #2dd4bf 100%);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sp-info {
    overflow: hidden;
}

.sp-name {
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-role {
    margin-top: 1px;
    color: #64748b;
    font-size: 0.68rem;
}

.sidebar.collapsed .sidebar-profile {
    justify-content: center;
    padding: 16px 0;
}

.sidebar.collapsed .sp-info {
    display: none;
}

/* Divisor */
.sidebar-divider {
    height: 1px;
    margin: 2px 14px;
    background: rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}

/* Etiquetas */
.nav-group-label {
    padding: 14px 18px 5px;
    color: #475569;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, height 0.2s ease;
}

.sidebar.collapsed .nav-group-label {
    height: 0;
    padding: 0;
    opacity: 0;
}

/* Área de navegación */
.nav-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
}

.nav-scroll::-webkit-scrollbar {
    width: 4px;
}

.nav-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.nav-scroll::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

/* Enlaces y botones */
.nav-link,
.nav-btn {
    width: calc(100% - 16px);
    margin: 1px 8px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 11px;
    position: relative;
    text-align: left;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
}

.nav-link.active {
    background: rgba(15, 118, 110, 0.3);
    color: #2dd4bf;
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    width: 3px;
    height: 55%;
    position: absolute;
    top: 50%;
    left: -8px;
    border-radius: 0 3px 3px 0;
    background: #2dd4bf;
    transform: translateY(-50%);
}

/* Íconos */
.nav-icon {
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.75;
}

.nav-link:hover .nav-icon,
.nav-btn:hover .nav-icon,
.nav-link.active .nav-icon {
    opacity: 1;
}

/* Flecha del acordeón */
.nav-arrow {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.35;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

.nav-item.open > .nav-btn .nav-arrow {
    color: #2dd4bf;
    opacity: 1;
    transform: rotate(90deg);
}

/* Sidebar colapsado */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-arrow {
    display: none;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-btn {
    padding: 10px 0;
    justify-content: center;
}

.sidebar.collapsed .nav-icon {
    min-width: unset;
    opacity: 0.8;
}

/* Submenús */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
}

.nav-item.open > .submenu {
    max-height: 300px;
}

.sidebar.collapsed .submenu {
    display: none;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 1px 8px;
    padding: 8px 12px 8px 43px;
    border-radius: 7px;
    color: #64748b;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.submenu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.submenu-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #334155;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.submenu a:hover .submenu-dot {
    background: #2dd4bf;
}

/* Enlace para cerrar sesión */
.nav-link-danger {
    color: #f87171 !important;
}

.nav-link-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #fca5a5 !important;
}

.sidebar-footer {
    padding-bottom: 6px;
    flex-shrink: 0;
}

/* ══════════════════════════════
   CONTENIDO PRINCIPAL
══════════════════════════════ */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* ══════════════════════════════
   FOOTER CENTRADO
══════════════════════════════ */
.footer {
    height: var(--footer-h);
    position: fixed;
    bottom: 0;
    left: var(--sidebar-w);
    right: 0;
    z-index: 250;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.74rem;
    text-align: center;

    backdrop-filter: blur(10px);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
}

.footer-brand {
    color: var(--primary);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.footer-separator {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #cbd5e1;
}

.footer-text {
    color: var(--text-muted);
}

.footer-year {
    color: #94a3b8;
    font-weight: 500;
}

/* Footer al colapsar el sidebar */
body:has(.sidebar.collapsed) .footer {
    left: var(--sidebar-collapsed);
}

/* ══════════════════════════════
   CARD GENÉRICA
══════════════════════════════ */
.card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    box-shadow: var(--shadow);
}

/* ══════════════════════════════
   TABLAS
══════════════════════════════ */
table {
    width: 100%;
    margin-top: 15px;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    background: var(--primary-light);
    color: var(--primary);
    text-align: left;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

tr:hover td {
    background: #fdfdfd;
}

/* ══════════════════════════════
   OVERLAY MÓVIL
══════════════════════════════ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.4);
}

.overlay.active {
    display: block;
}

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 860px) {
    .sidebar {
        width: var(--sidebar-w) !important;
        height: calc(100vh - var(--topbar-h) - var(--footer-h));
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .user-details {
        display: none;
    }

    .main-content {
        padding: 22px 16px;
    }

    .footer {
        left: 0 !important;
        padding: 0 16px;
    }

    .footer-content {
        gap: 8px;
        font-size: 0.68rem;
    }
}

@media (max-width: 480px) {
    .footer-text {
        display: none;
    }

    .footer-content {
        gap: 9px;
    }

    .logout-btn {
        padding: 7px 9px;
        font-size: 0;
    }

    .logout-btn svg {
        width: 16px;
        height: 16px;
    }
}
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary, #0f766e);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-header h1 {
    margin: 0;
    color: #0f172a;
    font-size: 1.65rem;
}

.page-subtitle {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 0.92rem;
}

.visita-form {
    overflow: hidden;
}

.card-header {
    padding: 22px 28px;
    border-bottom: 1px solid #e2e8f0;
}

.card-header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 1.05rem;
}

.card-header p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 0.86rem;
}

.visita-form-grid {
    padding: 28px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-field label {
    color: #334155;
    font-size: 0.8rem;
    font-weight: 700;
}

.required {
    color: #dc2626;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #dbe3ed;
    border-radius: 10px;
    background: #f8fafc;
    color: #0f172a;
    font: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-field input,
.form-field select {
    min-height: 44px;
    padding: 10px 12px;
}

.form-field textarea {
    padding: 12px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: #0f766e;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.field-help {
    font-size: 0.78rem;
}

.field-help-error {
    color: #b91c1c;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 28px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.alert-success {
    margin-bottom: 20px;
    padding: 13px 16px;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    background: #f0fdf4;
    color: #166534;
    font-size: 0.9rem;
}

@media (max-width: 720px) {
    .page-header {
        flex-direction: column;
    }

    .visita-form-grid {
        padding: 20px;
    }

    .form-field-full {
        grid-column: auto;
    }

    .form-actions {
        padding: 16px 20px;
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}