/* --- Variables por tema --- */
html.light {
    --page-bg: #f6f6f8;
    --text: #111318;
    --text-muted: #636f88;
    --text-footer-muted: #636f88;
    --card-bg: #ffffff;
    --card-border: #f3f4f6;
    --card-border-hover: #e5e7eb;
    --header-bg: rgba(255, 255, 255, 0.8);
    --header-border: #f0f2f4;
    --footer-bg: #ffffff;
    --primary: #195de6;
    --input-placeholder: #8b95aa;
    --avatar-bg: #1f2937;
    --avatar-fg: #facc15;
    --user-border: #e5e7eb;
}

html.dark {
    --page-bg: #111621;
    --text: #ffffff;
    --text-muted: #9ca3af;
    --text-footer-muted: #6b7280;
    --card-bg: #1e2330;
    --card-border: #1f2937;
    --card-border-hover: #374151;
    --header-bg: rgba(17, 22, 33, 0.8);
    --header-border: #1f2937;
    --footer-bg: #111621;
    --primary: #195de6;
    --input-placeholder: #8b95aa;
    --avatar-bg: #1f2937;
    --avatar-fg: #facc15;
    --user-border: #374151;
}

html {
    font-size: 100%;
}

.hidden {
    display: none !important;
}

.service-card--filtered-out {
    display: none !important;
}

/* --- Base --- */
.site-body {
    margin: 0;
    font-family: Inter, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.site-body::selection {
    background: rgba(25, 93, 230, 0.2);
    color: var(--primary);
}

.wrap {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    .wrap {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .wrap {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* --- Header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--header-border);
    transition: background-color 0.3s, border-color 0.3s;
}

.site-header__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4rem;
    height: 4rem;
}

.site-header__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-header__logo-wrap {
    color: var(--primary);
}

.site-header__logo {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    display: block;
}

.site-header__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--text);
}

.site-header__tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .site-header__tools {
        gap: 1rem;
    }
}

.theme-toggle {
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 0.5rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.theme-toggle:hover {
    color: var(--primary);
    background: #f3f4f6;
}

html.dark .theme-toggle:hover {
    color: #ffffff;
    background: #1f2937;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.theme-toggle__icon {
    font-size: 24px;
    display: block;
    line-height: 1;
}

.site-header__user-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--user-border);
}

@media (min-width: 640px) {
    .site-header__user-wrap {
        padding-left: 1rem;
    }
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-meta__name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
}

