:root {
    --portal-bg: #f7f9fb;
    --portal-surface: #ffffff;
    --portal-ink: #1f2933;
    --portal-muted: #52606d;
    --portal-line: #d9e2ec;
    --portal-brand: #0f5132;
    --portal-brand-soft: #e6f4ec;
    --portal-accent: #0b5cad;
    --portal-soft: #f2f6fa;
    --portal-btn-hover: #0b4228;
    --portal-footer-bg: #0b3d26;
    --portal-footer-text: #d9e8df;
    --portal-footer-muted: #b9d3c4;
    --portal-focus: rgba(11, 92, 173, .35);
    --portal-on-brand: #ffffff;
    --portal-mark-color: var(--portal-brand);
}

/* ------------------------------------------------------------------ */
/* Temas institucionales                                               */
/* ------------------------------------------------------------------ */
[data-theme="morena"] {
    --portal-bg: #f7f4f5;
    --portal-ink: #2b2b2b;
    --portal-muted: #6b6b6b;
    --portal-line: #e6dfe1;
    --portal-brand: #9b2242;
    --portal-brand-soft: #f7e9ee;
    --portal-accent: #9b2242;
    --portal-soft: #f7edf0;
    --portal-btn-hover: #7a1b34;
    --portal-footer-bg: #5e1327;
    --portal-footer-text: #f5e9ed;
    --portal-footer-muted: #d8b5c0;
    --portal-focus: rgba(155, 34, 66, .35);
}

[data-theme="pvem"] {
    --portal-bg: #f8fbf6;
    --portal-ink: #242424;
    --portal-muted: #5f6f5a;
    --portal-line: #dbe8d4;
    --portal-brand: #abd79e;
    --portal-brand-soft: #eef7ea;
    --portal-accent: #3f6d27;
    --portal-soft: #f0f8ec;
    --portal-btn-hover: #bde4b1;
    --portal-footer-bg: #3f6d27;
    --portal-footer-text: #eef7ea;
    --portal-footer-muted: #c3d9b8;
    --portal-focus: rgba(63, 109, 39, .35);
    --portal-on-brand: #242424;
    --portal-mark-color: #3f6d27;
}

[data-theme="pri"] {
    --portal-bg: #f5faf7;
    --portal-ink: #232b26;
    --portal-muted: #5f6b64;
    --portal-line: #dbe7df;
    --portal-brand: #0b6b3a;
    --portal-brand-soft: #e7f3ec;
    --portal-accent: #0b6b3a;
    --portal-soft: #eef5f0;
    --portal-btn-hover: #08552e;
    --portal-footer-bg: #0a4426;
    --portal-footer-text: #e4f1e9;
    --portal-footer-muted: #aecdbd;
    --portal-focus: rgba(11, 107, 58, .35);
}

[data-theme="pan"] {
    --portal-bg: #f5f7fc;
    --portal-ink: #1c2433;
    --portal-muted: #5f6b80;
    --portal-line: #dbe2ef;
    --portal-brand: #003da5;
    --portal-brand-soft: #e8eef9;
    --portal-accent: #003da5;
    --portal-soft: #eef2fa;
    --portal-btn-hover: #002f80;
    --portal-footer-bg: #00286b;
    --portal-footer-text: #e4ebf8;
    --portal-footer-muted: #aebfdd;
    --portal-focus: rgba(0, 61, 165, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--portal-bg);
    color: var(--portal-ink);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--portal-accent); }
a:hover { text-decoration: underline; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: #fff;
    color: var(--portal-ink);
    padding: .75rem 1rem;
    z-index: 100;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    outline: 3px solid var(--portal-accent);
}

.portal-wrap {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
}

.portal-header {
    background: var(--portal-brand);
    color: var(--portal-on-brand);
    padding: .9rem 0;
}

.portal-header .portal-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--portal-on-brand);
    font-weight: 700;
    text-decoration: none;
}

.portal-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff;
    color: var(--portal-mark-color);
    display: grid;
    place-items: center;
    font-weight: 800;
    overflow: hidden;
}

