/* Portal de acceso unificado CENIT365 (Web + App Nativa iOS/Android) */
:root {
    --ink: #172439;
    --ink-soft: #263650;
    --muted: #526176;
    --blue: #214eb7;
    --blue-dark: #153e9e;
    --blue-soft: #eef4ff;
    --blue-border: #c9dafc;
    --line: #dfe5ee;
    --soft: #f5f7fb;
    --white: #ffffff;
    --green-ink: #0f766e;
    --green-bg: #ecfdf5;
    --green-border: #a7f3d0;
    --warn-ink: #92400e;
    --warn-bg: #fffbeb;
    --warn-border: #fde68a;
    --err-ink: #991b1b;
    --err-bg: #fef2f2;
    --err-border: #fecaca;
    --radius: 16px;
    --container: 1184px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--soft);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(900px 460px at 82% -8%, rgba(33, 78, 183, 0.11), transparent 65%),
        radial-gradient(700px 420px at 8% 12%, rgba(21, 62, 158, 0.06), transparent 60%),
        var(--soft);
}

h1, h2, h3, p {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid #3872ec;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -64px;
    z-index: 200;
    background: var(--ink);
    color: var(--white);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
}

.skip-link:focus {
    top: 12px;
}

.container {
    width: min(var(--container), calc(100% - 32px));
    margin-inline: auto;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Cabecera Web */
.site-header {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    padding:
        calc(12px + env(safe-area-inset-top, 0px))
        max(0px, env(safe-area-inset-right, 0px))
        12px
        max(0px, env(safe-area-inset-left, 0px));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 60;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-name {
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ink);
    white-space: nowrap;
}

.brand-number {
    color: var(--blue);
}

.brand-sub {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-transform: uppercase;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    padding: 7px 10px;
    border-radius: 10px;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--ink);
    background: var(--soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 11px;
    font-weight: 650;
    font-size: 0.875rem;
    padding: 9px 14px;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.btn-secondary {
    background: var(--white);
    border-color: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    background: var(--soft);
    border-color: #c8d2e2;
}

.btn-primary {
    background: var(--blue);
    color: var(--white);
    box-shadow: 0 6px 16px -6px rgba(33, 78, 183, 0.55);
}

.btn-primary:hover {
    background: var(--blue-dark);
}

html:not(.is-native-app) .native-only {
    display: none !important;
}

.recent-box[hidden],
.section-divider[hidden] {
    display: none !important;
}

/* Contenido Principal */
.portal-main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    padding: 36px 0 48px;
}

.portal-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 460px);
    gap: 48px;
    align-items: center;
}

/* Columna Izquierda: Presentación Web */
.portal-intro {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--white);
    border: 1px solid var(--line);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--blue);
    text-transform: uppercase;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
    flex-shrink: 0;
}

.intro-title {
    font-size: clamp(1.85rem, 3.2vw, 2.75rem);
    line-height: 1.12;
    font-weight: 750;
    letter-spacing: -0.035em;
    color: var(--ink);
}

.intro-title span {
    color: var(--blue);
}

.intro-lead {
    font-size: 1.02rem;
    line-height: 1.6;
    color: var(--muted);
    max-width: 56ch;
}

.pillar-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pillar-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 15px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.pillar-card:hover {
    border-color: var(--blue-border);
    box-shadow: 0 10px 24px -18px rgba(23, 36, 57, 0.32);
    transform: translateY(-1px);
}

.pillar-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--blue-soft);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pillar-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 3px;
}

.pillar-desc {
    font-size: 0.81rem;
    line-height: 1.42;
    color: var(--muted);
}

.intro-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: 0.85rem;
    color: var(--muted);
}

.intro-strip-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--blue);
    font-weight: 650;
}

.text-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Columna Derecha: Tarjeta de Acceso */
.access-column {
    width: 100%;
    min-width: 0;
}

.access-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 28px 26px 24px;
    box-shadow:
        0 24px 48px -26px rgba(23, 36, 57, 0.25),
        0 2px 6px rgba(23, 36, 57, 0.04);
    position: relative;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.32rem;
    font-weight: 750;
    letter-spacing: -0.025em;
    color: var(--ink);
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.45;
}

.security-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green-ink);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.context-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-ink);
    font-size: 0.84rem;
    line-height: 1.45;
    margin-bottom: 18px;
}

.context-alert strong {
    display: block;
    font-weight: 700;
    margin-bottom: 2px;
}

/* Entornos Recientes */
.recent-box {
    margin-bottom: 16px;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 9px;
}

