/* portal-shell.css — Sistema de diseño unificado, sistemas CESFAM La Unión
   Copiar tal cual a la raíz del repo del sistema y enlazar ANTES del CSS propio.
   Tema oscuro por defecto; el claro se activa con html[data-theme="light"]. */

:root {
  --bg: #0F1620;
  --top: #131B26;
  --nav: #1A2431;
  --surface: #16202C;
  --surface2: #1C2734;
  --ink: #EEF2F6;
  --muted: #98A3AE;
  --faint: #717D89;
  --hair: rgba(255, 255, 255, .075);
  --hair2: rgba(255, 255, 255, .14);
  --gold: #F5B942;
  --goldink: #F5B942;
  --goldsoft: rgba(245, 185, 66, .10);
  --goldline: rgba(245, 185, 66, .45);
  --ok: #34D399;
  --oksoft: rgba(52, 211, 153, .12);
  --okline: rgba(52, 211, 153, .26);
  --logo: #1B2634;
  --logofx: brightness(0) invert(1);
  --ondark: #17202A;
  --shell-max: 1400px;
  --shell-pad: clamp(18px, 4vw, 48px);
  --font-display: "Quantico", "Arial Narrow", sans-serif;
  --font-ui: "IBM Plex Sans", system-ui, sans-serif;
  --chamfer-16: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  --chamfer-12: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  --chamfer-22: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

html[data-theme="light"] {
  --bg: #F2F1F0;
  --top: #FFFFFF;
  --nav: #F7F6F8;
  --surface: #FFFFFF;
  --surface2: #F7F6F8;
  --ink: #16202A;
  --muted: #6B6F72;
  --faint: #8A9096;
  --hair: rgba(16, 24, 32, .09);
  --hair2: rgba(16, 24, 32, .16);
  --gold: #E2A32B;
  --goldink: #8A5A0B;
  --goldsoft: rgba(226, 163, 43, .14);
  --goldline: rgba(226, 163, 43, .55);
  --ok: #0E8A5F;
  --oksoft: rgba(14, 138, 95, .10);
  --okline: rgba(14, 138, 95, .24);
  --logo: #FFFFFF;
  --logofx: brightness(0);
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--goldink); text-decoration: none; }
a:hover { color: var(--gold); }

/* ---------- Contenedor ---------- */
.shell { max-width: var(--shell-max); margin: 0 auto; padding-inline: var(--shell-pad); }

