/* Portal HOPSA: base visual (variables, barra superior, banda de titulo, tarjetas) y portada. Sin estilos en linea (CSP estricta).
   El color de cada portal se define abajo con una clase .theme-<slug>: la misma clase sirve para la pagina y para su tarjeta. */
:root {
    --ink: #172033;
    --muted: #5a6579;
    --line: #e3e8f0;
    --line-strong: #cbd3e0;
    --bg: #f3f5f9;
    --card: #fff;
    --brand: #17346a;
    --gold: #f4b400;
    --accent: #1b3a73;
    --accent-dark: #0f2447;
    --accent-soft: color-mix(in srgb, var(--accent) 8%, #fff);
    --accent-line: color-mix(in srgb, var(--accent) 26%, #fff);
    --focus: #2f6fd6;
    --ok: #166534; --ok-soft: #ecf8f0; --ok-line: #b9dfc6;
    --warn: #8a5300; --warn-soft: #fff8e6; --warn-line: #f1dca4;
    --bad: #b42318; --bad-soft: #fdf1f0; --bad-line: #f1c4bf;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .05), 0 12px 30px rgba(16, 24, 40, .07);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Colores por portal (todos con texto blanco legible: contraste >= 4.5) ---- */
.theme-hub { --accent: #1b3a73; --accent-dark: #0f2447; }
.theme-tecnologia { --accent: #1d4ed8; --accent-dark: #1e3a8a; }
.theme-contabilidad { --accent: #0f766e; --accent-dark: #134e4a; }
.theme-exoneraciones { --accent: #0e7490; --accent-dark: #164e63; }
.theme-credito { --accent: #047857; --accent-dark: #064e3b; }
.theme-credito_pfc { --accent: #15803d; --accent-dark: #14532d; }
.theme-tesoreria { --accent: #4d7c0f; --accent-dark: #365314; }
.theme-compras { --accent: #c2410c; --accent-dark: #7c2d12; }
.theme-inventario { --accent: #a16207; --accent-dark: #713f12; }
.theme-trafico { --accent: #be123c; --accent-dark: #881337; }
.theme-logistica { --accent: #9a3412; --accent-dark: #6c2410; }
.theme-servicios { --accent: #6d28d9; --accent-dark: #4c1d95; }
.theme-transporte { --accent: #0369a1; --accent-dark: #0c4a6e; }
.theme-hyp { --accent: #4338ca; --accent-dark: #312e81; }
.theme-nps { --accent: #a21caf; --accent-dark: #701a75; }
.theme-calculista { --accent: #475569; --accent-dark: #1e293b; }
.theme-ventas { --accent: #be185d; --accent-dark: #831843; }
.theme-legal { --accent: #7f1d1d; --accent-dark: #4a0f0f; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    background: var(--bg); color: var(--ink);
    font: 15.5px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.ico { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.2em; }
.ico-lg { width: 26px; height: 26px; }

/* ---- Barra superior ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 9px 24px; display: flex; align-items: center; gap: 20px; min-height: 56px; }
.logos { display: flex; align-items: center; gap: 20px; text-decoration: none; }
.logos img { height: 30px; width: auto; display: block; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: .01em; }
.wordmark i { width: 10px; height: 26px; border-radius: 3px; background: linear-gradient(var(--gold) 0 50%, var(--brand) 50% 100%); }
.topbar-space { flex: 1; }

/* Identidad (login de Google) */
.userbar { display: flex; justify-content: flex-end; }
.usermenu { position: relative; }
.usermenu summary {
    display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; user-select: none;
    padding: 3px 12px 3px 3px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { border-color: var(--accent); background: var(--accent-soft); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-i { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-weight: 600; font-size: .92rem; }
.uname { font-size: .9rem; font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu .menu {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 260px; padding: 14px 16px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.usermenu .mail { color: var(--muted); font-size: .82rem; margin-bottom: 10px; word-break: break-all; }
.usermenu .menu a { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); text-decoration: none; font-size: .92rem; font-weight: 500; }
.usermenu .menu a:hover { text-decoration: underline; }

/* ---- Banda de titulo ---- */
.band { position: relative; overflow: hidden; color: #fff; background: linear-gradient(120deg, var(--accent-dark) 0%, var(--accent) 100%); }
.band::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(520px 260px at 92% -10%, rgba(255, 255, 255, .20), transparent 65%), radial-gradient(360px 200px at 8% 130%, rgba(255, 255, 255, .10), transparent 70%); }
.band-in { position: relative; max-width: 1180px; margin: 0 auto; padding: 22px 24px 84px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .84rem; color: rgba(255, 255, 255, .8); margin-bottom: 18px; }
.crumbs a { color: #fff; text-decoration: none; opacity: .9; }
.crumbs a:hover { text-decoration: underline; opacity: 1; }
.band-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.band-main { display: flex; align-items: center; gap: 18px; min-width: 0; }
.band-ico { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 16px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28); flex: none; }
.band-ico .ico { width: 30px; height: 30px; }
.kicker { margin: 0 0 4px; font-size: .76rem; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .82); }
.band h1 { margin: 0; font-size: clamp(1.55rem, 3.2vw, 2.15rem); font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.lead { margin: 6px 0 0; color: rgba(255, 255, 255, .88); max-width: 70ch; }
.lead a { color: #fff; }
.band-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.page { width: 100%; max-width: 1180px; margin: -52px auto 0; padding: 0 24px 56px; position: relative; z-index: 2; flex: 1 0 auto; }
.sitefoot { max-width: 1180px; width: 100%; margin: 0 auto; padding: 22px 24px 34px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; color: var(--muted); font-size: .84rem; border-top: 1px solid var(--line); }
.sitefoot a { color: var(--accent); text-decoration: none; font-weight: 500; }
.sitefoot a:hover { text-decoration: underline; }

/* ---- Portada ---- */
.hubhero { background: #fff; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.hubhero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(700px 300px at 85% -30%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 70%), radial-gradient(600px 300px at 0% 120%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%); pointer-events: none; }
.hubhero-in { position: relative; max-width: 980px; margin: 0 auto; padding: 44px 24px 40px; text-align: center; }
.hubhero .logos { justify-content: center; flex-wrap: wrap; gap: 22px 46px; margin-bottom: 30px; }
.hubhero .logos img { height: 54px; }
.hubhero .eyebrow { margin: 0 0 10px; font-size: .76rem; font-weight: 650; letter-spacing: .18em; text-transform: uppercase; color: var(--brand); }
.hubhero h1 { margin: 0 0 8px; font: 400 clamp(2rem, 4.5vw, 2.8rem)/1.15 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.hubhero p.sub { margin: 0 auto; color: var(--muted); font-size: 1.05rem; max-width: 56ch; }
.search { position: relative; max-width: 560px; margin: 26px auto 0; }
.search .ico { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search input {
    width: 100%; font: inherit; color: inherit; background: #fff; box-shadow: var(--shadow);
    border: 1px solid var(--line-strong); border-radius: 999px; padding: 14px 20px 14px 50px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 3px solid var(--focus); outline-offset: 2px; }

.hubmain { max-width: 1180px; width: 100%; margin: 0 auto; padding: 8px 24px 56px; flex: 1 0 auto; }
.area { margin-top: 38px; }
.area h2 {
    display: flex; align-items: center; gap: 14px; margin: 0 0 16px;
    font: 650 .76rem/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.area h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.area h2 .count { font-weight: 600; color: var(--muted); letter-spacing: 0; background: #e9edf4; border-radius: 999px; padding: 2px 9px; font-size: .72rem; }
.cardgrid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card {
    position: relative; display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow-sm); overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); opacity: .9; }
.card:hover { border-color: var(--accent-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); flex: none; }
.card-ico .ico { width: 24px; height: 24px; }
.card-body { flex: 1; min-width: 0; }
.card-title { display: block; font-weight: 650; font-size: 1.05rem; color: var(--ink); }
.card-desc { display: block; color: var(--muted); font-size: .86rem; margin-top: 2px; }
.card-arrow { color: var(--muted); flex: none; display: grid; }
.card:hover .card-arrow { color: var(--accent); }
.empty { color: var(--muted); padding: 36px 0; text-align: center; }
.hubnote { margin: 40px auto 0; max-width: 720px; text-align: center; color: var(--muted); font-size: .9rem; }

@media (prefers-reduced-motion: no-preference) {
    .card { transition: border-color .15s, box-shadow .15s, transform .15s; }
    .usermenu summary { transition: border-color .15s, background-color .15s; }
}
@media (max-width: 700px) {
    .topbar-in { padding: 8px 16px; gap: 12px; }
    .logos { gap: 12px; }
    .logos img { height: 22px; }
    .uname { display: none; }
    .usermenu summary { padding-right: 3px; }
    .band-in { padding: 16px 16px 72px; }
    .band-ico { width: 48px; height: 48px; border-radius: 13px; }
    .page { padding: 0 16px 40px; }
    .hubhero .logos img { height: 38px; }
    .hubmain { padding: 4px 16px 40px; }
    .sitefoot { padding: 18px 16px 28px; }
}
@media (max-width: 520px) {
    .hubhero-in { padding: 30px 16px 28px; }
    .hubhero .logos { gap: 14px 24px; margin-bottom: 22px; }
    .hubhero .logos img { height: 30px; }
    .cardgrid { grid-template-columns: 1fr; }
    .band h1 { font-size: 1.45rem; }
}

.stagingbar { background: #b42318; color: #fff; text-align: center; padding: 8px 14px; font-weight: 700; font-size: .9rem; letter-spacing: .02em; }
.stagingbar a { color: #fff; text-decoration: underline; margin-left: 8px; font-weight: 600; }

/* Enlaces de interes (sistemas externos) */
.links .card-ext .card-desc { opacity: .85; }
