/* ==========================================================================
   PAI Vacunación Modular — sistema de diseño
   Sin dependencias externas: todo se sirve desde /static.
   Para cambiar la identidad visual basta con editar las variables de :root.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-wght.woff2") format("woff2");
}

:root {
  --primary: #0f7b5f;
  --primary-dark: #0a5c47;
  --primary-soft: #e6f4ef;
  --secondary: #2563a8;
  --secondary-soft: #e8f0fa;
  --accent: #e8a317;
  --accent-soft: #fdf3d8;
  --success: #1f9d6b;
  --success-soft: #e3f6ed;
  --warning: #b45309;
  --warning-soft: #fdf0dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #2563a8;
  --info-soft: #e8f0fa;

  --background: #f3f6f5;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --text: #17232d;
  --text-muted: #5b6a75;
  --border: #dce4e1;
  --border-strong: #c3cfca;

  --sidebar-bg: #0b3d31;
  --sidebar-text: #c9ddd6;
  --sidebar-active: rgba(255, 255, 255, .12);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 35, 30, .06);
  --shadow: 0 4px 16px rgba(15, 35, 30, .08);
  --sidebar-w: 264px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; line-height: 1.3; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
table { border-collapse: collapse; }
:focus-visible { outline: 3px solid rgba(37, 99, 168, .45); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }

/* ---------- Layout de aplicación ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #f3c24f); color: #3a2a00;
}
.brand-mark .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.brand-name { font-weight: 700; line-height: 1.15; font-size: .98rem; }
.brand-name small { display: block; font-weight: 500; font-size: .74rem; opacity: .7; letter-spacing: .02em; }

.nav-group { margin-top: 10px; }
.nav-label { padding: 8px 12px 6px; font-size: .68rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(201, 221, 214, .55); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 10px; color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .12); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; color: #fff; }
.sidebar-user b { display: block; font-size: .86rem; line-height: 1.25; }
.sidebar-user span { font-size: .74rem; opacity: .7; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; font-size: .82rem;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 28px; min-height: 64px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; }
.topbar-title strong { display: block; font-size: 1rem; line-height: 1.2; }
.crumbs { font-size: .78rem; color: var(--text-muted); }
.crumbs a { color: var(--text-muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-user .who { text-align: right; line-height: 1.25; }
.topbar-user .who b { display: block; font-size: .85rem; }
.topbar-user .who span { font-size: .74rem; color: var(--text-muted); }
.menu-toggle.btn { display: none; }
.content { padding: 28px; width: 100%; max-width: 1480px; margin: 0 auto; animation: rise .25s ease-out; }
.scrim { display: none; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Encabezado de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }
.page-head p { color: var(--text-muted); margin-top: 4px; max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(10, 92, 71, .3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: .82rem; border-radius: 8px; }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: progress; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; }
.card-head p { color: var(--text-muted); font-size: .82rem; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.section { margin-bottom: 22px; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.split-even { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 14px; }

/* ---------- KPI ---------- */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 22px; }
.kpi { display: flex; gap: 14px; align-items: flex-start; padding: 18px; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi-icon .icon { width: 22px; height: 22px; }
.kpi-icon.blue { background: var(--info-soft); color: var(--info); }
.kpi-icon.amber { background: var(--accent-soft); color: var(--warning); }
.kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi-label { font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.kpi-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-value.text { font-size: 1.15rem; padding-top: 6px; white-space: nowrap; }
.kpi-note { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- Formularios ---------- */
.field { display: block; min-width: 0; }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  font: inherit; font-size: .92rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:hover { border-color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 123, 95, .18); }
.input:disabled { background: var(--surface-alt); color: var(--text-muted); }
select.input { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235b6a75' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-items: end; }
.form-stack { display: grid; gap: 14px; }
.form-grid .form-row-2, .form-grid .form-row-3 { display: contents; }
.form-grid .btn-block { width: auto; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-row-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { display: grid; gap: 12px; grid-template-columns: 1fr 2fr; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.searchbar { position: relative; flex: 1 1 260px; }
.searchbar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.searchbar .input { padding-left: 38px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; font-size: .88rem; }
.table th {
  text-align: left; white-space: nowrap;
  padding: 11px 16px; background: var(--surface-alt);
  font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .wrap { white-space: normal; min-width: 200px; }
.table .strong { font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.4; background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: #14724d; border-color: #bfe8d3; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: #f2d7a8; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #f5c2be; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #c5d8ef; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); font-size: .78rem; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Alertas / estados ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 18px; font-size: .9rem; }
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--danger-soft); border-color: #f5c2be; color: #7f1a12; }
.alert-success { background: var(--success-soft); border-color: #bfe8d3; color: #0f5a3d; }
.alert-warning { background: var(--warning-soft); border-color: #f2d7a8; color: #7a3a06; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: .9rem; }
.empty .icon { width: 30px; height: 30px; opacity: .5; }
td.empty-cell { text-align: center; color: var(--text-muted); padding: 30px 16px; white-space: normal; }

/* ---------- Dashboard: filtros, gráficos, listas ---------- */
.filters summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; font-weight: 600; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary .icon.chev { transition: transform .2s; }
.filters[open] summary .icon.chev { transform: rotate(180deg); }
.filters .card-body { border-top: 1px solid var(--border); padding-top: 18px; }
.filter-count { margin-left: 8px; }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 300px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); font-size: .88rem; text-align: center; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin-bottom: 14px; font-size: .88rem; }
.bar-row span { font-weight: 500; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / 3; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; min-width: 4px; background: linear-gradient(90deg, var(--primary), var(--secondary)); border-radius: 999px; }

.heat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.heat-tile { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 96px; padding: 14px; border-radius: 10px; border: 1px solid #b9dccf; background: rgba(15, 123, 95, var(--heat)); color: #06281f; }
.heat-tile span { font-weight: 600; font-size: .86rem; }
.heat-tile strong { font-size: 1.6rem; line-height: 1; }
.heat-tile small { font-weight: 600; opacity: .8; }

.list-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.list-row:last-child { border-bottom: 0; }
.mini-card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); }
.entity-tile { padding: 14px; border-radius: 10px; background: var(--surface-alt); border: 1px solid var(--border); }
.entity-tile b { display: block; font-size: 1.5rem; color: var(--primary-dark); }

/* ---------- Aplicar vacunas ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 22px; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 500; color: var(--text-muted); counter-increment: step; }
.steps li::before { content: counter(step); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--border); color: var(--text-muted); font-size: .75rem; font-weight: 700; }
.steps li.done::before { background: var(--primary); color: #fff; }
.steps li.done { color: var(--text); }
.vaccine-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 4fr) minmax(0, 2fr) minmax(0, 5fr) auto; align-items: end; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); }
.remove-row-btn { width: 38px; height: 38px; border: 1px solid #f5c2be; background: var(--danger-soft); color: var(--danger); border-radius: 10px; font-weight: 700; cursor: pointer; }
.remove-row-btn:hover { background: #fbd9d6; }

/* ---------- Carga de Excel ---------- */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 20px; text-align: center; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-alt); transition: border-color .15s, background .15s; }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .icon { width: 34px; height: 34px; color: var(--primary); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-info { display: none; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.file-info.show { display: flex; }
.file-info b { display: block; word-break: break-all; }

/* ---------- Detalle de persona ---------- */
.person-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.person-hero .avatar { width: 56px; height: 56px; font-size: 1.1rem; }

/* ---------- Login ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 48px clamp(28px, 5vw, 72px); color: #fff;
  background: radial-gradient(1200px 600px at 0% 0%, #14856a 0%, transparent 60%), linear-gradient(160deg, #0b3d31 0%, #0a2f27 100%);
}
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .1); pointer-events: none; }
.auth-brand::before { width: 520px; height: 520px; right: -180px; bottom: -180px; }
.auth-brand::after { width: 320px; height: 320px; right: -60px; bottom: -60px; background: rgba(232, 163, 23, .08); }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand h1 { font-size: clamp(1.9rem, 3.4vw, 2.8rem); line-height: 1.1; max-width: 16ch; }
.auth-brand p.lead { margin-top: 14px; max-width: 46ch; color: rgba(255, 255, 255, .78); font-size: 1.05rem; }
.auth-points { display: grid; gap: 12px; padding: 0; margin: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .88); font-size: .95rem; }
.auth-points .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .1); }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--background); }
.auth-card { width: 100%; max-width: 420px; padding: 32px; box-shadow: var(--shadow); }
.auth-card .brand-mark { margin-bottom: 18px; }
.auth-card h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.auth-card > p { color: var(--text-muted); margin: 6px 0 22px; }
.auth-note { margin-top: 18px; font-size: .78rem; color: var(--text-muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split, .split-even, .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-100%); transition: transform .22s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(8, 24, 20, .5); }
  .menu-toggle.btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px; }
  .topbar-user .who { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { padding: 28px 24px; gap: 20px; }
  .auth-brand .auth-points { display: none; }
  .auth-brand h1 { max-width: none; }
}
@media (max-width: 720px) {
  .vaccine-row { grid-template-columns: minmax(0, 1fr); }
  .remove-row-btn { justify-self: end; }
  .form-row-2, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.4rem; }
  .btn { min-height: 44px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
}
