/* ============================================================
   Alertas Escolares · Design tokens (paleta derivada del logo)
   Marino institucional #0B2545 · Azul acero #1E6191 · Ámbar alerta #D97706
   ============================================================ */
:root, [data-theme="light"] {
  --brand-navy:    #0B2545;
  --brand-steel:   #1E6191;
  --brand-amber:   #D97706;

  --bg-primary:    #FFFFFF;
  --bg-secondary:  #F3F5F8;
  --bg-tertiary:   #E6EAF0;
  --surface:       #FFFFFF;
  --text-primary:  #0F1B2D;
  --text-secondary:#43526A;
  --text-muted:    #6B7A90;
  --border:        #D3DAE4;
  --accent:        #0B2545;
  --accent-hover:  #133A68;
  --accent-text:   #FFFFFF;
  --link:          #1E6191;
  --danger:        #B42318;
  --success:       #17803D;
  --warning:       #B45309;
  --shadow:        rgba(11, 37, 69, .08);

  /* Clasificación de alertas */
  --cl-info:       #1E6191;  --cl-info-bg:  #E8F1F8;
  --cl-prev:       #B45309;  --cl-prev-bg:  #FDF3E3;
  --cl-urg:        #B42318;  --cl-urg-bg:   #FDECEA;
}
[data-theme="dark"] {
  --bg-primary:    #0A1220;
  --bg-secondary:  #111B2C;
  --bg-tertiary:   #1A2638;
  --surface:       #111B2C;
  --text-primary:  #EDF1F7;
  --text-secondary:#A9B5C7;
  --text-muted:    #7D8AA0;
  --border:        #26344A;
  --accent:        #4F8CC9;
  --accent-hover:  #6BA0D6;
  --accent-text:   #06101E;
  --link:          #7FB0E0;
  --danger:        #F0645A;
  --success:       #4CC27B;
  --warning:       #F0A23B;
  --shadow:        rgba(0, 0, 0, .45);
  --cl-info:       #7FB0E0;  --cl-info-bg:  #12263D;
  --cl-prev:       #F0A23B;  --cl-prev-bg:  #2E2210;
  --cl-urg:        #F0645A;  --cl-urg-bg:   #351614;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.6;
  background: var(--bg-secondary); color: var(--text-primary);
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 600; margin: 0; line-height: 1.25; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 18px; } h4 { font-size: 15px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.muted { color: var(--text-muted); }
[hidden] { display: none !important; }
i[data-lucide], svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }

/* ---------- Topbar institucional ---------- */
.topbar {
  position: sticky; top: 0; z-index: 900;
  background: var(--brand-navy); color: #fff;
  border-bottom: 3px solid var(--brand-amber);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .6rem 1.5rem;
  display: flex; align-items: center; gap: 1rem; min-height: 60px;
}
.brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 40px; height: 40px; background: #fff; border-radius: 6px; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand-sub  { font-size: 12px; color: #B9C6D8; letter-spacing: .04em; text-transform: uppercase; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 8px;
  padding: 0 .75rem; font: inherit; font-size: 14px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
[data-theme="light"] .icon-dark, [data-theme="dark"] .icon-light { display: none; }