.portal-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.portal-logo-horizontal {
    display: block;
    max-height: 44px;
    width: auto;
    max-width: min(360px, 62vw);
    object-fit: contain;
}

.portal-nav {
    display: flex;
    gap: 1rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.portal-nav a {
    color: var(--portal-on-brand);
    text-decoration: none;
    padding: .25rem 0;
    border-bottom: 2px solid transparent;
}

.portal-nav a:hover,
.portal-nav a:focus {
    border-bottom-color: var(--portal-on-brand);
    text-decoration: none;
}

.portal-main {
    padding: 2rem 0 3rem;
    flex: 1 0 auto;
}

.portal-main:focus {
    outline: none;
}

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .5rem; }

.lead { color: var(--portal-muted); font-size: 1.05rem; }
.muted { color: var(--portal-muted); }
.small { font-size: .88rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mt-1 { margin-top: 1rem; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.portal-filters {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: .75rem;
    align-items: end;
    background: var(--portal-surface);
    border: 1px solid var(--portal-line);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
}

.portal-field { display: flex; flex-direction: column; gap: .3rem; }
.portal-field label { font-weight: 600; font-size: .9rem; }

input[type="search"] {
    padding: .65rem .7rem;
    border: 1px solid var(--portal-line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
    color: var(--portal-ink);
}

input[type="search"]:focus {
    outline: 3px solid var(--portal-focus);
    border-color: var(--portal-accent);
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .6rem .9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--portal-brand);
    color: var(--portal-on-brand);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.portal-btn:hover { background: var(--portal-btn-hover); text-decoration: none; }
.portal-btn.secondary { background: #fff; color: var(--portal-ink); border-color: var(--portal-line); }
.portal-btn:focus { outline: 3px solid var(--portal-focus); outline-offset: 2px; }

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-line);
    border-radius: 12px;
    padding: 1.1rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.portal-card h3 a { color: var(--portal-ink); text-decoration: none; }
.portal-card h3 a:hover { text-decoration: underline; }

.kpi-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    margin: 1rem 0;
}

.kpi-list div { background: var(--portal-soft); border-radius: 8px; padding: .5rem; }
.kpi-list dt { font-size: .75rem; color: var(--portal-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-list dd { margin: 0; font-weight: 700; font-size: 1.1rem; }

.portal-link { font-weight: 600; }

.portal-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}

.portal-kpi {
    background: var(--portal-surface);
    border: 1px solid var(--portal-line);
    border-radius: 10px;
    padding: .85rem;
}

.portal-kpi span { display: block; color: var(--portal-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.portal-kpi strong { display: block; font-size: 1.45rem; margin-top: .2rem; }

.bar {
    height: 8px;
    border-radius: 999px;
    background: var(--portal-line);
    overflow: hidden;
    margin-top: .5rem;
}

.bar > span {
    display: block;
    height: 100%;
    background: var(--portal-brand);
}

.portal-table-wrap { overflow-x: auto; }

.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--portal-surface);
    border: 1px solid var(--portal-line);
    border-radius: 10px;
    overflow: hidden;
    font-size: .92rem;
}

.portal-table caption {
    text-align: left;
    font-weight: 600;
    padding: .65rem 0;
    color: var(--portal-muted);
}

.portal-table th,
.portal-table td {
    padding: .6rem .65rem;
    border-bottom: 1px solid var(--portal-line);
    text-align: left;
    vertical-align: top;
}

.portal-table thead th {
    background: var(--portal-soft);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--portal-muted);
}

.portal-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.portal-empty { padding: 1.5rem; text-align: center; background: var(--portal-surface); border: 1px dashed var(--portal-line); border-radius: 10px; }

.portal-footer {
    background: var(--portal-footer-bg);
    color: var(--portal-footer-text);
    padding: 1.25rem 0;
    font-size: .9rem;
    margin-top: auto;
}

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

@media (max-width: 820px) {
    .portal-filters { grid-template-columns: 1fr; }
    h1 { font-size: 1.6rem; }
    .portal-logo-horizontal { max-height: 36px; max-width: 60vw; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}