.recent-title {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.recent-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--blue);
    background: var(--blue-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workspace-row {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--line);
    border-radius: 13px;
    background: var(--white);
    overflow: hidden;
    transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.workspace-row:hover {
    border-color: var(--blue);
    background: #f8fbff;
    box-shadow: 0 6px 16px -12px rgba(33, 78, 183, 0.45);
}

.workspace-item {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 56px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.workspace-meta {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.workspace-logo-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.workspace-logo-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.workspace-initial {
    font-size: 0.9rem;
    font-weight: 750;
    color: var(--blue);
}

.workspace-text {
    min-width: 0;
}

.workspace-name {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-sub {
    display: block;
    font-size: 0.76rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-enter {
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.workspace-remove {
    border: none;
    border-left: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    width: 40px;
    min-height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.workspace-remove:hover {
    background: var(--err-bg);
    color: var(--err-ink);
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 12px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
}

.section-divider::before,
.section-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* Buscador de Empresa */
.search-form {
    position: relative;
}

.field-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink);
}

.field-hint {
    font-size: 0.76rem;
    color: var(--muted);
}

.search-control {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--muted);
    pointer-events: none;
    display: inline-flex;
}

/* font-size 16px obligatorio para evitar auto-zoom en iOS Safari/WKWebView */
.search-input {
    width: 100%;
    height: 52px;
    padding: 0 46px 0 44px;
    border-radius: 13px;
    border: 1.5px solid #cbd5e1;
    background: var(--soft);
    color: var(--ink);
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
    color: #6b7b90;
    font-size: 0.94rem;
}

.search-input:focus {
    background: var(--white);
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(33, 78, 183, 0.13);
    outline: none;
}

.clear-btn {
    position: absolute;
    right: 4px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.clear-btn[hidden] {
    display: none;
}

.clear-btn:hover {
    color: var(--ink);
}

.suggestions-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: var(--white);
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    box-shadow: 0 18px 36px -14px rgba(15, 23, 42, 0.22);
    max-height: 248px;
    overflow-y: auto;
    padding: 6px;
    z-index: 120;
    display: none;
}

.suggestions-panel.is-open {
    display: block;
}

.suggestion-row {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 11px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    color: var(--ink);
}

.suggestion-row:hover,
.suggestion-row.is-active {
    background: var(--blue-soft);
    color: var(--blue-dark);
}

.suggestion-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.suggestion-left .workspace-logo-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    padding: 3px;
}

.suggestion-action {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--blue);
    flex-shrink: 0;
}

.suggestion-empty {
    padding: 12px 12px;
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.45;
}

.search-error {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 11px;
    background: var(--err-bg);
    border: 1px solid var(--err-border);
    color: var(--err-ink);
    font-size: 0.84rem;
    font-weight: 600;
}

.search-error[hidden] {
    display: none;
}

.btn-submit {
    margin-top: 14px;
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 13px;
    background: var(--blue);
    color: var(--white);
    font-size: 0.98rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 10px 20px -10px rgba(33, 78, 183, 0.7);
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.btn-submit:hover:not(:disabled) {
    background: var(--blue-dark);
    transform: translateY(-1px);
}

.btn-submit:disabled {
    opacity: 0.72;
    cursor: wait;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.noscript-note {
    margin-top: 12px;
    font-size: 0.83rem;
    color: var(--muted);
}

.noscript-note a {
    color: var(--blue);
    font-weight: 650;
}

/* Acciones secundarias dentro de la tarjeta */
.card-actions {
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.card-action-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 11px;
    background: var(--soft);
    border: 1px solid var(--line);
    font-size: 0.84rem;
    color: var(--ink-soft);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.card-action-link:hover {
    border-color: var(--blue-border);
    background: var(--blue-soft);
}

.card-action-link strong {
    color: var(--blue);
    font-weight: 700;
    white-space: nowrap;
}

.card-trust {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}

.card-trust .icon {
    width: 16px;
    height: 16px;
    color: var(--green-ink);
}

/* Footer */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--line);
    padding:
        16px
        max(0px, env(safe-area-inset-right, 0px))
        calc(16px + env(safe-area-inset-bottom, 0px))
        max(0px, env(safe-area-inset-left, 0px));
    font-size: 0.82rem;
    color: var(--muted);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.footer-links a:hover {
    color: var(--blue);
}

.footer-links .footer-support {
    color: var(--blue);
    font-weight: 650;
}

/* =========================================================
   MODO APP NATIVA (iOS / Android Capacitor o ?app=1)
   ========================================================= */
html.is-native-app .web-only {
    display: none !important;
}

html.is-native-app .native-only {
    display: flex;
}

html.is-native-app .site-header {
    border-bottom: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    position: static;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: 4px;
}

html.is-native-app .header-inner {
    justify-content: center;
}

html.is-native-app .portal-main {
    align-items: flex-start;
    padding: 12px 0 28px;
}

html.is-native-app .portal-shell {
    grid-template-columns: minmax(0, 440px);
    justify-content: center;
}

html.is-native-app .access-card {
    padding: 24px 20px 20px;
}

html.is-native-app .site-footer {
    background: transparent;
    border-top: none;
    padding-top: 8px;
}

html.is-native-app .footer-inner {
    justify-content: center;
    gap: 14px;
}

/* Responsive Móvil y Tablet Web */
@media (max-width: 959px) {
    .portal-main {
        align-items: flex-start;
        padding: 20px 0 36px;
    }

    .portal-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
    }

    .access-column {
        order: -1;
        max-width: 520px;
        margin-inline: auto;
    }

    .portal-intro {
        max-width: 680px;
        margin-inline: auto;
    }
}

@media (max-width: 639px) {
    .nav-hide-sm {
        display: none;
    }

    .pillar-grid {
        grid-template-columns: 1fr;
    }

    .access-card {
        padding: 24px 18px 20px;
        border-radius: 18px;
    }
}

@media (max-width: 399px) {
    .container {
        width: calc(100% - 24px);
    }

    .btn-header-alta {
        display: none;
    }
}

@media (max-width: 340px) {
    .card-head {
        flex-direction: column;
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}

