/* ALERTA PERÚ · sistema visual
 * Azul institucional como base, verde de servicio como acento,
 * rojo reservado para alertas críticas y riesgo. Sin dependencias externas. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../vendor/inter/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../vendor/inter/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../vendor/inter/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../vendor/inter/inter-latin-700-normal.woff2") format("woff2"); }

:root {
  --ap-navy-950: #061528;
  --ap-navy-900: #0B2545;
  --ap-navy-800: #13315C;
  --ap-navy-700: #1D4373;
  --ap-navy-100: #E6EDF6;
  --ap-navy-50:  #F3F6FB;
  --ap-green-700: #165A44;
  --ap-green-600: #1E6B52;
  --ap-green-100: #DDF0E8;
  --ap-gold-500: #E5B94E;
  --ap-red-700: #A50E25;
  --ap-red-600: #C8102E;
  --ap-red-50:  #FDECEE;
  --ap-amber-600: #B26B00;
  --ap-amber-50: #FFF5E0;
  --ap-ink: #14213D;
  --ap-muted: #5B6B82;
  --ap-line: #DCE3ED;
  --ap-surface: #FFFFFF;
  --ap-bg: #F5F7FA;
  --ap-radius: 12px;
  --ap-radius-sm: 8px;
  --ap-shadow: 0 1px 2px rgba(11, 37, 69, .06), 0 4px 16px rgba(11, 37, 69, .06);
  --ap-focus: 0 0 0 3px rgba(29, 67, 115, .35);

  --bs-body-font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-color: var(--ap-ink);
  --bs-body-bg: var(--ap-bg);
  --bs-primary: var(--ap-navy-900);
  --bs-primary-rgb: 11, 37, 69;
  --bs-link-color: var(--ap-navy-700);
  --bs-link-color-rgb: 29, 67, 115;
  --bs-link-hover-color: var(--ap-navy-900);
  --bs-border-color: var(--ap-line);
  --bs-border-radius: var(--ap-radius-sm);
}

body { background: var(--ap-bg); color: var(--ap-ink); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, .h1, .h2, .h3, .h4 { color: var(--ap-navy-900); font-weight: 700; letter-spacing: -0.015em; }
.text-muted, .ap-muted { color: var(--ap-muted) !important; }
a { text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--ap-focus) !important; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: 6px; }
.skip-link:focus { left: 8px; }

/* Botones */
.btn { font-weight: 600; border-radius: 10px; padding: .6rem 1.1rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn-primary { --bs-btn-bg: var(--ap-navy-900); --bs-btn-border-color: var(--ap-navy-900); --bs-btn-hover-bg: var(--ap-navy-800); --bs-btn-hover-border-color: var(--ap-navy-800); --bs-btn-active-bg: var(--ap-navy-950); --bs-btn-disabled-bg: var(--ap-navy-700); }
.btn-success { --bs-btn-bg: var(--ap-green-600); --bs-btn-border-color: var(--ap-green-600); --bs-btn-hover-bg: var(--ap-green-700); --bs-btn-hover-border-color: var(--ap-green-700); }
.btn-outline-primary { --bs-btn-color: var(--ap-navy-900); --bs-btn-border-color: var(--ap-navy-900); --bs-btn-hover-bg: var(--ap-navy-900); --bs-btn-hover-border-color: var(--ap-navy-900); }
.btn-danger { --bs-btn-bg: var(--ap-red-600); --bs-btn-border-color: var(--ap-red-600); --bs-btn-hover-bg: var(--ap-red-700); --bs-btn-hover-border-color: var(--ap-red-700); }
.btn-light-ghost { color: #fff; border: 1px solid rgba(255,255,255,.45); background: transparent; }
.btn-light-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Cabecera pública */
.ap-topbar { background: var(--ap-navy-950); color: #C9D6E8; font-size: .85rem; }
.ap-topbar a { color: #fff; font-weight: 600; text-decoration: none; }
.ap-topbar .ap-emergency { color: #fff; }
.ap-flagbar { height: 4px; background: linear-gradient(90deg, var(--ap-red-600) 0 33.3%, #fff 33.3% 66.6%, var(--ap-red-600) 66.6%); }
.ap-header { background: var(--ap-surface); border-bottom: 1px solid var(--ap-line); }
.ap-brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ap-navy-900); }
.ap-brand img { width: 40px; height: 40px; }
.ap-brand-name { font-weight: 800; letter-spacing: .04em; font-size: 1.05rem; line-height: 1.1; }
.ap-brand-sub { display: block; font-size: .7rem; font-weight: 500; letter-spacing: .02em; color: var(--ap-muted); }
.ap-nav .nav-link { color: var(--ap-ink); font-weight: 500; padding: .5rem .8rem; border-radius: 8px; }
.ap-nav .nav-link:hover, .ap-nav .nav-link.active { background: var(--ap-navy-50); color: var(--ap-navy-900); }

/* Hero */
.ap-hero { background: radial-gradient(1200px 500px at 85% -10%, rgba(30,107,82,.35), transparent 60%), linear-gradient(160deg, var(--ap-navy-900), var(--ap-navy-950)); color: #E8EEF7; position: relative; overflow: hidden; }
.ap-hero h1 { color: #fff; font-size: clamp(2rem, 4.6vw, 3.25rem); line-height: 1.08; }
.ap-hero .lead { color: #C9D6E8; font-size: 1.15rem; max-width: 38rem; }
.ap-hero-kicker { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ap-gold-500); }
.ap-hero-panel { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); border-radius: var(--ap-radius); padding: 1.25rem; }
.ap-hero-panel .ap-step { display: flex; gap: .85rem; align-items: flex-start; padding: .65rem 0; }
.ap-hero-panel .ap-step + .ap-step { border-top: 1px solid rgba(255,255,255,.1); }
.ap-hero-panel .ap-step i { font-size: 1.25rem; color: var(--ap-gold-500); }
.ap-hero-panel strong { color: #fff; }

/* Banda de emergencia (rojo: solo riesgo) */
.ap-emergency-band { background: var(--ap-red-50); border: 1px solid #F3C2C9; border-left: 6px solid var(--ap-red-600); border-radius: var(--ap-radius); color: #5C0614; }
.ap-emergency-band .ap-number { font-size: 1.6rem; font-weight: 800; color: var(--ap-red-700); text-decoration: none; letter-spacing: .02em; }

/* Tarjetas y secciones */
.ap-section { padding: 4rem 0; }
.ap-section-alt { background: var(--ap-surface); border-top: 1px solid var(--ap-line); border-bottom: 1px solid var(--ap-line); }
.ap-eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ap-green-600); }
.ap-card { background: var(--ap-surface); border: 1px solid var(--ap-line); border-radius: var(--ap-radius); box-shadow: var(--ap-shadow); }
.ap-card-body { padding: 1.5rem; }
.ap-icon { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--ap-navy-50); color: var(--ap-navy-800); flex-shrink: 0; }
.ap-icon-green { background: var(--ap-green-100); color: var(--ap-green-700); }
.ap-icon-red { background: var(--ap-red-50); color: var(--ap-red-600); }
.ap-num { width: 34px; height: 34px; border-radius: 50%; background: var(--ap-navy-900); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.ap-check li { position: relative; padding-left: 1.75rem; margin-bottom: .6rem; list-style: none; }
.ap-check { padding-left: 0; }
.ap-check li::before { content: "\F270"; font-family: "bootstrap-icons"; position: absolute; left: 0; top: 0; color: var(--ap-green-600); }
.ap-cross li::before { content: "\F622"; color: var(--ap-red-600); }
.ap-distinction { border-top: 4px solid var(--ap-navy-700); }
.ap-distinction.is-green { border-top-color: var(--ap-green-600); }
.ap-distinction.is-gold { border-top-color: var(--ap-gold-500); }
.ap-notice { background: var(--ap-amber-50); border: 1px solid #F1D9A6; border-radius: var(--ap-radius-sm); color: #5A3A00; }
.accordion { --bs-accordion-active-bg: var(--ap-navy-50); --bs-accordion-active-color: var(--ap-navy-900); --bs-accordion-btn-focus-box-shadow: var(--ap-focus); --bs-accordion-border-color: var(--ap-line); }
.accordion-button { font-weight: 600; }
.ap-prose h2 { font-size: 1.35rem; margin-top: 2rem; }
.ap-prose p, .ap-prose li { line-height: 1.7; }

/* Pie */
.ap-footer { background: var(--ap-navy-950); color: #AFC0D6; font-size: .92rem; }
.ap-footer a { color: #E8EEF7; text-decoration: none; }
.ap-footer a:hover { text-decoration: underline; }
.ap-footer h2 { color: #fff; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }

/* Autenticación */
.ap-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .ap-auth { grid-template-columns: 5fr 7fr; } }
.ap-auth-aside { background: linear-gradient(170deg, var(--ap-navy-900), var(--ap-navy-950)); color: #C9D6E8; padding: 3rem; display: none; }
@media (min-width: 992px) { .ap-auth-aside { display: flex; flex-direction: column; justify-content: space-between; } }
.ap-auth-aside h1 { color: #fff; }
.ap-auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.ap-auth-card { width: 100%; max-width: 440px; }

/* Panel interno */
.ap-shell { display: flex; min-height: 100vh; }
.ap-sidebar { width: 264px; background: var(--ap-navy-950); color: #AFC0D6; flex-shrink: 0; display: flex; flex-direction: column; }
.ap-sidebar .ap-brand { color: #fff; padding: 1.1rem 1.25rem; }
.ap-sidebar .ap-brand-sub { color: #8FA3BE; }
.ap-side-label { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #6F86A6; padding: 1rem 1.25rem .4rem; }
.ap-side-link { display: flex; align-items: center; gap: .7rem; padding: .55rem 1.25rem; margin: 1px .6rem; border-radius: 8px; color: #C9D6E8; text-decoration: none; font-weight: 500; font-size: .95rem; }
.ap-side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.ap-side-link.active { background: var(--ap-navy-800); color: #fff; box-shadow: inset 3px 0 0 var(--ap-gold-500); }
.ap-side-foot { margin-top: auto; padding: 1rem 1.25rem; font-size: .8rem; border-top: 1px solid rgba(255,255,255,.08); }
.ap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ap-appbar { background: var(--ap-surface); border-bottom: 1px solid var(--ap-line); padding: .7rem 1.25rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 1010; }
.ap-content { padding: 1.5rem 1.25rem 3rem; }
@media (min-width: 992px) { .ap-content { padding: 2rem 2rem 3rem; } }
.ap-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.ap-page-head h1 { font-size: 1.6rem; margin: 0; }
.ap-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ap-navy-100); color: var(--ap-navy-900); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
@media (max-width: 991.98px) {
  .ap-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1040; transform: translateX(-100%); transition: transform .2s ease; }
  .ap-sidebar.is-open { transform: none; }
  .ap-backdrop { position: fixed; inset: 0; background: rgba(6,21,40,.5); z-index: 1030; display: none; }
  .ap-backdrop.is-open { display: block; }
}
@media (prefers-reduced-motion: reduce) { .ap-sidebar { transition: none; } }

/* KPIs */
.ap-kpi { padding: 1.15rem 1.25rem; }
.ap-kpi-label { font-size: .82rem; color: var(--ap-muted); font-weight: 500; }
.ap-kpi-value { font-size: 1.9rem; font-weight: 700; color: var(--ap-navy-900); line-height: 1.15; font-variant-numeric: tabular-nums; }
.ap-kpi.is-critical .ap-kpi-value { color: var(--ap-red-600); }

/* Tablas */
.ap-table { margin: 0; }
.ap-table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ap-muted); font-weight: 700; background: var(--ap-navy-50); border-bottom: 1px solid var(--ap-line); white-space: nowrap; }
.ap-table td { vertical-align: middle; }
.ap-table code, .ap-hash { font-size: .78rem; color: var(--ap-navy-700); word-break: break-all; }
.ap-empty { padding: 3rem 1rem; text-align: center; color: var(--ap-muted); }
.ap-empty i { font-size: 2rem; color: #A9B7CA; display: block; margin-bottom: .5rem; }

/* Insignias de estado */
.ap-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.ap-badge-ok { background: var(--ap-green-100); color: var(--ap-green-700); }
.ap-badge-off { background: #EEF1F5; color: #4A5A70; }
.ap-badge-warn { background: var(--ap-amber-50); color: var(--ap-amber-600); border-color: #F1D9A6; }
.ap-badge-danger { background: var(--ap-red-50); color: var(--ap-red-700); }
.ap-badge-info { background: var(--ap-navy-50); color: var(--ap-navy-800); }
.ap-demo { background: #FFF1B8; color: #5A4700; font-weight: 700; font-size: .75rem; padding: .2rem .55rem; border-radius: 6px; }

/* Formularios */
.form-label { font-weight: 600; font-size: .92rem; }
.form-control, .form-select { border-radius: 10px; padding: .6rem .8rem; border-color: #C9D3E0; }
.form-control:focus, .form-select:focus { border-color: var(--ap-navy-700); box-shadow: var(--ap-focus); }
.form-text { color: var(--ap-muted); }
.ap-perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .35rem 1.25rem; }
.ap-check-locked { opacity: .7; }

.alert { border-radius: var(--ap-radius-sm); }
.ap-flash { position: relative; }
.ap-reset-link { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
.ap-narrow { max-width: 560px; }

/* ---- Fase 2: asistente de reporte y consulta ---- */
.ap-form-container { max-width: 860px; }
.ap-mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; letter-spacing: .02em; }
.ap-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.ap-pre { white-space: pre-wrap; word-break: break-word; }

.ap-stepper { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0; counter-reset: s; }
.ap-stepper li { flex: 1; display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ap-muted); padding-bottom: .6rem; border-bottom: 3px solid var(--ap-line); }
.ap-stepper li.is-current { color: var(--ap-navy-900); font-weight: 600; border-bottom-color: var(--ap-navy-900); }
.ap-stepper li.is-done { color: var(--ap-green-700); border-bottom-color: var(--ap-green-600); }
.ap-stepper-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--ap-line); color: var(--ap-ink); font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.ap-stepper li.is-current .ap-stepper-dot { background: var(--ap-navy-900); color: #fff; }
.ap-stepper li.is-done .ap-stepper-dot { background: var(--ap-green-600); color: #fff; }
@media (max-width: 575.98px) { .ap-stepper-label { display: none; } .ap-stepper li.is-current .ap-stepper-label { display: inline; } }

.ap-choice { display: flex; flex-direction: column; gap: .25rem; height: 100%; padding: 1rem 1.1rem; border: 1px solid var(--ap-line); border-radius: var(--ap-radius); background: var(--ap-surface); color: var(--ap-ink); text-decoration: none; box-shadow: var(--ap-shadow); }
.ap-choice i { font-size: 1.4rem; color: var(--ap-navy-700); }
.ap-choice span { font-size: .88rem; color: var(--ap-muted); }
.ap-choice:hover { border-color: var(--ap-navy-700); color: var(--ap-ink); }
.ap-choice.is-selected { border: 2px solid var(--ap-green-600); }
.ap-risk-option { padding: .7rem .9rem .7rem 2.4rem; border: 1px solid var(--ap-line); border-radius: 10px; background: #fff; }
.ap-risk-option:has(input:checked) { border-color: var(--ap-navy-700); background: var(--ap-navy-50); }
.ap-risk-option:has(input[data-ap-critical]:checked) { border-color: var(--ap-red-600); background: var(--ap-red-50); }

.ap-credential { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.6rem; font-weight: 700; color: var(--ap-navy-900); letter-spacing: .06em; background: var(--ap-navy-50); border: 1px dashed var(--ap-navy-700); border-radius: 10px; padding: .6rem .9rem; word-break: break-all; }
.ap-timeline { list-style: none; padding-left: 1.1rem; margin: 0; border-left: 2px solid var(--ap-line); }
.ap-timeline li { position: relative; padding: 0 0 1rem .75rem; }
.ap-timeline li::before { content: ""; position: absolute; left: -1.53rem; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--ap-navy-700); border: 2px solid #fff; }
.ap-message { padding: .75rem .9rem; border-radius: 10px; background: var(--ap-navy-50); border: 1px solid var(--ap-line); }
.ap-message.is-mine { background: var(--ap-green-100); border-color: #BFE2D3; }

.ap-resource-phone { font-weight: 800; font-size: 1.15rem; color: var(--ap-navy-900); text-decoration: none; white-space: nowrap; }
.ap-resource-phone.is-emergency { color: var(--ap-red-700); }
.ap-resource-emergency { border-left: 5px solid var(--ap-red-600); }
.ap-count { position: absolute; top: -6px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--ap-red-600); color: #fff; font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ap-unread { background: var(--ap-navy-50); }
@media (min-width: 576px) { .w-sm-auto { width: auto !important; } }
.ap-message.is-internal { background: #FFF8E6; border-color: #F1D9A6; }

/* ---- Fase 3: estadísticas ---- */
.ap-chart { position: relative; height: 260px; }
.ap-chart.is-wide { height: 240px; }
@media (max-width: 575.98px) { .ap-chart { height: 300px; } }
figure.ap-card figcaption { color: var(--ap-navy-900); font-weight: 700; }
.ap-nav .nav-link, .ap-nav .btn { white-space: nowrap; }
