* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #075f91;
    --primary-light: #0a8fd8;
    --background-color: #1f1f1f;
    --panel-color: #d9d9d9;
    --workspace-color: #ffffff;
    --text-light: #ffffff;
    --border-radius: 10px;
}

body {
    /* min-height: 100vh; */
    /* padding: 20px; */
    background-color: var(--background-color);
    font-family: Arial, Helvetica, sans-serif;
}

/*
 * Tema oscuro de la interfaz principal.
 * servicontaAplicarTema() agrega esta clase al body; las variables actualizan
 * las superficies generales y las reglas siguientes cubren colores fijos de
 * menús y tarjetas que no dependen de variables CSS.
 */
body.tema-oscuro-sistema {
    --primary-color: #063f61;
    --primary-light: #1976a8;
    --background-color: #101820;
    --panel-color: #24313d;
    --workspace-color: #17212b;
}

body.tema-oscuro-sistema .main-menu__item.active {
    background-color: #24313d;
    color: #f1f5f9;
}

body.tema-oscuro-sistema .options-panel__message,
body.tema-oscuro-sistema .module-section__label,
body.tema-oscuro-sistema .app__footer-text {
    color: #d7e0e8;
}

body.tema-oscuro-sistema .module-section {
    border-color: #52606d;
}

body.tema-oscuro-sistema .module-option {
    border-color: #607080;
    background-color: #344454;
    color: #f8fafc;
}

body.tema-oscuro-sistema .module-option:hover {
    background-color: #43576a;
}

body.tema-oscuro-sistema .user-panel-dropdown,
body.tema-oscuro-sistema .upd-profile,
body.tema-oscuro-sistema .upd-footer {
    background-color: #24313d;
}

body.tema-oscuro-sistema .upd-username,
body.tema-oscuro-sistema .upd-role,
body.tema-oscuro-sistema .upd-menu-item,
body.tema-oscuro-sistema .upd-menu-icon {
    color: #e5edf4;
}

body.tema-oscuro-sistema .upd-menu-item:hover {
    background-color: #344454;
}

body.tema-oscuro-sistema .upd-divider,
body.tema-oscuro-sistema .upd-footer {
    border-color: #52606d;
}

button {
    font: inherit;
}

.app {
    width: 100%;
    /* max-width: 1400px; */
    /* min-height: calc(100vh - 40px); */
    margin: 0;
    /* padding: 8px; */
    background-color: var(--primary-color);
}

/* Encabezado */

.app__header {
    min-height: 46px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 0 10px;
}

.main-menu {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    overflow-x: auto;
}

.main-menu__item {
    min-height: 34px;
    padding: 8px 13px;
    border: none;
    border-radius: 7px 7px 0 0;
    background-color: transparent;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

.main-menu__item:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.main-menu__item.active {
    background-color: #ffffff;
    color: #1b1b1b;
}

.user-button {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    /* margin-bottom: 4px; */
    border: none;
    border-radius: 50%;
    background-color: #ffffff;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.user-button:hover,
.user-button.active {
    background-color: #e8e8e8;
    transform: scale(1.08);
}

/* Contenedor relativo para anclar el dropdown */
.user-panel-wrap {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 4px;
}

/* Panel flotante */
.user-panel-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: #f4f4f4;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.10);
    z-index: 9999;
    overflow: hidden;
    animation: updFadeIn 0.16s ease;
}

.user-panel-dropdown.open {
    display: block;
}

@keyframes updFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Sección de perfil */
.upd-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px 12px;
    background: #e8e8e8;
}

