/*
 * Rey Gaspar 2027 · Portal visual mobile-first
 * Versión 1.0.0 · piloto visual del Portal
 * Capa aditiva: no modifica lógica, rutas, datos, SSO ni permisos.
 */

:root{
  --rg-navy-950:#06162d;
  --rg-navy-900:#071b37;
  --rg-navy-800:#0c2b56;
  --rg-blue-700:#174f91;
  --rg-blue-600:#2468b7;
  --rg-gold-500:#d8aa4a;
  --rg-gold-300:#efd693;
  --rg-surface:#ffffff;
  --rg-surface-soft:#f6f8fc;
  --rg-canvas:#eef3f9;
  --rg-text:#122038;
  --rg-muted:#637089;
  --rg-line:#d8e1ee;
  --rg-success:#176b45;
  --rg-warning:#8a5b00;
  --rg-danger:#a62f2f;
  --rg-shadow-sm:0 5px 18px rgba(6,27,55,.07);
  --rg-shadow-md:0 14px 38px rgba(6,27,55,.11);
  --rg-shadow-lg:0 24px 64px rgba(6,27,55,.20);
  --rg-radius-sm:12px;
  --rg-radius-md:18px;
  --rg-radius-lg:24px;
  --rg-touch:48px;
}

html{
  background:var(--rg-canvas);
  text-size-adjust:100%;
  -webkit-text-size-adjust:100%;
  scroll-behavior:smooth;
}

