/* =========================================================
   RADAR ESTADO PERÚ — sistema de diseño (compartido público/admin)
   Azul institucional + blanco. Rojo/verde/ámbar solo como señal.
   ========================================================= */
:root {
  --blue-950: #2a0a10;
  --blue-900: #5c0b17;
  --blue-800: #8a1020;
  --blue-700: #c8102e;
  --blue-600: #d9233c;
  --blue-500: #e5484d;
  --blue-300: #f2a0a7;
  --blue-200: #f9cfd3;
  --blue-100: #fdecee;
  --blue-50:  #fff6f6;
  --white:    #ffffff;
  --ink:      #1f1a1c;
  --ink-2:    #4a3f43;
  --muted:    #7a6b70;
  --line:     #f1e4e6;
  --line-2:   #f8eff0;

  --signal-red:   #9b1c1c;
  --signal-green: #0f7a55;
  --signal-amber: #9a5800;

  --font-ui: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --font-news: Arial, "Helvetica Neue", Helvetica, sans-serif;

  --fs-xs: .78rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.2rem;
  --fs-xl: 1.5rem; --fs-2xl: 1.95rem; --fs-3xl: 2.6rem;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 26px;
  --shadow-1: 0 1px 2px rgba(92,11,23,.06), 0 1px 3px rgba(92,11,23,.05);
  --shadow-2: 0 6px 18px -6px rgba(92,11,23,.16), 0 2px 6px rgba(92,11,23,.05);
  --shadow-3: 0 24px 60px -18px rgba(42,10,16,.35);
  --ring: 0 0 0 4px rgba(229,72,77,.18);
  --wrap: 1220px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-ui); font-size: var(--fs-md); line-height: 1.55;
  color: var(--ink); background: var(--blue-50); -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; color: var(--ink); letter-spacing: -.012em; }
h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2 { font-size: var(--fs-xl); font-weight: 750; }
h3 { font-size: var(--fs-lg); font-weight: 700; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
code { font-size: .88em; background: var(--blue-100); color: var(--blue-900); padding: .1em .4em; border-radius: 5px; }
.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--white); padding: .5rem 1rem; z-index: 200; border-radius: var(--r-sm); }
.skip-link:focus { left: 1rem; top: 1rem; }
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

/* ---------- Enlaces: sin subrayado en todo el sistema ---------- */
a { color: var(--blue-700); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--blue-900); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: var(--r-sm);
}
.link { font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.link .ico { transition: transform .15s var(--ease); }
.link:hover .ico { transform: translateX(3px); }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: .65rem; color: var(--blue-950); }
.brand:hover { color: var(--blue-950); }
.brand__mark { width: 56px; height: 56px; flex: none; }
.brand__name { font-weight: 800; font-size: 1.05rem; letter-spacing: -.015em; line-height: 1.1; }
.brand__name span { display: block; font-weight: 500; font-size: var(--fs-xs); color: var(--muted); letter-spacing: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 42px; padding: .55rem 1.1rem; font: 650 var(--fs-sm)/1.2 var(--font-ui);
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--blue-700); color: var(--white); box-shadow: 0 6px 14px -6px rgba(200,16,46,.6); }
.btn--primary:hover { background: var(--blue-800); color: var(--white); }
.btn--ghost { background: var(--white); color: var(--blue-800); border-color: var(--line); box-shadow: var(--shadow-1); }
.btn--ghost:hover { border-color: var(--blue-300); color: var(--blue-900); }
.btn--soft { background: var(--blue-100); color: var(--blue-800); }
.btn--soft:hover { background: var(--blue-200); color: var(--blue-900); }
.btn--apply { background: linear-gradient(135deg, var(--blue-700), var(--blue-900)); color: var(--white); box-shadow: 0 10px 22px -10px rgba(92,11,23,.8); }
.btn--apply:hover { color: var(--white); filter: brightness(1.08); }
.btn--white { background: var(--white); color: var(--blue-900); }
.btn--white:hover { color: var(--blue-700); }
.btn--danger { background: var(--white); color: var(--signal-red); border-color: #f1c9cc; }
.btn--danger:hover { background: #fdf1f2; color: var(--signal-red); }
.btn--danger-solid { background: var(--signal-red); color: var(--white); }
.btn--sm { min-height: 34px; padding: .35rem .75rem; font-size: var(--fs-xs); border-radius: 7px; }
.btn--lg { min-height: 52px; padding: .75rem 1.6rem; font-size: var(--fs-md); border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { width: 38px; min-height: 38px; padding: 0; }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 650; font-size: var(--fs-sm); margin-bottom: .35rem; color: var(--blue-950); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 42px; padding: .55rem .8rem; font: inherit; font-size: var(--fs-sm); color: var(--ink);
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
select { appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a6b70' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px; }
input:hover, select:hover, textarea:hover { border-color: var(--blue-200); }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); outline: none; box-shadow: var(--ring); }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 1rem; }
.field small { display: block; margin-top: .3rem; font-size: var(--fs-xs); }
.field-error { color: var(--signal-red); font-size: var(--fs-xs); margin-top: .3rem; }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 500; cursor: pointer; margin-bottom: .5rem; }
.check input { width: 18px; height: 18px; accent-color: var(--blue-700); }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input, .input-icon select { padding-left: 2.4rem; }