.user-meta__dept {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    box-shadow: 0 0 0 2px #ffffff, 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    background: var(--avatar-bg);
    color: var(--avatar-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

html.dark .avatar {
    box-shadow: 0 0 0 2px #1f2937, 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- Main --- */
.site-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding: 2.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .site-main {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .site-main {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* --- Búsqueda --- */
.search-panel {
    border-radius: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 1rem;
    width: 100%;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .search-panel {
        padding: 1rem 1.5rem;
    }
}

.search-panel__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-panel__icon {
    color: var(--primary);
    flex-shrink: 0;
    line-height: 1;
}

.search-panel__input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
    font: inherit;
}

.search-panel__input::placeholder {
    color: var(--input-placeholder);
}

.search-panel__btn {
    display: none;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.search-panel__btn:hover {
    background: #1d4ed8;
}

@media (min-width: 640px) {
    .search-panel__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* --- Grid de servicios --- */
.service-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .service-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .service-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .service-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.service-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-radius: 1rem;
    background: var(--card-bg);
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s ease-out;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}

html.dark .service-card {
    border-color: rgba(71, 85, 105, 0.55);
}

.service-card:hover {
    border-color: rgba(0, 168, 168, 0.55);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-4px);
}

.service-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.service-card__icon-wrap {
    padding: 0.75rem;
    border-radius: 0.75rem;
}

.service-card__icon {
    font-size: 28px;
    line-height: 1;
    display: block;
}

.service-card__chevron {
    color: #d1d5db;
    transition: color 0.3s, transform 0.3s;
    line-height: 1;
}

.service-card:hover .service-card__chevron {
    transform: translateX(4px);
}

.service-card__title {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    transition: color 0.3s;
}

.service-card__desc {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.625;
    color: var(--text-muted);
}

/* Acentos por tarjeta */
.service-card--blue .service-card__icon-wrap {
    background: #eff6ff;
    color: #195de6;
}
html.dark .service-card--blue .service-card__icon-wrap {
    background: rgba(30, 58, 138, 0.3);
    color: #93c5fd;
}
.service-card--blue:hover .service-card__chevron,
.service-card--blue:hover .service-card__title {
    color: #195de6;
}
html.dark .service-card--blue:hover .service-card__title {
    color: #93c5fd;
}

.service-card--emerald .service-card__icon-wrap {
    background: #ecfdf5;
    color: #059669;
}
html.dark .service-card--emerald .service-card__icon-wrap {
    background: rgba(6, 78, 59, 0.3);
    color: #34d399;
}
.service-card--emerald:hover .service-card__chevron,
.service-card--emerald:hover .service-card__title {
    color: #059669;
}
html.dark .service-card--emerald:hover .service-card__title {
    color: #34d399;
}

.service-card--purple .service-card__icon-wrap {
    background: #faf5ff;
    color: #9333ea;
}
html.dark .service-card--purple .service-card__icon-wrap {
    background: rgba(88, 28, 135, 0.3);
    color: #c084fc;
}
.service-card--purple:hover .service-card__chevron,
.service-card--purple:hover .service-card__title {
    color: #9333ea;
}
html.dark .service-card--purple:hover .service-card__title {
    color: #c084fc;
}

.service-card--orange .service-card__icon-wrap {
    background: #fff7ed;
    color: #ea580c;
}
html.dark .service-card--orange .service-card__icon-wrap {
    background: rgba(124, 45, 18, 0.3);
    color: #fb923c;
}
.service-card--orange:hover .service-card__chevron,
.service-card--orange:hover .service-card__title {
    color: #ea580c;
}
html.dark .service-card--orange:hover .service-card__title {
    color: #fb923c;
}

.service-card--indigo .service-card__icon-wrap {
    background: #eef2ff;
    color: #4f46e5;
}
html.dark .service-card--indigo .service-card__icon-wrap {
    background: rgba(49, 46, 129, 0.3);
    color: #818cf8;
}
.service-card--indigo:hover .service-card__chevron,
.service-card--indigo:hover .service-card__title {
    color: #4f46e5;
}
html.dark .service-card--indigo:hover .service-card__title {
    color: #818cf8;
}

.service-card--teal .service-card__icon-wrap {
    background: #f0fdfa;
    color: #0d9488;
}
html.dark .service-card--teal .service-card__icon-wrap {
    background: rgba(19, 78, 74, 0.3);
    color: #2dd4bf;
}
.service-card--teal:hover .service-card__chevron,
.service-card--teal:hover .service-card__title {
    color: #0d9488;
}
html.dark .service-card--teal:hover .service-card__title {
    color: #2dd4bf;
}

.service-card--gray .service-card__icon-wrap {
    background: #f3f4f6;
    color: #4b5563;
}
html.dark .service-card--gray .service-card__icon-wrap {
    background: #1f2937;
    color: #d1d5db;
}
.service-card--gray:hover .service-card__chevron,
.service-card--gray:hover .service-card__title {
    color: #4b5563;
}
html.dark .service-card--gray:hover .service-card__title {
    color: #d1d5db;
}

.service-card--cyan .service-card__icon-wrap {
    background: #ecfeff;
    color: #0891b2;
}
html.dark .service-card--cyan .service-card__icon-wrap {
    background: rgba(22, 78, 99, 0.3);
    color: #22d3ee;
}
.service-card--cyan:hover .service-card__chevron,
.service-card--cyan:hover .service-card__title {
    color: #0891b2;
}
html.dark .service-card--cyan:hover .service-card__title {
    color: #22d3ee;
}

.service-card--amber .service-card__icon-wrap {
    background: #fffbeb;
    color: #d97706;
}
html.dark .service-card--amber .service-card__icon-wrap {
    background: rgba(120, 53, 15, 0.3);
    color: #fbbf24;
}
.service-card--amber:hover .service-card__chevron,
.service-card--amber:hover .service-card__title {
    color: #d97706;
}
html.dark .service-card--amber:hover .service-card__title {
    color: #fbbf24;
}

.service-card--rose .service-card__icon-wrap {
    background: #fff1f2;
    color: #e11d48;
}
html.dark .service-card--rose .service-card__icon-wrap {
    background: rgba(136, 19, 55, 0.3);
    color: #fb7185;
}
.service-card--rose:hover .service-card__chevron,
.service-card--rose:hover .service-card__title {
    color: #e11d48;
}
html.dark .service-card--rose:hover .service-card__title {
    color: #fb7185;
}

.empty-state {
    font-size: 0.875rem;
    color: var(--text-muted);
    width: 100%;
    margin: 0;
}

/* --- Footer --- */
.site-footer {
    width: 100%;
    background: var(--footer-bg);
    border-top: 1px solid var(--header-border);
    padding: 2.5rem 0;
    margin-top: auto;
    transition: background 0.3s, border-color 0.3s;
}

.site-footer__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .site-footer__inner {
        flex-direction: row;
    }
}

.site-footer__credit-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

@media (min-width: 768px) {
    .site-footer__credit-wrap {
        align-items: flex-start;
    }
}

.site-footer__credit {
    margin: 0;
    color: var(--text-footer-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
}

/* --- Tema accesible --- */
html.accessible .site-body {
    background: #eceff3 !important;
    color: #111111 !important;
}

html.accessible .site-header,
html.accessible .site-footer {
    background: #dfe4ea !important;
    border-color: #7a8088 !important;
}

html.accessible .search-panel,
html.accessible .service-card {
    background: #f7f7f8 !important;
    border-color: #6b7280 !important;
}

html.accessible .site-header__title,
html.accessible .user-meta__name,
html.accessible .service-card__title {
    color: #111111 !important;
}

html.accessible .user-meta__dept,
html.accessible .service-card__desc,
html.accessible .search-panel__input,
html.accessible .empty-state {
    color: #3f3f46 !important;
}

html.accessible .search-panel__icon {
    color: #1f2937 !important;
}

html.accessible .search-panel__btn {
    background-color: #2f2f35 !important;
    color: #ffffff !important;
}

html.accessible .theme-toggle:hover {
    color: #1f2937 !important;
}

html.accessible *:focus-visible {
    outline: 3px solid #111111 !important;
    outline-offset: 2px !important;
}

/* --- Responsive móvil --- */
@media (max-width: 640px) {
    body {
        overflow-x: hidden;
    }

    .site-main {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .site-header .wrap,
    .site-footer .wrap {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .site-header__row {
        height: auto;
        min-height: 56px;
        padding-top: 8px;
        padding-bottom: 8px;
        gap: 8px;
    }

    .site-header__title {
        font-size: 11px !important;
        line-height: 1.15 !important;
        max-width: 170px;
        letter-spacing: 0;
    }

    .site-header__logo {
        width: 28px !important;
        height: 28px !important;
    }

    .user-meta {
        align-items: center !important;
        justify-content: center;
    }

    .user-meta__name {
        font-size: 9px !important;
        line-height: 1.1 !important;
    }

    .user-meta__dept {
        font-size: 8px !important;
        line-height: 1.1 !important;
    }

    .site-header__user-wrap {
        padding-left: 6px !important;
        border-left-width: 0 !important;
        gap: 6px !important;
    }

    .site-header__tools {
        margin-left: -8px !important;
    }

    .avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 9px !important;
        box-shadow: 0 0 0 1px #ffffff, 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    html.dark .avatar {
        box-shadow: 0 0 0 1px #1f2937, 0 1px 2px rgba(0, 0, 0, 0.2);
    }

    .theme-toggle {
        padding: 6px !important;
        margin-right: 2px !important;
    }

    #searchInput {
        font-size: 16px;
        min-height: 40px;
    }

    .search-panel__btn {
        display: none !important;
    }

    .service-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        width: 100% !important;
    }

    .service-card {
        padding: 13px !important;
        border-radius: 12px !important;
        min-height: 0 !important;
        min-width: 0 !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .service-card__icon {
        font-size: 22px !important;
    }

    .service-card__title {
        font-size: 13px !important;
        line-height: 1.25 !important;
        margin-bottom: 6px !important;
    }

    .service-card__desc {
        font-size: 11px !important;
        line-height: 1.35 !important;
    }

    .site-footer {
        padding-top: 14px !important;
        padding-bottom: 14px !important;
    }

    .site-footer__credit {
        font-size: 11px !important;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .service-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .service-card {
        padding: 11px !important;
    }

    .service-card__title {
        font-size: 12px !important;
    }
}

@media (max-width: 360px) {
    .service-grid {
        grid-template-columns: 1fr !important;
    }

    .site-header .wrap,
    .site-main,
    .site-footer .wrap {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}