body{
  color:var(--rg-text);
  background:
    radial-gradient(circle at 100% 0,rgba(36,104,183,.09),transparent 25rem),
    linear-gradient(180deg,#f7f9fd 0,var(--rg-canvas) 34rem);
  font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  line-height:1.45;
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
}

button,input,select,textarea{font:inherit}
a,button,input,select,textarea{-webkit-tap-highlight-color:transparent}
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{
  outline:3px solid rgba(36,104,183,.34);
  outline-offset:2px;
}

/* Cabecera y navegación */
.app-header{
  position:sticky;
  top:0;
  z-index:100;
  background:linear-gradient(135deg,var(--rg-navy-950),var(--rg-navy-800));
  border-bottom:1px solid rgba(255,255,255,.14);
  box-shadow:0 8px 28px rgba(6,22,45,.20);
}
.header-inner{
  min-height:64px;
  padding:8px max(14px,env(safe-area-inset-right)) 8px max(14px,env(safe-area-inset-left));
  gap:10px;
}
.brand{gap:10px;min-width:0}
.brand-mark{
  width:42px;
  height:42px;
  flex:0 0 42px;
  border-radius:13px;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.62),0 7px 18px rgba(0,0,0,.24);
}
.brand strong{font-size:15px;line-height:1.08}
.brand small{font-size:11px;margin-top:3px;color:#d9e4f5;opacity:.86}
.header-actions{display:flex;align-items:center;gap:9px;min-width:0}
.user-chip{min-width:0;gap:7px}
.user-name{max-width:180px;font-size:13px}
.role-badge{font-size:9px;padding:4px 7px}
.header-logout{
  min-width:44px;
  min-height:44px;
  padding:0 12px;
  border:1px solid rgba(255,255,255,.17);
  border-radius:13px;
  background:rgba(255,255,255,.08);
  color:#fff;
}
.header-logout:hover{background:rgba(255,255,255,.15)}

.portal-access-nav{
  border-top:1px solid rgba(255,255,255,.10);
  background:rgba(4,18,39,.94);
  backdrop-filter:blur(14px);
}
.portal-access-track{
  max-width:1180px;
  gap:6px;
  padding:7px max(10px,env(safe-area-inset-right)) 8px max(10px,env(safe-area-inset-left));
  scroll-snap-type:x proximity;
  scrollbar-width:none;
}
.portal-access-track::-webkit-scrollbar{display:none}
.portal-nav-item{
  min-height:50px;
  flex:0 0 auto;
  scroll-snap-align:start;
  gap:7px;
  padding:6px 10px;
  border-radius:14px;
  color:#e8effa;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
}
.portal-nav-item.active{
  color:var(--rg-navy-950);
  background:linear-gradient(180deg,#f5d98d,#d8aa4a);
  box-shadow:0 6px 18px rgba(0,0,0,.18);
}
.portal-nav-icon{
  width:34px;
  height:34px;
  border-radius:11px;
  background:rgba(255,255,255,.09);
}
.portal-nav-item.active .portal-nav-icon{background:rgba(255,255,255,.40)}
.portal-nav-icon .rg-icon{width:24px;height:24px}

/* Contenedor general */
.page-shell{
  width:100%;
  max-width:1180px;
  padding:14px 12px calc(34px + env(safe-area-inset-bottom));
}
.flash-stack{margin:0 0 12px;padding:0;gap:8px}
.flash{
  padding:13px 14px;
  border-radius:14px;
  box-shadow:var(--rg-shadow-sm);
  font-size:14px;
  line-height:1.4;
}

/* Panel principal */
.personal-hero,
.portal-v071 .personal-hero{
  min-height:360px;
  margin:0 0 16px;
  padding:20px 17px;
  grid-template-columns:1fr;
  align-content:end;
  gap:16px;
  border-radius:var(--rg-radius-lg);
  background-image:
    linear-gradient(180deg,rgba(3,14,31,.05) 0,rgba(3,14,31,.35) 42%,rgba(3,14,31,.92) 78%,rgba(3,14,31,.98) 100%),
    url('/static/img/portal-hero-clean.jpg')!important;
  background-size:cover!important;
  background-position:center 36%!important;
  box-shadow:var(--rg-shadow-md);
}
.personal-hero-copy{align-self:end;padding:13px 14px;border-radius:16px;background:linear-gradient(135deg,rgba(4,18,39,.76),rgba(4,18,39,.46));box-shadow:inset 0 1px 0 rgba(255,255,255,.10);backdrop-filter:blur(3px);text-shadow:0 3px 16px rgba(0,0,0,.45)}
.personal-hero h1,
.portal-v071 .personal-hero h1{
  margin:7px 0 8px;
  font-size:clamp(32px,9vw,42px);
  line-height:1.02;
  letter-spacing:-.025em;
}
.personal-hero p,
.portal-v071 .personal-hero p{max-width:620px;font-size:15px;line-height:1.45;color:#e6edf8}
.responsibility-total,
.portal-v071 .responsibility-total{
  width:100%;
  padding:15px 16px;
  border-radius:17px;
  background:rgba(6,27,55,.74);
  border:1px solid rgba(239,214,147,.56);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.12);
  backdrop-filter:blur(8px);
}
.responsibility-total>span{font-size:10px;letter-spacing:.09em}
.responsibility-total strong,
.portal-v071 .responsibility-total strong{margin:6px 0 4px;font-size:38px;line-height:1}
.responsibility-total small{font-size:12px;line-height:1.35}

.launcher-section{
  margin:0 0 18px;
  padding:16px;
  border-radius:var(--rg-radius-lg);
  background:rgba(255,255,255,.96);
  border:1px solid var(--rg-line);
  box-shadow:var(--rg-shadow-sm);
}
.section-heading,.launcher-heading{
  margin-bottom:13px;
  padding:0;
  align-items:flex-start;
  flex-direction:column;
  gap:4px;
}
.section-kicker{font-size:10px;letter-spacing:.12em;color:var(--rg-blue-700)}
.section-heading h2{font-size:27px;line-height:1.08;letter-spacing:-.015em}
.launcher-heading p{margin:0;text-align:left;font-size:13px;line-height:1.4}
.portal-launcher-grid{grid-template-columns:1fr;gap:11px}
.portal-launch-card{
  min-height:92px;
  grid-template-columns:56px minmax(0,1fr) 28px;
  gap:12px;
  padding:14px;
  border-radius:18px;
  border-color:#d3dfed;
  box-shadow:0 6px 18px rgba(6,27,55,.07);
  transform:none;
}
.portal-launch-card:hover{transform:none;box-shadow:0 9px 24px rgba(6,27,55,.11)}
.portal-launch-card:active{transform:scale(.992)}
.portal-launch-card:before{height:4px;border-radius:18px 18px 0 0}
.portal-launch-icon{width:56px;height:56px;border-radius:17px}
.portal-launch-icon .rg-icon{width:35px;height:35px}
.portal-launch-copy{gap:5px}
.portal-launch-copy strong{font-size:23px}
.portal-launch-copy small{font-size:13px;line-height:1.25}
.portal-launch-arrow{width:28px;height:28px;font-size:18px}

.custody-section{margin-bottom:18px}
.custody-grid{grid-template-columns:1fr;gap:10px}
.custody-card{
  padding:16px;
  border-radius:18px;
  box-shadow:0 6px 18px rgba(6,27,55,.065);
}
.portal-v071 .custody-card-head,.custody-card-head{min-height:52px}
.portal-v071 .custody-icon,.custody-icon{width:50px;height:50px;border-radius:15px}
.portal-v071 .custody-icon .rg-icon,.custody-icon .rg-icon{width:30px;height:30px}
.custody-card h3{font-size:19px}
.custody-card p{min-height:0;margin-bottom:11px;font-size:13px}
.custody-amount{font-size:30px}

.install-entry-card{
  margin:0;
  padding:16px;
  border-radius:20px;
  flex-direction:column;
  align-items:stretch;
  gap:14px;
  box-shadow:var(--rg-shadow-sm);
}
.install-entry-copy{align-items:flex-start;gap:12px}
.install-entry-icon{width:48px;height:48px;flex:0 0 48px;border-radius:15px}
.install-entry-card h2{font-size:22px;line-height:1.12}
.install-entry-card p{font-size:13px}
.install-entry-actions{width:100%;display:grid;grid-template-columns:1fr;gap:9px}

/* Botones, formularios y acciones administrativas */
.btn,.button,.page-shell button,.page-shell .button{
  min-height:var(--rg-touch);
  padding:11px 16px;
  border-radius:14px;
  font-size:15px;
  font-weight:850;
  line-height:1.15;
  box-shadow:none;
}
.primary,.page-shell button:not(.secondary):not(.ghost):not(.warn):not(.danger),.page-shell .button:not(.secondary):not(.ghost):not(.warn):not(.danger){
  background:linear-gradient(135deg,var(--rg-blue-700),var(--rg-navy-900));
  box-shadow:0 8px 20px rgba(7,27,55,.20);
}
.secondary,.ghost,.page-shell .button.secondary,.page-shell button.secondary,.page-shell .btn.secondary,.page-shell .button.ghost,.page-shell button.ghost,.page-shell .btn.ghost{background:#fff;color:var(--rg-navy-800);border:1px solid #cbd8e8;box-shadow:none}
.page-shell button.danger{background:var(--rg-danger)}
.page-shell button.warn{background:var(--rg-warning)}

.page-shell>section:not(.personal-hero):not(.launcher-section):not(.custody-section):not(.alerts-panel):not(.install-entry-card),
.account-card,.transition-card{
  padding:17px;
  border-radius:20px;
  box-shadow:var(--rg-shadow-sm);
}
.page-shell>section>h2,.section-head h2,.narrow h2{margin-top:0;color:var(--rg-navy-900)}
.section-head{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin-bottom:14px}

.form-grid{grid-template-columns:1fr;gap:14px}
.form-grid label{gap:7px;font-size:14px;color:#27354f}
.form-grid input,.form-grid select,.form-grid textarea,
input,select,textarea{
  min-height:48px;
  padding:12px 13px;
  border:1px solid #bccbdd;
  border-radius:13px;
  background:#fff;
  color:var(--rg-text);
  font-size:16px;
}
textarea{min-height:112px;resize:vertical}
input:focus,select:focus,textarea:focus{
  border-color:var(--rg-blue-600);
  box-shadow:0 0 0 4px rgba(36,104,183,.13);
}
.form-grid small{font-size:12px;line-height:1.35;color:var(--rg-muted)}
.form-grid fieldset{padding:14px;border-radius:14px;background:var(--rg-surface-soft)}
.check{min-height:42px;align-items:center}
.check input{min-height:auto;width:22px!important;height:22px}
.form-actions,.actions{display:grid;grid-template-columns:1fr;gap:9px;width:100%}
.form-actions>* ,.actions>*{width:100%}
.actions form{width:100%}
.actions form button{width:100%}

.table-wrap{
  width:100%;
  overflow:auto;
  overscroll-behavior-inline:contain;
  border-radius:15px;
  box-shadow:inset -16px 0 18px -20px rgba(6,27,55,.45);
}
.table-wrap table{min-width:760px;font-size:13px}
.table-wrap th,.table-wrap td{padding:11px 12px}
.table-wrap th{position:sticky;top:0;z-index:2;background:#eaf0f8}
.table-wrap th:first-child,.table-wrap td:first-child{
  position:sticky;
  left:0;
  z-index:1;
  background:inherit;
  box-shadow:7px 0 12px -13px rgba(6,27,55,.8);
}
.table-wrap th:first-child{z-index:3;background:#eaf0f8}

.badge{padding:5px 9px;font-size:11px}
.notice,.source-warning{border-radius:15px;padding:13px 14px;font-size:14px}
.activation-result{padding:16px;border-radius:17px}
.activation-code{font-size:clamp(22px,8vw,29px);overflow-wrap:anywhere}

/* Instalación PWA */
.install-hero{
  padding:20px 17px;
  border-radius:var(--rg-radius-lg);
  flex-direction:column;
  align-items:stretch;
  gap:16px;
}
.install-hero h1{font-size:34px}
.install-hero p{font-size:15px}
.direct-install-card{padding:17px;flex-direction:column;align-items:stretch;gap:15px}
.direct-install-card h2{font-size:25px}
.install-grid{grid-template-columns:1fr;gap:14px}
.install-card{padding:19px;border-radius:20px}
.install-card h2{font-size:27px}
.install-card ol{padding-left:20px;font-size:14px;line-height:1.55}
.install-card li+li{margin-top:7px}

/* Transiciones */
.zone-transition{padding:14px}
.zone-transition-card{
  width:min(100%,430px);
  grid-template-columns:64px minmax(0,1fr);
  gap:14px;
  padding:18px;
  border-radius:22px;
}
.zone-transition-icon{width:64px;height:64px;border-radius:19px}
.zone-svg{width:40px;height:40px}
.zone-transition-copy h2{font-size:25px}
.zone-transition-spinner{grid-column:1/-1;justify-self:center}

/* Login móvil */
.login-page{background:var(--rg-navy-950)}
.portal-login-v016,.v016-stage{min-height:100svh}
.v016-stage{padding:calc(18px + env(safe-area-inset-top)) 13px calc(18px + env(safe-area-inset-bottom))}
.v016-card{
  width:min(100%,520px);
  padding:30px 20px 23px;
  border-radius:26px;
}
.v016-card:before{inset:8px;border-radius:20px}
.v016-crest{width:72px;height:72px;border-radius:22px}
.v016-crest span{font-size:36px}
.v016-heading h1{font-size:36px;margin:13px 0 7px}
.v016-heading p{font-size:15px}
.v016-kicker{font-size:10px;gap:9px}
.v016-kicker span{width:34px}
.v016-field input,.v016-control input{min-height:50px;font-size:16px}
.v016-submit{min-height:52px;border-radius:14px;font-size:16px}
.v016-footer{font-size:11px}
.login-progress{border-radius:13px;padding:12px}

/* Ajustes por anchura */
@media(min-width:520px){
  .page-shell{padding-left:18px;padding-right:18px}
  .custody-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .install-entry-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
  .form-actions,.actions{display:flex;flex-wrap:wrap;width:auto}
  .form-actions>* ,.actions>*{width:auto}
  .actions form{width:auto}
  .actions form button{width:auto}
}

@media(min-width:760px){
  .header-inner{min-height:72px;padding:11px 22px}
  .brand-mark{width:46px;height:46px;flex-basis:46px}
  .brand strong{font-size:17px}.brand small{font-size:12px}
  .portal-access-track{padding:7px 16px}
  .portal-nav-item{min-height:48px;flex-direction:row;font-size:13px;padding:6px 13px}
  .page-shell{padding:22px 20px 48px}
  .personal-hero,.portal-v071 .personal-hero{
    min-height:300px;
    grid-template-columns:minmax(0,1fr) minmax(280px,350px);
    align-items:end;
    padding:28px;
    background-image:
      linear-gradient(90deg,rgba(3,14,31,.35),rgba(3,14,31,.58) 52%,rgba(3,14,31,.86)),
      url('/static/img/portal-hero-clean.jpg')!important;
    background-position:center 45%!important;
  }
  .personal-hero-copy{padding:0;background:none;box-shadow:none;backdrop-filter:none}
  .personal-hero h1,.portal-v071 .personal-hero h1{font-size:46px}
  .responsibility-total,.portal-v071 .responsibility-total{align-self:end;padding:19px 21px}
  .responsibility-total strong,.portal-v071 .responsibility-total strong{font-size:45px}
  .launcher-section{padding:21px}
  .section-heading,.launcher-heading{flex-direction:row;align-items:flex-end;justify-content:space-between}
  .launcher-heading p{text-align:right;max-width:430px}
  .portal-launcher-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:13px}
  .portal-launch-card{grid-template-columns:58px minmax(0,1fr);min-height:132px;align-content:center}
  .portal-launch-arrow{position:absolute;right:14px;bottom:14px}
  .custody-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .install-entry-card{flex-direction:row;align-items:center;padding:20px}
  .install-entry-actions{width:auto;display:flex}
  .page-shell>section:not(.personal-hero):not(.launcher-section):not(.custody-section):not(.alerts-panel):not(.install-entry-card),.account-card,.transition-card{padding:22px}
  .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .install-hero{padding:28px;flex-direction:row;align-items:center}
  .install-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:18px}
  .v016-card{padding:42px 46px 30px;border-radius:34px}
  .v016-card:before{border-radius:26px}
  .v016-heading h1{font-size:46px}
}

@media(min-width:1024px){
  .page-shell{padding-top:26px}
  .portal-launch-card{transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease}
  .portal-launch-card:hover{transform:translateY(-3px)}
}

@media(max-width:380px){
  .brand small{display:none}
  .brand strong{font-size:14px}
  .user-chip{display:none}
  .header-logout{width:44px;padding:0}
  .header-logout span{display:none}
  .portal-nav-item{min-width:72px;flex-direction:column;font-size:10px;padding:5px 7px}
  .personal-hero,.portal-v071 .personal-hero{min-height:345px;padding:18px 15px}
  .personal-hero h1,.portal-v071 .personal-hero h1{font-size:30px}
  .launcher-section{padding:14px}
  .portal-launch-card{grid-template-columns:52px minmax(0,1fr) 24px;padding:12px;gap:10px}
  .portal-launch-icon{width:52px;height:52px}
  .portal-launch-copy strong{font-size:21px}
}

@media(orientation:landscape) and (max-height:520px){
  .personal-hero,.portal-v071 .personal-hero{min-height:260px;background-position:center 42%!important}
  .v016-stage{padding-top:12px;padding-bottom:12px}
  .v016-card{padding-top:24px;padding-bottom:20px}
  .v016-crest{width:58px;height:58px;border-radius:18px}
  .v016-heading h1{font-size:32px}
}

@media(prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