/* ---------- Barra de filtros (horizontal, ordenada) ---------- */
.filterbar { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: .9rem; margin-bottom: 1.2rem; }
.filterbar__grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.filterbar__grid .field { margin: 0; }
.filterbar__grid label { font-size: var(--fs-xs); color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.filterbar__actions { display: flex; gap: .5rem; align-items: end; }
.filterbar__wide { grid-column: span 2; }
@media (max-width: 640px) { .filterbar__wide { grid-column: auto; } }

/* ---------- Pestañas tipo píldora ---------- */
.pills { display: flex; gap: .35rem; flex-wrap: wrap; padding: .3rem; background: var(--white); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; overflow-x: auto; box-shadow: var(--shadow-1); }
.pills a, .pills button { border: 0; background: none; padding: .45rem .95rem; border-radius: 999px; font: 650 var(--fs-xs)/1.2 var(--font-ui); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.pills a:hover, .pills button:hover { color: var(--blue-800); background: var(--blue-50); }
.pills .is-active, .pills [aria-selected="true"] { background: var(--blue-700); color: var(--white); }
.pills .is-active:hover { color: var(--white); background: var(--blue-700); }
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a, .tabs button { border: 1px solid var(--line); background: var(--white); padding: .4rem .85rem; border-radius: 999px; font: 650 var(--fs-xs)/1.4 var(--font-ui); color: var(--blue-800); cursor: pointer; }
.tabs [aria-selected="true"], .tabs .is-active { background: var(--blue-700); color: var(--white); border-color: var(--blue-700); }

/* ---------- Estados y etiquetas ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 650; background: var(--blue-100); color: var(--blue-800); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--vigente { background: #e2f5ec; color: var(--signal-green); }
.badge--por_vencer { background: #fdf0dc; color: var(--signal-amber); }
.badge--vencida, .badge--cerrada, .badge--cancelada, .badge--desierta, .badge--suspendida { background: #eef1f6; color: #4c5a72; }
.badge--concluida { background: #e8ecf4; color: var(--blue-900); }
.badge--error_fuente, .badge--no_verificable { background: #fbe7e9; color: var(--signal-red); }
.badge--proxima { background: var(--blue-100); color: var(--blue-700); }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--blue-50); color: var(--ink-2); border: 1px solid var(--line-2); padding: .25rem .65rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.chip .ico { color: var(--blue-600); }
.sector { font-size: .7rem; font-weight: 750; padding: .12rem .5rem; border-radius: 5px; letter-spacing: .03em; text-transform: uppercase; }
.sector--PUBLICO { color: var(--blue-700); background: var(--blue-100); }
.sector--PRIVADO { color: #5b3fa6; background: #efeafb; }
.sector--OTRO { color: var(--muted); background: var(--line-2); }
.flag { display: inline-flex; align-items: center; font-size: .7rem; font-weight: 750; padding: .18rem .55rem; border-radius: 6px; margin-right: .3rem; letter-spacing: .02em; }
.flag--new { background: var(--blue-700); color: var(--white); }
.flag--upd { background: var(--blue-100); color: var(--blue-800); }
.flag--closing { background: var(--ink); color: var(--white); }
.flag--closing::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #ff5a63; margin-right: .35rem; }
.flag--demo { background: #fff4cf; color: #7a5600; border: 1px dashed #c9a23a; }

/* ---------- Avatar de entidad ---------- */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 12px; font-weight: 800; letter-spacing: -.02em; color: var(--white); }
.avatar--sm { width: 34px; height: 34px; font-size: .68rem; border-radius: 9px; }
.avatar--md { width: 48px; height: 48px; font-size: .8rem; }
.avatar--lg { width: 72px; height: 72px; font-size: 1.1rem; border-radius: 18px; }
.avatar--t0 { background: linear-gradient(135deg, #c8102e, #5c0b17); }
.avatar--t1 { background: linear-gradient(135deg, #e5484d, #8a1020); }
.avatar--t2 { background: linear-gradient(135deg, #d9233c, #2a0a10); }
.avatar--t3 { background: linear-gradient(135deg, #f0525b, #d9233c); }
.avatar--t4 { background: linear-gradient(135deg, #8a1020, #e5484d); }
.avatar--t5 { background: linear-gradient(135deg, #ef6b72, #c8102e); }

/* ---------- Mensajes ---------- */
.flash { display: flex; gap: .6rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r-md); margin-bottom: 1rem; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow-2); border-left: 4px solid var(--blue-500); animation: slideIn .25s var(--ease); }
.flash--success { border-left-color: var(--signal-green); }
.flash--error { border-left-color: var(--signal-red); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } }
.notice { display: flex; gap: .6rem; background: var(--blue-100); border-radius: var(--r-md); padding: .85rem 1rem; color: var(--blue-900); font-size: var(--fs-sm); margin-bottom: 1rem; }
.notice .ico { color: var(--blue-700); margin-top: .1rem; }
.empty { padding: 2rem 1.4rem; text-align: center; color: var(--muted); background: var(--white); border: 1px dashed var(--blue-200); border-radius: var(--r-md); }
.empty .ico { width: 34px; height: 34px; color: var(--blue-300); display: block; margin: 0 auto .6rem; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: .75rem .9rem; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: .72rem; font-weight: 700; color: var(--muted); background: #fffafa; white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: #fff8f8; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { font-weight: 600; }
.cell-title { font-weight: 650; color: var(--blue-950); display: block; }
.cell-sub { font-size: var(--fs-xs); color: var(--muted); }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Paginación ---------- */
.pager { display: flex; flex-wrap: wrap; gap: .35rem; margin: 1.4rem 0; align-items: center; }
.pager a, .pager span { min-width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0 .7rem; border-radius: var(--r-sm); background: var(--white); border: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.pager a:hover { border-color: var(--blue-300); color: var(--blue-800); }
.pager .is-current { background: var(--blue-700); color: var(--white); border-color: var(--blue-700); }
.pager small { border: 0; background: none; margin-left: auto; }

/* ---------- Modales (<dialog>) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); width: min(560px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); box-shadow: var(--shadow-3); color: var(--ink); overflow: hidden; }
dialog.modal--lg { width: min(820px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(42,10,16,.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog.modal[open] { display: flex; flex-direction: column; animation: modalIn .22s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal__head { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line-2); }
.modal__head h2 { margin: 0; font-size: var(--fs-lg); flex: 1; }
.modal__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--blue-100); color: var(--blue-700); flex: none; }
.modal__icon--danger { background: #fdecee; color: var(--signal-red); }
.modal__body { padding: 1.2rem 1.3rem; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.3rem; background: var(--blue-50); border-top: 1px solid var(--line-2); }
.modal__close { background: none; border: 0; color: var(--muted); cursor: pointer; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; }
.modal__close:hover { background: var(--blue-50); color: var(--blue-900); }
body.has-modal { overflow: hidden; }

/* ---------- Menú desplegable genérico ---------- */
.dropdown { position: relative; }
.dropdown__panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); min-width: 230px; padding: .4rem; z-index: 80; opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .15s var(--ease), transform .15s var(--ease); }
.dropdown.is-open .dropdown__panel { opacity: 1; transform: none; pointer-events: auto; }
.dropdown__panel a, .dropdown__panel button { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; padding: .6rem .7rem; border: 0; background: none; font: 500 var(--fs-sm)/1.3 var(--font-ui); color: var(--ink); border-radius: var(--r-sm); cursor: pointer; }
.dropdown__panel a:hover, .dropdown__panel button:hover { background: var(--blue-50); color: var(--blue-900); }
.dropdown__panel .ico { color: var(--muted); }
.dropdown__sep { height: 1px; background: var(--line-2); margin: .35rem 0; }

/* ---------- Esqueleto, progreso, toasts ---------- */
.skeleton { background: linear-gradient(90deg, var(--blue-100) 25%, var(--blue-50) 50%, var(--blue-100) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); min-height: 1em; }
@keyframes shimmer { to { background-position: -200% 0; } }
.progress { height: 8px; background: var(--blue-100); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); border-radius: 99px; transition: width .35s var(--ease); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--blue-200); border-top-color: var(--blue-700); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 300; }
.toast { background: var(--blue-950); color: var(--white); padding: .8rem 1.05rem; border-radius: var(--r-md); box-shadow: var(--shadow-3); font-size: var(--fs-sm); max-width: 360px; animation: slideIn .2s var(--ease); }

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

.badge--descartada { background: #eceaea; color: #6b6466; }