/* ---------- Header del portal (idéntico en todos los sistemas) ---------- */
.portal-topbar { background: var(--top); border-bottom: 1px solid var(--hair); }
.portal-topbar__inner {
  max-width: var(--shell-max); margin: 0 auto; padding-inline: var(--shell-pad);
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.portal-clock { display: flex; align-items: center; gap: 14px; min-width: 0; }
.portal-clock__date { font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-clock__sep { width: 1px; height: 18px; background: var(--hair2); flex: none; }
.portal-clock__time { font-size: 15.5px; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.portal-theme {
  flex: none; width: 62px; height: 31px; border-radius: 999px; border: 1px solid var(--hair2);
  background: var(--surface2); position: relative; cursor: pointer; padding: 0;
}
.portal-theme__thumb {
  position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 999px;
  background: var(--gold); display: flex; align-items: center; justify-content: center;
  transition: left .28s var(--ease-spring);
}
html[data-theme="light"] .portal-theme__thumb { left: 34px; }

.portal-nav { background: var(--nav); border-bottom: 1px solid var(--hair); }
.portal-nav__inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 11px clamp(14px, 4vw, 44px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.portal-nav__item {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 14.5px; font-weight: 500; white-space: nowrap;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.portal-nav__item:hover { color: var(--ink); background: var(--hair); transform: translateY(-1px); }
.portal-nav__item.is-active {
  border-color: var(--goldline); background: var(--goldsoft); color: var(--goldink); font-weight: 600;
}

.portal-id { background: var(--top); }
.portal-id__inner {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 26px var(--shell-pad) 30px;
  display: flex; align-items: center; gap: clamp(16px, 3vw, 34px); flex-wrap: wrap;
}
.portal-id__logo {
  flex: none; width: 96px; height: 96px; border-radius: 22px; background: var(--logo);
  border: 1px solid var(--hair2); display: flex; align-items: center; justify-content: center;
  padding: 14px; box-sizing: border-box;
}
.portal-id__logo img { max-width: 100%; max-height: 100%; object-fit: contain; filter: var(--logofx); }
.portal-id__copy { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.portal-id__row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.portal-id__title { margin: 0; font-size: clamp(24px, 3.4vw, 34px); font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.portal-id__subtitle { margin: 0; color: var(--muted); font-size: 15px; }
.portal-status {
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px;
  background: var(--oksoft); border: 1px solid var(--okline); color: var(--ok);
  font-size: 13.5px; font-weight: 700; white-space: nowrap;
}
.portal-status__dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ok); animation: dotPulse 2.4s ease-in-out infinite; }

/* ---------- Barra de secciones del sistema ---------- */
.section-bar {
  position: sticky; top: 0; z-index: 30; background: var(--nav);
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); backdrop-filter: blur(10px);
}
.section-bar__inner {
  max-width: var(--shell-max); margin: 0 auto; padding-inline: var(--shell-pad);
  display: flex; gap: 26px; flex-wrap: wrap;
}
.section-bar__link {
  padding: 15px 0; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.section-bar__link:hover { color: var(--ink); }
.section-bar__link.is-active { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; background: var(--bg); }
.hero__canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .95; }
.hero__inner {
  position: relative; max-width: var(--shell-max); margin: 0 auto;
  padding: clamp(46px, 7vw, 86px) var(--shell-pad) clamp(50px, 7vw, 90px);
}
.eyebrow { margin: 0 0 22px; font-size: 12px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--goldink); }
.stair {
  margin: 0; font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  letter-spacing: .01em; line-height: .98; font-size: min(clamp(38px, 7.4vw, 86px), 11vh);
}
.stair span { display: block; }
.stair span.is-indent { padding-left: min(238px, 26vw); }
.stair span.is-accent { color: var(--gold); }

/* ---------- Botones ---------- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 12px; background: var(--gold); color: var(--ondark);
  border: none; font: 700 15px/1 var(--font-ui); letter-spacing: .13em; text-transform: uppercase;
  padding: 19px 34px; cursor: pointer; clip-path: var(--chamfer-16);
  box-shadow: 0 0 0 1px var(--goldline), 0 12px 34px -14px rgba(245, 185, 66, .7);
  transition: transform .2s ease, filter .2s ease;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-2px); color: var(--ondark); }
.btn-primary__tail { width: 22px; height: 1px; background: var(--ondark); display: inline-block; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 10px; padding: 19px 26px; color: var(--ink);
  background: transparent; border: 1px solid var(--hair2);
  font: 700 13px/1 var(--font-ui); letter-spacing: .13em; text-transform: uppercase;
  cursor: pointer; clip-path: var(--chamfer-12); transition: background .2s ease;
}
.btn-ghost:hover { background: var(--hair); color: var(--ink); }

.chip {
  padding: 9px 14px; background: transparent; border: 1px solid var(--hair2); color: var(--muted);
  font: 600 12.5px/1 var(--font-ui); cursor: pointer; white-space: nowrap;
  transition: color .2s ease, border-color .2s ease;
}
.chip:hover { color: var(--ink); border-color: var(--goldline); }

/* ---------- Paneles, retículas y tablas ---------- */
.panel { background: var(--surface); border: 1px solid var(--hair); padding: clamp(22px, 3vw, 30px); clip-path: var(--chamfer-22); }
.field {
  width: 100%; box-sizing: border-box; padding: 16px 18px; background: var(--surface2);
  border: 1px solid var(--hair2); color: var(--ink); font: 600 16px/1.2 var(--font-ui);
  border-radius: 0; outline: none;
}

.grid-hair { display: grid; gap: 1px; background: var(--hair); border: 1px solid var(--hair); }
.grid-hair--metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card { background: var(--surface); padding: 24px; }
.card--accent { border-top: 2px solid var(--gold); }
.card__label { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.card--accent .card__label { color: var(--goldink); }
.card__value { display: block; margin-top: 12px; font-family: var(--font-display); font-size: clamp(20px, 2.4vw, 30px); font-weight: 700; line-height: 1.05; }

.section-title {
  margin: 0; font-family: var(--font-display); font-size: clamp(30px, 5vw, 58px);
  font-weight: 700; text-transform: uppercase; letter-spacing: .01em; line-height: .98;
}

.table-shell { border: 1px solid var(--hair); background: var(--surface); overflow-x: auto; }
.table-shell table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table-shell th {
  text-align: left; padding: 16px 20px; font-size: 11px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--hair);
}
.table-shell td { padding: 16px 20px; border-bottom: 1px solid var(--hair); }
.table-shell tbody tr { animation: rowIn .5s var(--ease-out) both; }
.pill { display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; background: var(--hair); color: var(--muted); }
.pill--next { background: var(--goldsoft); color: var(--goldink); }
.pill--soon { background: var(--oksoft); color: var(--ok); }

/* Callout de regla operativa */
.rule-note { padding: 18px 22px; border-left: 2px solid var(--gold); background: var(--surface); }
.rule-note__label { margin: 0 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--goldink); }
.rule-note__text { margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.5; }

/* ---------- Footer ---------- */
.portal-footer { border-top: 1px solid var(--hair); background: var(--top); }
.portal-footer__inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 34px var(--shell-pad);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.portal-footer__mark { font-family: var(--font-display); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.portal-footer__meta { color: var(--muted); font-size: 13.5px; }

/* ---------- Motion ---------- */
[data-rv] { opacity: 0; transform: translateY(24px); transition: opacity .85s var(--ease-out), transform .85s var(--ease-out); }
[data-rv].rv-in { opacity: 1; transform: none; }

@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes dotPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--okline); } 50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); } }

@media (prefers-reduced-motion: reduce) {
  [data-rv] { opacity: 1; transform: none; transition: none; }
  .table-shell tbody tr { animation: none; }
  .portal-status__dot { animation: none; }
}
