/* ======================================================================
   Reconciliação Vacinal — Design System v2
   Tema: saúde moderno, glassmorphism, gradientes, micro-interações.
   ====================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* paleta */
  --c-ink: #0b1220;
  --c-ink-2: #334155;
  --c-muted: #7c8aa0;
  --c-line: #e8edf4;
  --c-bg: #eef2f8;
  --c-card: #ffffff;

  --c-primary: #4f6ef7;
  --c-primary-2: #7c3aed;
  --c-cyan: #06b6d4;
  --c-green: #10b981;
  --c-amber: #f59e0b;
  --c-red: #ef4444;
  --c-slate: #64748b;

  --grad-brand: linear-gradient(135deg, #4f6ef7 0%, #7c3aed 100%);
  --grad-sky: linear-gradient(135deg, #06b6d4 0%, #4f6ef7 100%);
  --grad-side: linear-gradient(175deg, #10163a 0%, #161f4d 55%, #0d1230 100%);

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow: 0 10px 30px -12px rgba(16,24,40,.22);
  --shadow-lg: 0 24px 60px -20px rgba(16,24,40,.35);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }
::selection { background: rgba(79,110,247,.2); }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdd7e6; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b6c2d6; background-clip: content-box; }

/* ======================  LOGIN  ====================== */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  position: relative; overflow: hidden;
  background: var(--grad-side);
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5;
}
.login-wrap::before { width: 460px; height: 460px; background: #4f6ef7; top: -140px; right: -120px; }
.login-wrap::after { width: 420px; height: 420px; background: #7c3aed; bottom: -160px; left: -120px; }

.login-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255,255,255,.18);
  width: 100%; max-width: 400px; padding: 40px 36px;
  border-radius: 24px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 18px;
  animation: pop .5s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.login-card .brand { text-align: center; color: #fff; }
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px;
  background: var(--grad-sky); display: grid; place-items: center;
  box-shadow: 0 10px 30px -8px rgba(6,182,212,.6);
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; color: #fff; letter-spacing: -.02em; }
.login-card .brand-sub { color: rgba(255,255,255,.7); margin: 0; font-size: 13px; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12.5px; color: rgba(255,255,255,.85); font-weight: 600; }
.field input {
  padding: 13px 15px; border-radius: 12px; font-size: 14.5px; color: #fff;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); outline: none;
  transition: .2s var(--ease);
}
.field input::placeholder { color: rgba(255,255,255,.5); }
.field input:focus { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.55); box-shadow: 0 0 0 4px rgba(255,255,255,.08); }

/* buttons */
.btn {
  padding: 12px 18px; border: none; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 700; transition: .2s var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 10px 24px -10px rgba(79,110,247,.7); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 14px 30px -10px rgba(79,110,247,.8); }
.btn-lg { padding: 14px 18px; font-size: 15px; }
.btn-ghost { background: rgba(255,255,255,.06); color: #cbd5e1; border: 1px solid rgba(255,255,255,.12); }
.btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn-soft { background: #eef1fb; color: var(--c-primary); }
.btn-soft:hover { background: #e3e8fb; }
.btn-danger { background: #fff; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #f87171; }
.error { color: #fecaca; font-size: 13px; min-height: 18px; margin: 0; text-align: center; }

/* ======================  APP SHELL  ====================== */
#app-view { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--grad-side); color: #e7ecf6; padding: 26px 18px;
  display: flex; flex-direction: column; gap: 10px; position: relative;
}
.sidebar::after { content:""; position:absolute; inset:0 0 0 auto; width:1px; background: rgba(255,255,255,.06); }
.brand-side { display: flex; align-items: center; gap: 12px; padding: 0 8px 8px; }
.brand-side .logo {
  width: 42px; height: 42px; border-radius: 13px; background: var(--grad-sky);
  display: grid; place-items: center; flex: none; box-shadow: 0 8px 20px -8px rgba(6,182,212,.7);
}
.brand-side strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand-side small { color: #93a1c4; font-size: 11.5px; font-weight: 500; }

.nav-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #6b7aa3; margin: 18px 10px 6px; font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: transparent; color: #aeb9d6; border: none;
  padding: 11px 12px; border-radius: 12px; cursor: pointer; font-size: 14px; font-weight: 600;
  position: relative; transition: .18s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(79,110,247,.18); color: #fff; }
.nav-item.active::before { content:""; position:absolute; left:-18px; top:9px; bottom:9px; width:4px; border-radius:0 4px 4px 0; background: var(--grad-sky); }
.nav-item.active svg { opacity: 1; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 11px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px 12px; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--grad-brand); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; flex: none; }
.user-chip .meta { overflow: hidden; }
.user-chip .meta span { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta small { color: #93a1c4; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; }

/* content */
.content { padding: 30px 36px 48px; overflow-y: auto; height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.topbar .title h2 { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -.02em; }
.topbar .title p { margin: 4px 0 0; color: var(--c-muted); font-size: 13.5px; }

/* ======================  CARDS  ====================== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--c-card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--c-line);
  transition: .25s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; }
.stat .ic svg { width: 21px; height: 21px; color: #fff; }
.stat .num { font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .lbl { color: var(--c-muted); font-size: 12.5px; margin-top: 6px; font-weight: 600; }
.ic.blue { background: var(--grad-brand); } .ic.violet { background: linear-gradient(135deg,#7c3aed,#a855f7); }
.ic.amber { background: linear-gradient(135deg,#f59e0b,#f97316); } .ic.green { background: linear-gradient(135deg,#10b981,#059669); }
.ic.red { background: linear-gradient(135deg,#ef4444,#dc2626); } .ic.cyan { background: var(--grad-sky); }
.stat .spark { position: absolute; right: -6px; bottom: -6px; opacity: .06; font-size: 90px; font-weight: 800; }

/* ======================  PANELS  ====================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.panel { background: var(--c-card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); border: 1px solid var(--c-line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.panel-head .tag { font-size: 11px; font-weight: 700; color: var(--c-muted); background: #f3f6fb; padding: 4px 10px; border-radius: 999px; }

.bars { display: flex; flex-direction: column; gap: 13px; max-height: 330px; overflow-y: auto; padding-right: 4px; }
.bars-wide { max-height: none; }
.bar-row { display: grid; grid-template-columns: 128px 1fr 58px; align-items: center; gap: 12px; font-size: 13px; font-weight: 600; }
.bar-row > span:first-child { color: var(--c-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef2f8; border-radius: 8px; height: 24px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 8px; background: var(--grad-sky); width: 0; transition: width .8s var(--ease); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--c-muted); font-weight: 700; }

/* status fills */
.s-MATCH { background: linear-gradient(90deg,#10b981,#34d399); }
.s-ONLY_IN_SIPNI { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.s-ONLY_IN_PEC { background: linear-gradient(90deg,#64748b,#94a3b8); }
.s-COVERED_BY_EQUIVALENT { background: var(--grad-brand); }
.s-DOSE_DIVERGENCE { background: linear-gradient(90deg,#ef4444,#f87171); }

.hint { color: var(--c-muted); font-size: 13px; margin: 14px 0 0; display: flex; gap: 8px; align-items: flex-start; }
.hint svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ======================  IMPORT  ====================== */
.drop {
  border: 2px dashed #cdd7e6; border-radius: var(--radius-sm); padding: 26px; text-align: center;
  transition: .2s var(--ease); cursor: pointer; background: #fafbfe;
}
.drop:hover, .drop.drag { border-color: var(--c-primary); background: #f3f6ff; }
.drop .big { font-size: 15px; font-weight: 700; margin: 10px 0 4px; }
.drop .sm { color: var(--c-muted); font-size: 12.5px; }
.drop svg { width: 40px; height: 40px; color: var(--c-primary); }
.drop .fname { margin-top: 10px; font-size: 13px; color: var(--c-primary); font-weight: 700; }
.out { background: #0b1220; color: #7ee3b0; padding: 14px; border-radius: 12px; font-size: 12.5px; min-height: 20px; white-space: pre-wrap; margin-top: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ======================  FILTERS + TABLE  ====================== */
.filters { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-end; }
.filters .field { gap: 6px; }
.filters .field > span { font-size: 11.5px; font-weight: 700; color: var(--c-muted); }
.filters select, .filters input {
  padding: 10px 13px; border: 1px solid var(--c-line); border-radius: 11px; font-size: 13.5px;
  background: #fff; color: var(--c-ink); outline: none; min-width: 170px; transition: .18s var(--ease);
}
.filters select:focus, .filters input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(79,110,247,.12); }

.filters.topbar-actions { margin-bottom: 0; }
.filters.topbar-actions select { min-width: 220px; }

.table-meta { color: var(--c-muted); font-size: 13px; margin-bottom: 10px; font-weight: 600; }
.table-wrap { overflow: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--c-line); background: #fff; max-height: 60vh; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--c-line); }
th { background: #f8fafd; position: sticky; top: 0; font-size: 11px; color: var(--c-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 800; z-index: 2; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f6f9ff; }
td:first-child { font-weight: 600; }

.badge { padding: 4px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #fff; white-space: nowrap; letter-spacing: .01em; }
.badge.MATCH { background: linear-gradient(90deg,#10b981,#34d399); }
.badge.ONLY_IN_SIPNI { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.badge.ONLY_IN_PEC { background: linear-gradient(90deg,#64748b,#94a3b8); }
.badge.COVERED_BY_EQUIVALENT { background: var(--grad-brand); }
.badge.DOSE_DIVERGENCE { background: linear-gradient(90deg,#ef4444,#f87171); }
.badge.NOT_APPLIED { background: linear-gradient(90deg,#dc2626,#ef4444); }
/* Badges de cobertura vacinal (cores do calendário) */
.badge.ATRASADA { background: linear-gradient(90deg,#ef4444,#f87171); }
.badge.APLICADA { background: linear-gradient(90deg,#10b981,#34d399); }
.badge.EQUIVALENTE { background: linear-gradient(90deg,#3b82f6,#60a5fa); }
.badge.DISPONIVEL { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.badge.FUTURA { background: #e2e8f0; color: #475569; }
.badge.INDETERMINADA { background: #f1f5f9; color: #94a3b8; border: 1px dashed #cbd5e1; }
/* Badges de pendência PEC x SIPNI */
.badge.LANCAR_PEC { background: linear-gradient(90deg,#3b82f6,#60a5fa); }
.badge.APLICAR { background: linear-gradient(90deg,#ef4444,#f87171); }

/* Agrupamento expansível por criança (aba Cobertura) */
tr.cov-group { cursor: pointer; }
tr.cov-group:hover { background: #f3f6fb; }
tr.cov-group td:first-child { font-weight: 700; }
tr.cov-group.open { background: #eef1fb; }
.cov-caret { display: inline-block; width: 14px; color: var(--c-primary); font-size: 11px; }
tr.cov-detail td { background: #fbfcfe; color: var(--c-muted); border-top: none; }
tr.cov-detail td small { color: #94a3b8; font-weight: 600; margin-left: 4px; }

/* ======================  TOAST  ====================== */
.toast {
  position: fixed; bottom: 26px; right: 26px; background: var(--c-ink); color: #fff;
  padding: 14px 20px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600;
  z-index: 60; display: flex; align-items: center; gap: 10px; animation: slideIn .35s var(--ease);
}
@keyframes slideIn { from { opacity: 0; transform: translateY(14px); } }
.toast.err { background: linear-gradient(135deg,#ef4444,#dc2626); }
.toast::before { content:"✓"; font-weight: 800; }
.toast.err::before { content:"!"; }

/* view transitions */
.view { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }

/* responsive */
@media (max-width: 900px) {
  #app-view { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .sidebar-foot { display: none; }
  .content { height: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ======================  MAPA  ====================== */
.map-panel { padding: 16px; }
#geo-map { height: 68vh; min-height: 420px; border-radius: var(--radius-sm); border: 1px solid var(--c-line); z-index: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 13px; color: var(--c-ink-2); margin-bottom: 12px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.dot-aplicar { background: #ef4444; }
.dot-lancar { background: #f59e0b; }
.dot-ok { background: #10b981; }
.dot-unit { background: #1d4ed8; border-radius: 3px !important; }
.map-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.map-popup { font-size: 13px; line-height: 1.45; min-width: 220px; }
.map-popup strong { font-size: 14px; }
.map-popup .muted { color: var(--c-muted); font-size: 12px; }
.map-popup .tag-aplicar { color: #b91c1c; font-weight: 700; }
.map-popup .tag-lancar { color: #b45309; font-weight: 700; }
.map-popup .tag-ok { color: #047857; font-weight: 700; }
.terr-label { background: rgba(255,255,255,.85); border: 1px solid rgba(0,0,0,.15); border-radius: 4px; padding: 1px 5px; font-size: 11px; font-weight: 700; color: #1e293b; box-shadow: none; }
.terr-label::before { display: none; }

/* ======================  ESCOLAS (aba Mapa)  ====================== */
.school-grid { margin-top: 20px; grid-template-columns: minmax(320px, 1fr) 1.4fr; }
.school-form { display: grid; grid-template-columns: 1fr 120px; gap: 12px 14px; }
.school-form .full { grid-column: 1 / -1; }
.school-form .field > span { font-size: 11.5px; font-weight: 700; color: var(--c-muted); }
.school-form .field input {
  padding: 10px 13px; border: 1px solid var(--c-line); border-radius: 11px; font-size: 13.5px;
  background: #fff; color: var(--c-ink);
}
.school-form .field input::placeholder { color: #a3adbd; }
.school-form .field input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(79,110,247,.12); background: #fff; }
.school-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.school-form .hint { margin-top: 0; }
.dot-school { background: #7c3aed; border-radius: 3px !important; transform: rotate(45deg); }
.school-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.school-row-actions .btn { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
#geo-map.picking { cursor: crosshair; }
@media (max-width: 1100px) { .school-grid { grid-template-columns: 1fr; } }

/* ======================  ALTERAR SENHA  ====================== */
.pass-dialog { border: none; border-radius: var(--radius); padding: 26px; width: min(420px, 92vw); box-shadow: var(--shadow-lg); color: var(--c-ink); }
.pass-dialog::backdrop { background: rgba(11,18,32,.55); }
.pass-dialog h3 { margin: 0 0 4px; font-size: 18px; }
.pass-dialog .hint { margin: 0 0 16px; }
.pass-dialog form { display: flex; flex-direction: column; gap: 12px; }
.pass-dialog .field > span { font-size: 11.5px; font-weight: 700; color: var(--c-muted); }
.pass-dialog .field input {
  padding: 11px 13px; border: 1px solid var(--c-line); border-radius: 11px; font-size: 14px;
  background: #fff; color: var(--c-ink);
}
.pass-dialog .field input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(79,110,247,.12); background: #fff; }
.pass-show { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--c-ink-2); cursor: pointer; }
.pass-error { color: #dc2626; font-size: 13px; min-height: 18px; margin: 0; font-weight: 600; }
.pass-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 9px; }

/* ======================  ACESSO DO NÍVEL ESCOLA  ====================== */
.access-grid { grid-template-columns: minmax(320px, 1fr) 1.3fr; }
.access-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.access-form .full { grid-column: 1 / -1; }
.access-form .field > span { font-size: 11.5px; font-weight: 700; color: var(--c-muted); }
.access-form .field input {
  padding: 10px 13px; border: 1px solid var(--c-line); border-radius: 11px; font-size: 13.5px;
  background: #fff; color: var(--c-ink);
}
.access-form .field input:focus { border-color: var(--c-primary); box-shadow: 0 0 0 4px rgba(79,110,247,.12); background: #fff; }
.access-form .hint { margin: 0; }
.child-h { margin: 6px 0 10px; font-size: 14px; }
#child-panel { margin-top: 20px; }
.badge.PENDING { background: linear-gradient(90deg,#f59e0b,#fbbf24); }
.badge.APPROVED { background: linear-gradient(90deg,#10b981,#34d399); }
.badge.DENIED { background: linear-gradient(90deg,#ef4444,#f87171); }
.badge.REVOKED { background: #e2e8f0; color: #475569; }
.match-ok { color: #047857; font-weight: 700; }
.match-warn { color: #b45309; font-weight: 700; }
.match-bad { color: #b91c1c; font-weight: 700; }
.nav-badge { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800; padding: 1px 7px; }
@media (max-width: 1100px) { .access-grid { grid-template-columns: 1fr; } }