.upd-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.upd-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.upd-username {
    font-weight: 700;
    font-size: 0.97rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upd-role {
    font-size: 0.81rem;
    color: #555e6d;
    margin-top: 2px;
}

.upd-divider {
    margin: 0;
    border: none;
    border-top: 1px solid #d4d4d4;
}

/* Lista de opciones */
.upd-menu {
    list-style: none;
    margin: 6px 0;
    padding: 0 8px;
}

.upd-menu li {
    margin: 2px 0;
}

.upd-menu-item {
    width: 100%;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 7px;
    font-size: 0.92rem;
    color: #1e293b;
    cursor: pointer;
    text-align: left;
    transition: background 0.13s;
}

.upd-menu-item:hover {
    background: #e0e0e0;
}

.upd-menu-icon {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    color: #475569;
}

/* Footer con botón cerrar sesión */
.upd-footer {
    padding: 12px 14px;
    background: #e8e8e8;
    border-top: 1px solid #d4d4d4;
}

.upd-logout-btn {
    display: block;
    text-align: center;
    background: #c0392b;
    color: #ffffff;
    padding: 10px 0;
    border-radius: 7px;
    font-weight: 600;
    font-size: 0.91rem;
    text-decoration: none;
    transition: background 0.15s;
}

.upd-logout-btn:hover {
    background: #a93226;
    color: #ffffff;
}

/* Panel superior */

.options-panel {
    min-height: 115px;
    padding: 0 8px;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    border: 3px solid var(--primary-light);
    border-radius: var(--border-radius);
    background-color: var(--panel-color);
}

.options-panel__message {
    color: #666666;
    font-size: 14px;
}

/* Área principal */

.workspace {
    min-height: calc(100vh - 220px);
    margin-top: 8px;
    display: grid;
    place-items: center;
    border-radius: var(--border-radius);
    background-color: var(--workspace-color);
    overflow: auto;
}

.brand {
    color: #bac8d0;
    text-align: center;
    user-select: none;
}

.brand__initials {
    font-family: Georgia, serif;
    font-size: clamp(42px, 6vw, 72px);
    line-height: 1;
}

.brand__name {
    margin-top: 8px;
    font-family: Georgia, serif;
    font-size: clamp(13px, 2vw, 20px);
}

/* Secciones y opciones del módulo (estilo por grupos como referencia visual). */

.module-sections {
    display: flex;
    align-items: stretch;
    min-height: 100%;
    width: max-content;
}

.module-section {
    min-width: 260px;
    min-height: 100%;
    padding: 10px 12px 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: 1px solid #b5b5b5;
}

.module-section:last-child {
    border-right: none;
}

.module-options {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 54px;
}

.module-option {
    width: auto;
    /* height: 40px; */
    padding: 5px;
    margin: 5px;
    border: 1px solid #9fa6b2;
    border-radius: 4px;
    background-color: #eef1f5;
    color: #1e1e1e;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.module-option:hover {
    background-color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.module-option:focus-visible {
    outline: 2px solid #0a8fd8;
    outline-offset: 1px;
    background-color: #ffffff;
}

.module-option__icon {
    font-size: 23px;
    line-height: 1;
    pointer-events: none;
}

.module-section__label {
    margin-top: 6px;
    margin-bottom: 3px;
    font-size: 19px;
    line-height: 1.1;
    color: #1f2937;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive */

@media (max-width: 900px) {
    body {
        padding: 10px;
    }

    .app {
        min-height: calc(100vh - 20px);
    }

    .app__header {
        padding: 0;
    }

    .main-menu__item {
        padding-inline: 10px;
        font-size: 13px;
    }

    .options-panel {
        min-height: 130px;
    }

    .workspace {
        min-height: calc(100vh - 245px);
    }
}


.app__footer {
    margin-top: 0;
    padding: 12px 16px;
    border-radius: 0;
    box-shadow: none;
    background-color: var(--panel-color);
    text-align: center;
}

.app__footer-text {
    color: #666666;
    font-size: 14px;
}


/* ======================================================
   IFRAME DEL ÁREA DE TRABAJO
   El iframe ocupa todo el espacio del workspace cuando
   está visible. La clase --hidden lo oculta sin eliminarlo
   del DOM (preserva el estado de la vista cargada).
   ====================================================== */

.workspace-frame {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 220px);
    border: none;
    border-radius: var(--border-radius);
    background-color: #ffffff;
    display: block;
    align-self: stretch; /* ocupa el alto completo del flex/grid padre */
}

.workspace-frame--hidden {
    display: none;
}

/* Indicador de carga de módulos. Se limita al workspace para mantener accesible
   el encabezado del sistema mientras el servidor del hosting responde. */
.workspace{position:relative}
.workspace-loader{position:absolute;inset:0;z-index:15;display:none;align-items:center;justify-content:center;padding:20px;background:rgba(245,248,250,.9);backdrop-filter:blur(2px);border-radius:var(--border-radius)}
.workspace-loader.is-loading{display:flex}.workspace-loader__card{width:min(350px,100%);padding:27px 23px;text-align:center;background:#fff;border:1px solid #dfe7ec;border-radius:12px;box-shadow:0 14px 38px rgba(26,48,67,.16)}
.workspace-loader__spinner{display:block;width:44px;height:44px;margin:0 auto 15px;border:4px solid #d9eaf2;border-top-color:#075f91;border-radius:50%;animation:workspaceLoaderSpin .75s linear infinite}.workspace-loader strong,.workspace-loader small{display:block}.workspace-loader strong{font-size:15px;color:#243245}.workspace-loader small{margin-top:7px;color:#748191;font-size:11px;line-height:1.45}
@keyframes workspaceLoaderSpin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.workspace-loader__spinner{animation-duration:1.8s}}

/* ======================================================
   VISTAS CARGADAS DENTRO DEL PANEL PRINCIPAL
   (usadas cuando se inyecta HTML directamente con innerHTML)
   ====================================================== */

.module-view {
    width: 100%;
    min-height: 100%;
    padding: 24px;
}

.module-view__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.module-view__header h1 {
    margin-bottom: 5px;
    font-size: 24px;
    color: #1f2933;
}

.module-view__header p {
    color: #6b7280;
}

.module-view__content {
    overflow-x: auto;
}

.primary-button {
    padding: 10px 16px;
    border: none;
    border-radius: 7px;
    background-color: #075f91;
    color: #ffffff;
    cursor: pointer;
}

.primary-button:hover {
    background-color: #064f78;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.data-table th {
    background-color: #f3f4f6;
    color: #374151;
}

.workspace-message,
.workspace-error {
    width: 100%;
    padding: 30px;
}

.workspace-error {
    color: #b42318;
}

.main-menu__item.module-locked{opacity:.42;cursor:not-allowed}.main-menu__item.module-locked:hover{background:transparent;color:#fff}.main-menu__item.module-locked::after{content:"";width:5px;height:5px;margin-left:5px;display:inline-block;border-radius:50%;background:#f0c36c;vertical-align:middle}
.brand__company-prompt{margin-top:16px;padding:9px 14px;border:1px solid #cfdbe3;border-radius:7px;background:#f7fafc;color:#607181;font-size:12px;font-weight:500;letter-spacing:0}

.header-company-status{margin-left:auto;margin-bottom:5px;display:flex;align-items:center;gap:8px;max-width:260px;padding:5px 10px;border-radius:7px;background:rgba(255,255,255,.13);color:#fff}.header-company-status span:last-child{min-width:0}.header-company-status small,.header-company-status strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.header-company-status small{font-size:9px;opacity:.75}.header-company-status strong{font-size:11px;margin-top:1px}.header-company-dot{width:7px;height:7px;flex:0 0 auto;border-radius:50%;background:#62dfa8;box-shadow:0 0 0 3px rgba(98,223,168,.15)}.header-company-status.no-company{opacity:.75}.header-company-status.no-company .header-company-dot{background:#f0c36c}@media(max-width:760px){.header-company-status{max-width:150px}.header-company-status small{display:none}}

/* Menú desplegable exclusivo del botón Archivo. */
.archivo-dropdown {
    display: none;
    position: fixed;
    min-width: 320px;
    padding: 6px 0 10px;
    background-color: #ffffff;
    border: 1px solid #d0d5dd;
    border-radius: 0 8px 8px 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    z-index: 9999;
}

.archivo-dropdown.open {
    display: block;
}

.archivo-dd-section {
    margin: 0;
    padding: 10px 16px 4px;
    color: #9aa0ad;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
}

.archivo-dd-sep {
    margin: 8px 0;
    border: none;
    border-top: 1px solid #e8eaed;
}

.archivo-dd-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background-color: transparent;
    color: #1f2937;
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.archivo-dd-item:hover {
    background-color: #f0f5ff;
    color: var(--primary-color);
}

.archivo-dd-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-width: 30px;
    height: 30px;
    background-color: #e8eaed;
    border-radius: 6px;
    font-size: 16px;
    pointer-events: none;
}

.archivo-dd-label {
    font-weight: 500;
    pointer-events: none;
}

.archivo-dd-chevron{margin-left:auto;font-size:22px;line-height:1;color:#708090;transition:transform .18s ease;pointer-events:none}.archivo-dd-item.submenu-open .archivo-dd-chevron{transform:rotate(90deg);color:var(--primary-color)}.archivo-dd-item.submenu-open{background:#f0f5ff;color:var(--primary-color)}

.archivo-company-list{display:none;margin:2px 10px 7px;padding:5px;background:#f6f8fa;border:1px solid #e1e6eb;border-radius:7px;max-height:230px;overflow-y:auto}.archivo-company-list.open{display:block}.archivo-company-item{width:100%;border:0;border-radius:6px;background:transparent;padding:8px;display:flex;align-items:center;gap:9px;text-align:left;color:#253244;cursor:pointer}.archivo-company-item:hover{background:#e8f2f8}.archivo-company-item.active{background:#dceef7;color:#075f91}.archivo-company-initials{width:30px;height:30px;display:grid;place-items:center;flex:0 0 auto;border-radius:6px;background:#075f91;color:#fff;font-size:10px;font-weight:700}.archivo-company-item strong,.archivo-company-item small{display:block}.archivo-company-item strong{font-size:12px}.archivo-company-item small{font-size:10px;color:#7b8795;margin-top:2px}.archivo-company-check{margin-left:auto;font-weight:800}.archivo-company-empty{padding:10px;margin:0;color:#7c8794;font-size:12px;text-align:center}.archivo-active-company{margin:1px 16px 7px;padding:7px 9px;border-radius:5px;background:#edf7f2;color:#39705a;font-size:10px}.archivo-active-company[hidden]{display:none}


/* Logos: object-fit evita deformarlos y mantiene el cuadro compacto. */
.archivo-company-initials{overflow:hidden}.archivo-company-initials.has-logo{background:#fff;border:1px solid #d9e2e8}.archivo-company-initials img{width:100%;height:100%;display:block;object-fit:contain}

/* Estilos botones menu usuarios */
.config-modal {
        position: fixed;
        inset: 0;
        z-index: 3000;
        display: none;
        align-items: center;
        justify-content: center;
        padding: 20px;
        background: rgba(15, 23, 42, .55);
    }
    .config-modal.open { display: flex; }
    .config-modal__window {
        width: min(760px, 94vw);
        height: min(650px, 88vh);
        overflow: hidden;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, .55);
        background: rgba(255, 255, 255, .78);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        box-shadow: 0 20px 55px rgba(0, 0, 0, .28);
    }
    .config-modal__header {
        height: 52px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 18px;
        border-bottom: 1px solid #e5e7eb;
    }
    .config-modal__close {
        border: 0;
        background: transparent;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
    }
    .config-modal__frame {
        width: 100%;
        height: calc(100% - 52px);
        border: 0;
        background: transparent;
    }
    .support-modal__window {
    width: min(430px, 92vw);
    height: auto;
}

.support-modal__body {
    padding: 26px 24px 28px;
    text-align: center;
}

.support-modal__icon {
    font-size: 38px;
    color: #075f91;
}

.support-modal__body p {
    margin: 12px 0 8px;
    line-height: 1.5;
}

.support-modal__email {
    display: block;
    margin-bottom: 20px;
    color: #075f91;
    font-weight: 600;
}

.support-modal__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 7px;
    background: #075f91;
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
}

.support-modal__button:hover {
    background: #064f78;
    color: #ffffff;
}
.maintenance-notice{position:fixed;z-index:9999;top:62px;left:50%;transform:translateX(-50%);width:min(760px,calc(100% - 28px));display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid #e5a72f;border-radius:9px;background:#fff7df;color:#714a00;box-shadow:0 10px 28px rgba(0,0,0,.18)}.maintenance-notice[hidden]{display:none}.maintenance-notice__icon{font-size:22px}.maintenance-notice span:nth-child(2){display:flex;flex-direction:column;min-width:0;flex:1}.maintenance-notice strong{font-size:14px}.maintenance-notice small{margin-top:3px;font-size:11px}.maintenance-notice b{white-space:nowrap;font-size:12px;padding:6px 9px;border-radius:6px;background:#f4d589}.maintenance-notice.is-active{border-color:#c83a31;background:#fff0ef;color:#8f211b}.maintenance-notice.is-active b{background:#f2b5b1}@media(max-width:650px){.maintenance-notice{top:58px;align-items:flex-start}.maintenance-notice b{white-space:normal}}