/* ---------- Layout ---------- */
.vista-container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.vista { animation: slideIn .26s cubic-bezier(.4,0,.2,1); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .vista { animation: none; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.15rem; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, transform .1s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-amber { background: var(--brand-amber); color: #1B1200; }
.btn-amber:hover { background: #C26A05; }
.btn-ghost { background: transparent; color: var(--link); padding-left: .25rem; padding-right: .25rem; }
.btn-block { width: 100%; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field input, .field select {
  min-height: 46px; padding: .6rem .8rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-primary);
  font: inherit; font-size: 15px; outline: none; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--brand-steel); box-shadow: 0 0 0 3px rgba(30,97,145,.18); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.password-field { position: relative; }
.password-field input { padding-right: 3rem; }
.toggle-password {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; background: none; border: none; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Selector de perfil (segmented) */
.segmented { display: flex; border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 4px; background: var(--bg-secondary); margin-bottom: 1.25rem; }
.segmented button {
  flex: 1; min-height: 44px; border: none; border-radius: 7px; background: transparent;
  color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .35rem; padding: 0 .4rem;
}
.segmented button.active { background: var(--surface); color: var(--text-primary); box-shadow: 0 1px 3px var(--shadow); }

/* ---------- Auth layout (asimétrico: panel institucional + formulario) ---------- */
.auth-wrap { min-height: calc(100vh - 63px); display: flex; }
.auth-side {
  flex: 0 0 42%; background: var(--brand-navy) url('/assets/img/auth-lluvia-sm.jpg') center/cover no-repeat; isolation: isolate; color: #E6ECF4; padding: 3rem 2.5rem;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(8,26,50,.92) 0%, rgba(8,26,50,.78) 55%, rgba(8,26,50,.94) 100%); }
.auth-side::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 360px; height: 360px;
  border: 40px solid rgba(255,255,255,.04); border-radius: 50%;
}
.auth-side h2 { color: #fff; font-size: 26px; margin: 1.25rem 0 .75rem; }
.auth-side p { color: #B9C6D8; max-width: 380px; }
.auth-side .emblem { width: 88px; height: 88px; background: #fff; border-radius: 12px; padding: 6px; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--bg-primary); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 24px; margin-bottom: .35rem; }
.auth-card .sub { color: var(--text-secondary); margin: 0 0 1.5rem; }
.auth-foot { margin-top: 1.25rem; font-size: 14px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; }

/* Leyenda de clasificación (franja lateral + jerarquía tipográfica) */
.cls-legend { display: flex; flex-direction: column; gap: .6rem; margin-top: 2rem; position: relative; z-index: 1; }
.cls-item { display: flex; align-items: center; gap: .75rem; font-size: 14px; color: #DCE4EF; }
.cls-dot { width: 10px; height: 28px; border-radius: 2px; }
.cls-dot.info { background: #4F8CC9; } .cls-dot.prev { background: var(--brand-amber); } .cls-dot.urg { background: #E5483B; }

.cls-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 4px; }
.cls-badge.informativa { color: var(--cl-info); background: var(--cl-info-bg); }
.cls-badge.preventiva  { color: var(--cl-prev); background: var(--cl-prev-bg); }
.cls-badge.urgente     { color: #fff; background: var(--cl-urg); }

/* ---------- Home ---------- */
.hero { background: var(--brand-navy); color: #fff; position: relative; overflow: hidden; isolation: isolate; }
.hero-photo { position: absolute; inset: 0; z-index: -2; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 55%; display: block; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(8,26,50,.96) 0%, rgba(8,26,50,.86) 42%, rgba(8,26,50,.35) 75%, rgba(8,26,50,.15) 100%); }
.hero-inner { max-width: 1200px; margin: 0 auto; padding: 5rem 1.5rem 6rem; display: flex; gap: 3rem; align-items: center; }
.hero-copy { flex: 1 1 58%; }
.hero-copy .label { color: #F6B65A; }
.hero-copy h1 { font-size: 40px; line-height: 1.1; margin: .75rem 0 1rem; max-width: 640px; }
.hero-copy p { color: #C3CEDD; font-size: 17px; max-width: 560px; margin: 0 0 2rem; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.hero-actions .btn-secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.hero-actions .btn-secondary:hover { background: rgba(255,255,255,.08); }
.hero-emblem { flex: 0 0 300px; display: flex; justify-content: flex-end; align-self: flex-end; }
.hero-emblem .emb-card { background: rgba(255,255,255,.96); color: var(--text-primary); padding: 1rem 1.1rem; border-left: 5px solid var(--brand-amber); max-width: 300px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.hero-emblem .emb-card img { width: 52px; height: 52px; float: left; margin-right: .75rem; }
.hero-emblem .emb-card strong { display: block; color: #0B2545; font-size: 15px; }
.hero-emblem .emb-card span { font-size: 13px; color: #43526A; }
.hero-strip { height: 6px; background: linear-gradient(90deg, #4F8CC9 0 33%, var(--brand-amber) 33% 66%, #E5483B 66%); }

.home-grid { display: flex; gap: 1.25rem; margin-top: -2.5rem; position: relative; flex-wrap: wrap; }
.role-card { flex: 1 1 260px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--brand-steel); padding: 1.5rem; box-shadow: 0 6px 24px var(--shadow); }
.role-card:nth-child(2) { border-top-color: var(--brand-amber); margin-top: 1.25rem; }
.role-card:nth-child(3) { border-top-color: var(--brand-navy); }
[data-theme="dark"] .role-card:nth-child(3) { border-top-color: var(--accent); }
.role-card .ic { width: 44px; height: 44px; border-radius: 8px; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; color: var(--brand-steel); margin-bottom: .9rem; }
.role-card h3 { margin-bottom: .4rem; }
.role-card p { color: var(--text-secondary); margin: 0 0 1rem; font-size: 14px; }

.cls-section { margin-top: 3rem; display: flex; gap: 2.5rem; flex-wrap: wrap; align-items: flex-start; }
.cls-section > div:first-child { flex: 1 1 300px; }
.cls-section > div:first-child p { color: var(--text-secondary); }
.cls-samples { flex: 1 1 420px; display: flex; flex-direction: column; gap: .75rem; }
.cls-sample { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--cl-info); padding: 1rem 1.25rem; }
.cls-sample.preventiva { border-left-color: var(--cl-prev); }
.cls-sample.urgente { border-left-color: var(--cl-urg); background: var(--cl-urg-bg); }
.cls-sample h4 { margin: .4rem 0 .15rem; }
.cls-sample p { margin: 0; font-size: 14px; color: var(--text-secondary); }

.site-footer { margin-bottom: 0; border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.5rem; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- Panel ---------- */
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.panel-head h1 { margin-top: .25rem; }
.perfil-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 4px; background: var(--bg-tertiary); color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.panel-layout { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }
.panel-main { flex: 1 1 560px; display: flex; flex-direction: column; gap: 1rem; }
.panel-side { flex: 0 1 340px; display: flex; flex-direction: column; gap: 1rem; }
.box { background: var(--surface); border: 1px solid var(--border); padding: 1.25rem 1.35rem; }
.box h3 { margin-bottom: .75rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--text-muted); }
.kv span:last-child { font-weight: 600; text-align: right; word-break: break-word; }
.module-list { display: flex; flex-direction: column; }
.module { display: flex; align-items: center; gap: .9rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.module:last-child { border-bottom: none; }
.module .ic { width: 40px; height: 40px; border-radius: 8px; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; color: var(--brand-steel); }
.module div { flex: 1; }
.module strong { display: block; font-size: 15px; }
.module small { color: var(--text-muted); font-size: 13px; }
.tag-soon { font-size: 12px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: .1rem .45rem; white-space: nowrap; }

/* ---------- Estados ---------- */
.state { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.state .ic { width: 56px; height: 56px; margin: 0 auto 1rem; border-radius: 50%; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; }
.state h3 { color: var(--text-primary); margin-bottom: .5rem; }
.loader { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand-steel); border-radius: 50%; animation: spin .8s linear infinite; margin: 4rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%);
  padding: .75rem 1.25rem; border-radius: 8px; font-size: 14px; font-weight: 500;
  z-index: 9999; max-width: calc(100vw - 2rem); pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: slideIn .2s ease;
}
.toast-error   { background: var(--danger);  color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast-info    { background: var(--brand-navy); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .hero-emblem { flex-basis: 240px; }
}
@media (max-width: 768px) {
  .topbar-inner { padding: .5rem 1rem; }
  .brand-sub { display: none; }
  .vista-container { padding: 1.25rem 1rem; }
  .hero-inner { flex-direction: column-reverse; align-items: flex-start; padding: 2.5rem 1rem 4rem; gap: 1.5rem; }
  .hero-copy h1 { font-size: 30px; }
  .hero-emblem { display: none; }
  .hero::before { background: linear-gradient(180deg, rgba(8,26,50,.72) 0%, rgba(8,26,50,.93) 60%); }
  .role-card:nth-child(2) { margin-top: 0; }
  .auth-wrap { flex-direction: column; }
  .auth-side { flex-basis: auto; padding: 1.5rem 1rem; flex-direction: row; align-items: center; gap: 1rem; }
  .auth-side .emblem { width: 56px; height: 56px; }
  .auth-side h2 { font-size: 18px; margin: 0; } .auth-side p, .auth-side .cls-legend { display: none; }
  .auth-main { padding: 1.5rem 1rem 3rem; align-items: flex-start; }
  .btn-label-desk { display: none; }
}

/* ============================================================
   FASE 2 · Shell PWA, navegación por rol, componentes
   ============================================================ */
body.no-scroll { overflow: hidden; }
.ripple-target, .btn, .icon-btn, .menu-tile, .footnav a, .chip { position: relative; overflow: hidden; }
.ripple-wave { position: absolute; border-radius: 50%; background: currentColor; opacity: .18; transform: scale(0); animation: ripple .6s linear; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* Topnav desktop */
.topnav { display: flex; gap: .25rem; margin-left: 1.5rem; }
.topnav-link { display: inline-flex; align-items: center; gap: .45rem; height: 40px; padding: 0 .8rem; border-radius: 6px; color: #C9D4E3; font-size: 14px; font-weight: 500; }
.topnav-link:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.topnav-link.active { color: #fff; background: rgba(255,255,255,.1); box-shadow: inset 0 -2px 0 var(--brand-amber); }
.btn-install { border-color: var(--brand-amber); color: #FCD9A6; }
#topbar-user { display: contents; }

/* Footer nativo mobile */
.footnav { display: none; }
@media (max-width: 768px) {
  .topnav, .btn-install { display: none !important; }
  .footnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
    height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px var(--shadow);
  }
  .footnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 12px; font-weight: 500; color: var(--text-muted); text-decoration: none; min-height: 44px; }
  .footnav a.active { color: var(--brand-steel); }
  [data-theme="dark"] .footnav a.active { color: var(--accent); }
  .footnav a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; background: var(--brand-amber); border-radius: 0 0 3px 3px; }
  #app { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
.modo-app .topbar { padding-top: env(safe-area-inset-top); }

/* Sheet / modal (máx 90vh, scroll interno, footer fijo) */
.sheet-wrap { position: fixed; inset: 0; z-index: 2000; background: rgba(6,16,30,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--bg-primary); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: up .22s cubic-bezier(.4,0,.2,1); }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.sheet-body { flex: 1; overflow-y: auto; padding: 1.25rem; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }
.icon-btn-plain { width: 44px; height: 44px; border: none; background: none; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.icon-btn-plain:hover { background: var(--bg-tertiary); }
@media (max-width: 768px) {
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.menu-user { display: flex; flex-direction: column; padding: .25rem 0 1rem; margin-bottom: 1rem; border-bottom: 1px dashed var(--border); }
.menu-user span { font-size: 13px; color: var(--text-muted); }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.menu-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45rem; min-height: 88px; padding: .75rem .4rem;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font: inherit; font-size: 13px; font-weight: 600; text-align: center; cursor: pointer; }
.menu-tile:hover { text-decoration: none; border-color: var(--brand-steel); }
.menu-tile i { color: var(--brand-steel); width: 22px; height: 22px; }
.menu-tile.danger, .menu-tile.danger i { color: var(--danger); }
.install-body { text-align: center; }
.install-body img { border-radius: 16px; }
.install-steps { text-align: left; line-height: 2.1; padding-left: 1.25rem; }
.install-steps i { width: 16px; height: 16px; vertical-align: -3px; }

/* Splash */
#splash { position: fixed; inset: 0; z-index: 5000; background: #081A32; display: flex; align-items: center; justify-content: center; transition: opacity .45s; }
#splash.out { opacity: 0; }
#splash .splash-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .28; }
.splash-inner { position: relative; text-align: center; color: #fff; padding: 1.5rem; }
.splash-logo { background: #fff; border-radius: 22px; padding: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.splash-inner h1 { margin: 1.25rem 0 .35rem; font-size: 26px; }
.splash-inner p { color: #B9C6D8; margin: 0 0 1.75rem; }
.splash-track { width: 220px; height: 3px; margin: 0 auto; background: rgba(255,255,255,.18); border-radius: 2px; overflow: hidden; }
#splash-bar { width: 0; height: 100%; background: var(--brand-amber); }
#splash-skip { margin-top: 1.5rem; background: none; border: 1px solid rgba(255,255,255,.3); color: #DCE4EF; border-radius: 20px; padding: .45rem 1.1rem; min-height: 44px; font: inherit; font-size: 13px; cursor: pointer; }

/* Offline + pull to refresh */
#offline-banner { position: sticky; top: 0; z-index: 1000; background: var(--warning); color: #fff; text-align: center; font-size: 13px; font-weight: 600; padding: .5rem 1rem; display: flex; gap: .5rem; align-items: center; justify-content: center; }
#ptr { position: fixed; top: 0; left: 50%; transform: translate(-50%, -60px); z-index: 1500; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--brand-steel); box-shadow: 0 4px 14px var(--shadow); display: flex; align-items: center; justify-content: center; transition: transform .15s; pointer-events: none; }
#ptr.spin { transform: translate(-50%, 70px) !important; } #ptr.spin svg { animation: spin .8s linear infinite; }

/* ---------- Encabezado de vista ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.view-head h1 { margin-top: .3rem; }
.view-head p { margin: .35rem 0 0; color: var(--text-secondary); max-width: 640px; }

/* ---------- Tarjeta de ALERTA (clasificación = color + jerarquía) ---------- */
.alertas { display: flex; flex-direction: column; gap: .85rem; }
.alerta { display: flex; background: var(--surface); border: 1px solid var(--border); position: relative; }
.alerta-rail { flex: 0 0 52px; display: flex; justify-content: center; padding-top: 1.05rem; background: var(--cl-info-bg); color: var(--cl-info); border-right: 4px solid var(--cl-info); }
.alerta-rail svg { width: 22px; height: 22px; }
.alerta-body { flex: 1; padding: .95rem 1.15rem 1rem; min-width: 0; }
.alerta-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.alerta-tipo { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); }
.alerta-time { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.alerta-titulo { font-size: 16px; margin: .45rem 0 .3rem; color: var(--text-primary); }
.alerta-msg { margin: 0 0 .6rem; color: var(--text-secondary); font-size: 14px; white-space: normal; word-wrap: break-word; }
.alerta-dest { display: flex; align-items: center; gap: .35rem; font-size: 13px; color: var(--text-muted); }
.alerta-dest svg { width: 14px; height: 14px; }
.alerta.compact .alerta-titulo { margin-bottom: .25rem; font-size: 15px; }

.alerta-preventiva .alerta-rail { background: var(--cl-prev-bg); color: var(--cl-prev); border-right-color: var(--cl-prev); }
/* URGENTE: máxima jerarquía — franja roja completa, fondo tintado, título grande, borde reforzado */
.alerta-urgente { border: 2px solid var(--cl-urg); background: var(--cl-urg-bg); }
.alerta-urgente .alerta-rail { background: var(--cl-urg); color: #fff; border-right-color: var(--cl-urg); }
.alerta-urgente .alerta-titulo { font-size: 18px; font-weight: 700; }
.alerta-urgente .alerta-msg { color: var(--text-primary); }
.alerta-urgente .alerta-tipo { color: var(--cl-urg); }
@media (prefers-reduced-motion: no-preference) {
  .alerta-urgente .alerta-rail svg { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(1.15); } }
}

/* Leyenda compacta de clasificación (en feeds) */
.cls-key { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.cls-key span { display: inline-flex; align-items: center; gap: .4rem; }
.cls-key b { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.cls-key .k-info { background: var(--cl-info); } .cls-key .k-prev { background: var(--cl-prev); } .cls-key .k-urg { background: var(--cl-urg); }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.chip { min-height: 40px; padding: 0 .9rem; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.chip.active { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
[data-theme="dark"] .chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.c-urgente.active { background: var(--cl-urg); border-color: var(--cl-urg); color: #fff; }
.chip.c-preventiva.active { background: var(--cl-prev); border-color: var(--cl-prev); color: #fff; }
.search { position: relative; flex: 1 1 220px; }
.search input { width: 100%; min-height: 44px; padding: .5rem .8rem .5rem 2.4rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); font: inherit; outline: none; }
.search input:focus { border-color: var(--brand-steel); }
.search svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.select-sm { min-height: 44px; padding: 0 .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-primary); font: inherit; font-size: 14px; }
.pager { display: flex; justify-content: center; gap: .5rem; margin-top: 1.25rem; align-items: center; font-size: 14px; color: var(--text-muted); }

/* ---------- KPIs del inicio (asimétricos) ---------- */
.kpis { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.kpi { flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border); padding: 1rem 1.15rem; border-left: 4px solid var(--brand-steel); }
.kpi.kpi-urg { border-left-color: var(--cl-urg); }
.kpi.kpi-amber { border-left-color: var(--brand-amber); }
.kpi .n { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.callout { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.25rem; background: var(--cl-info-bg); border: 1px solid var(--border); border-left: 4px solid var(--brand-amber); margin-bottom: 1.25rem; flex-wrap: wrap; }
.callout div { flex: 1 1 260px; }
.callout strong { display: block; }
.callout p { margin: .15rem 0 0; font-size: 14px; color: var(--text-secondary); }

/* ---------- Suscripciones ---------- */
.subs-layout { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: flex-start; }
.subs-picker { flex: 1 1 560px; }
.subs-mine { flex: 0 1 360px; position: sticky; top: 80px; }
.steps { display: flex; gap: .5rem; margin-bottom: 1rem; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }
.steps span { display: inline-flex; align-items: center; gap: .35rem; }
.steps b { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-tertiary); color: var(--text-secondary); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.steps .on b { background: var(--brand-navy); color: #fff; }
.loc-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.loc-btn { min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; gap: .5rem; align-items: center; }
.loc-btn small { color: var(--text-muted); font-weight: 500; }
.loc-btn.active { border-color: var(--brand-navy); box-shadow: inset 0 0 0 1px var(--brand-navy); background: var(--bg-secondary); }
[data-theme="dark"] .loc-btn.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.loc-all { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.15rem; border: 1px dashed var(--brand-steel); background: var(--cl-info-bg); margin: 1rem 0; flex-wrap: wrap; }
.loc-all div { flex: 1 1 240px; }
.loc-all p { margin: .1rem 0 0; font-size: 13px; color: var(--text-secondary); }
.esc-list { display: flex; flex-direction: column; border: 1px solid var(--border); background: var(--surface); }
.esc-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.esc-row:last-child { border-bottom: none; }
.esc-row .ic { width: 40px; height: 40px; border-radius: 8px; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; color: var(--brand-steel); flex-shrink: 0; }
.esc-row div { flex: 1; min-width: 0; }
.esc-row strong { display: block; font-size: 15px; }
.esc-row small { color: var(--text-muted); font-size: 13px; }
.nivel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .1rem .4rem; border-radius: 3px; background: var(--bg-tertiary); color: var(--text-secondary); margin-left: .35rem; vertical-align: 1px; }
.btn-sm { min-height: 40px; padding: .35rem .85rem; font-size: 14px; }
.btn-follow.on { background: var(--success); color: #fff; border-color: var(--success); }
.sub-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px dashed var(--border); }
.sub-item:last-child { border-bottom: none; }
.sub-item div { flex: 1; min-width: 0; }
.sub-item strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-item small { color: var(--text-muted); font-size: 12px; }
.sub-item .ic { color: var(--brand-steel); }
@media (max-width: 768px) { .subs-mine { position: static; flex-basis: 100%; order: -1; } }

/* ---------- Guía ---------- */
.guia-niveles { display: flex; flex-direction: column; gap: 1rem; }
.nivel-row { display: flex; gap: 1.25rem; align-items: stretch; flex-wrap: wrap; }
.nivel-row .nivel-info { flex: 0 1 280px; }
.nivel-row .nivel-info h3 { margin: .5rem 0 .35rem; }
.nivel-row .nivel-info p { margin: 0; font-size: 14px; color: var(--text-secondary); }
.nivel-row .nivel-info ul { margin: .5rem 0 0; padding-left: 1.1rem; font-size: 14px; color: var(--text-secondary); }
.nivel-row .alerta { flex: 1 1 380px; }
.tipos-grid { display: flex; flex-wrap: wrap; gap: .75rem; }
.tipo-item { flex: 1 1 220px; display: flex; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--border); padding: .8rem 1rem; }
.tipo-item .ic { width: 40px; height: 40px; border-radius: 8px; background: var(--bg-secondary); display: flex; align-items: center; justify-content: center; color: var(--brand-steel); }
.tipo-item small { display: block; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.section-title { margin: 2.25rem 0 1rem; }

/* ---------- Tour ---------- */
#tour-tip { position: fixed; z-index: 3002; background: var(--bg-primary); color: var(--text-primary); padding: 1rem 1.15rem; border-radius: 10px; max-width: 290px; box-shadow: 0 10px 40px rgba(0,0,0,.45); border: 1px solid var(--border); }
#tour-tip h4 { margin: 0 0 .3rem; }
#tour-tip p { margin: 0 0 .75rem; font-size: 14px; color: var(--text-secondary); }
.tour-target { position: relative; z-index: 3001 !important; box-shadow: 0 0 0 4px var(--brand-amber), 0 0 0 9999px rgba(6,16,30,.65) !important; border-radius: 8px; }
/* Topbar: nada se parte en dos líneas */
.topnav-link, .icon-btn, .brand-name { white-space: nowrap; }
@media (max-width: 1280px) { .brand-sub { display: none; } .btn-install .btn-label-desk { display: none; } }
@media (max-width: 1100px) and (min-width: 769px) { .topnav { margin-left: .75rem; } .topnav-link span { display: none; } .topnav-link { padding: 0 .7rem; } }
.tipo-item .ic { flex-shrink: 0; }
