/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; border-radius: 3px; }
img { max-width: 100%; height: auto; display: block; }

/* === NAVIGATION === */
nav { background: #0f172a; }
.nav-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
}
.nav-brand {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #475569;
  padding: 0.8rem 1rem 0.8rem 0;
  border-right: 1px solid #1e293b;
  margin-right: 0.5rem;
  white-space: nowrap;
}
.nav-inner a {
  padding: 0.8rem 0.875rem;
  font-size: 0.82rem;
  color: #94a3b8;
  transition: color .15s, background .15s;
  white-space: nowrap;
  text-decoration: none;
}
.nav-inner a:hover { color: #e2e8f0; background: rgba(255,255,255,.05); text-decoration: none; }
.nav-inner a[aria-current="page"] { color: #38bdf8; border-bottom: 2px solid #38bdf8; font-weight: 600; }

/* === SITE HEADER (index + metodologia) === */
.site-header {
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 60%, #0e4f6b 100%);
  color: #fff;
  padding: 2.25rem 1.25rem 2rem;
}
.hdr-inner { max-width: 1140px; margin: 0 auto; }
.hdr-inner h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.025em; }
.hdr-sub { color: #7dd3fc; margin-top: 0.2rem; font-size: 0.92rem; }
.hdr-stats { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.stat-chip {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
}
.stat-chip strong { display: block; font-size: 1.25rem; font-weight: 800; color: #38bdf8; line-height: 1.2; }
.stat-chip span { font-size: 0.72rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; }

/* === SCHOOL DETAIL HEADER === */
.school-header {
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 60%, #0e4f6b 100%);
  color: #fff;
  padding: 2rem 1.25rem 1.75rem;
}
.sh-inner { max-width: 1140px; margin: 0 auto; }
.sh-inner h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 0.6rem; }
.sh-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.35rem; }
.sh-address { color: #94a3b8; font-size: 0.875rem; }
.type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.type-priv { background: #4c1d95; color: #e9d5ff; }
.type-pub  { background: #064e3b; color: #a7f3d0; }
.sh-municipality { font-size: 0.82rem; color: #94a3b8; }

/* === MAIN WRAPPER === */
.wrap { max-width: 1140px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* === LEGEND === */
.legend {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.1rem;
  font-size: 0.78rem;
  color: #64748b;
}
.legend b { color: #1e293b; }
.leg-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-vp { background: #16a34a; }
.dot-p  { background: #2563eb; }
.dot-m  { background: #d97706; }
.dot-n  { background: #dc2626; }
.dot-nd { background: #94a3b8; }
.legend-hint { margin-left: auto; font-size: 0.72rem; color: #94a3b8; display: flex; align-items: center; gap: 0.3rem; }
.legend-hint::before { content: "↕"; font-size: 0.85rem; color: #cbd5e1; }

/* === CARD === */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 2rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-head {
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.card-head h2 { font-size: 0.95rem; font-weight: 700; }
.card-count {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}
.card-head.priv { border-left: 4px solid #7c3aed; }
.card-head.priv h2 { color: #6d28d9; }
.card-head.pub  { border-left: 4px solid #059669; }
.card-head.pub  h2 { color: #047857; }
.card-head.info { border-left: 4px solid #38bdf8; }
.card-head.info h2 { color: #0369a1; }
.card-body { padding: 1.25rem; }
.card-note {
  padding: 0.55rem 1.25rem;
  font-size: 0.72rem;
  color: #94a3b8;
  border-top: 1px solid #f8fafc;
  background: #fafafa;
  line-height: 1.5;
}

/* === TABLES === */
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
thead tr { background: #f8fafc; }
th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  white-space: nowrap;
  border-bottom: 2px solid #e2e8f0;
  user-select: none;
}
th.sort { cursor: pointer; }
th.sort:hover { background: #f1f5f9; color: #334155; }
th.sort-asc  { color: #1d4ed8; }
th.sort-desc { color: #1d4ed8; }
th.sort-asc::after  { content: " ↑"; }
th.sort-desc::after { content: " ↓"; }
.sort-ico { color: #cbd5e1; font-size: 0.8em; }
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td { padding: 0.65rem 0.75rem; vertical-align: middle; }
th[scope="row"] { text-align: left; font-weight: 600; background: #f8fafc; text-transform: none; font-size: 0.83rem; letter-spacing: 0; border-bottom: 1px solid #f1f5f9; }
table caption {
  font-weight: 600;
  font-size: 0.82rem;
  color: #64748b;
  text-align: left;
  padding-bottom: 0.5rem;
  caption-side: top;
}
.table-note { color: #64748b; font-style: italic; }

/* === RANK BADGE (index table) === */
.rk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #64748b;
}
.rk-1 { background: #fef9c3; border-color: #eab308; color: #713f12; }
.rk-2 { background: #f1f5f9; border-color: #94a3b8; color: #334155; }
.rk-3 { background: #fff7ed; border-color: #f97316; color: #7c2d12; }

/* === SCHOOL NAME CELL (index table) === */
td.name-cell { min-width: 200px; max-width: 300px; }
.sname { font-weight: 600; color: #1e40af; font-size: 0.86rem; line-height: 1.35; display: block; }
.sname:hover { color: #1d4ed8; }
.sloc  { font-size: 0.72rem; color: #94a3b8; margin-top: 0.1rem; }

/* === SCORE BADGES (K1–K4) === */
.sb { display: inline-block; padding: 0.12rem 0.45rem; border-radius: 4px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.sb-vp { background: #dcfce7; color: #14532d; }
.sb-p  { background: #dbeafe; color: #1e3a8a; }
.sb-m  { background: #fef3c7; color: #78350f; }
.sb-n  { background: #fee2e2; color: #7f1d1d; }
.sb-nd { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; }

/* === E8 BAR CELL (index table) === */
td.e8c { min-width: 100px; }
.e8v { font-weight: 800; font-size: 0.92rem; color: #0f172a; letter-spacing: -0.01em; }
.e8bar-bg { height: 5px; background: #e2e8f0; border-radius: 3px; margin-top: 5px; position: relative; }
.e8bar-fill { height: 5px; border-radius: 3px; background: linear-gradient(90deg, #1d4ed8, #38bdf8); }
.e8bar-nat  { position: absolute; top: -2px; left: 61.3%; width: 2px; height: 9px; background: #f59e0b; border-radius: 1px; }
.e8-na   { color: #94a3b8; font-size: 0.78rem; font-style: italic; }
.e8-decl { color: #7c3aed; font-size: 0.78rem; }
.e8-nat-ref { font-size: 0.68rem; color: #94a3b8; margin-top: 3px; }
.e8-note { font-size: 0.78rem; color: #64748b; margin-top: 0.75rem; font-style: italic; line-height: 1.5; }

/* === TUITION CELL (index table) === */
.cz-val { font-weight: 700; }
.cz-note { font-size: 0.7rem; color: #94a3b8; }
.cz-na   { color: #94a3b8; font-size: 0.78rem; font-style: italic; }

/* === SCHOOL DETAIL: PHOTO PLACEHOLDER === */
.school-photo-placeholder {
  width: 100%;
  aspect-ratio: 16 / 5;
  max-height: 180px;
  background: linear-gradient(135deg, #1e3a5f, #0e4f6b);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.school-photo {
  width: 100%;
  aspect-ratio: 16 / 5;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: block;
}
.school-initials {
  font-size: 2rem;
  font-weight: 800;
  color: rgba(255,255,255,.2);
  letter-spacing: 0.1em;
  user-select: none;
}

/* === SCHOOL DETAIL: INTRO === */
.school-intro { display: flex; flex-direction: column; gap: 1rem; }
.school-intro p { line-height: 1.7; color: #334155; font-size: 0.9rem; }

/* === SCHOOL DETAIL: RANK STRIP === */
.rank-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.rk-big { font-size: 2rem; font-weight: 800; color: #1e40af; line-height: 1; min-width: 2rem; text-align: center; }
.rank-label { font-size: 0.82rem; color: #64748b; line-height: 1.4; }
.rank-label strong { display: block; color: #1e293b; font-size: 0.95rem; }

/* === SCHOOL DETAIL: CRITERIA === */
.criteria-dl { display: flex; flex-direction: column; }
.criteria-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.criteria-row:last-child { border-bottom: none; }
.criteria-dt { flex: 1 1 220px; font-size: 0.875rem; font-weight: 600; color: #334155; }

/* === SCHOOL DETAIL: OPINIONS SUMMARY === */
.opinions-summary {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fafafa;
  border-left: 3px solid #e2e8f0;
  border-radius: 0 4px 4px 0;
  color: #475569;
  font-size: 0.875rem;
  font-style: italic;
  line-height: 1.6;
}

/* === SCHOOL DETAIL: TUITION === */
.tuition-amount { font-weight: 700; font-size: 1.05rem; color: #1e293b; margin-bottom: 0.35rem; }
.tuition-confidence { font-size: 0.82rem; color: #64748b; line-height: 1.5; }

/* === SCHOOL DETAIL: SOURCES === */
.sources-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.sources-list li { display: flex; align-items: baseline; gap: 0.5rem; }
.sources-list li::before { content: "→"; color: #38bdf8; font-weight: 700; flex-shrink: 0; }
.sources-list a { font-size: 0.9rem; color: #1e40af; }
.sources-list a:hover { color: #1d4ed8; text-decoration: underline; }

/* === SCHOOL DETAIL: NO DATA === */
.no-data {
  color: #94a3b8;
  font-style: italic;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* === BACK LINK === */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .15s;
}
.back-link:hover { color: #38bdf8; text-decoration: none; }

/* === METODOLOGIA === */
.meto-intro { font-size: 0.9rem; color: #475569; line-height: 1.7; margin-bottom: 1rem; }
.meto-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.meto-list li {
  padding: 0.6rem 0.875rem;
  background: #f8fafc;
  border-radius: 6px;
  border-left: 3px solid #38bdf8;
  font-size: 0.875rem;
  line-height: 1.6;
}
.meto-list li strong { color: #1e293b; }
.meto-ul { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.35rem; }
.meto-ul li { font-size: 0.875rem; color: #475569; line-height: 1.6; }

/* === FOOTER LINK ROW (bottom of index) === */
.footer-link-row { text-align: center; font-size: 0.78rem; color: #94a3b8; margin-top: 0.5rem; }
.footer-link-row a { color: #2563eb; }
.footer-link-row a:hover { text-decoration: underline; }

/* === DISCLAIMER === */
.disclaimer {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.625rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.5;
}
.disclaimer strong { color: #64748b; font-weight: 600; }
.disclaimer p + p { margin-top: 0.375rem; }

/* === CONTACT PAGE === */
.contact-block { margin-bottom: 1rem; }
.contact-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: #94a3b8; margin-bottom: 0.25rem; }
.contact-value { font-size: 1rem; font-weight: 600; color: #1e293b; }
.contact-placeholder { color: #94a3b8; font-weight: 400; font-style: italic; }
.contact-note-text { font-size: 0.82rem; color: #64748b; line-height: 1.6; margin-top: 0.75rem; }

/* === SHARE HINT === */
.share-hint {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3px solid #22c55e;
  border-radius: 8px;
  padding: 0.625rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: #15803d;
  line-height: 1.5;
}

/* === SCHOOL UPDATE NOTE === */
.update-note {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 4px solid #38bdf8;
  border-radius: 10px;
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: #0c4a6e;
  line-height: 1.6;
}
.update-note a { color: #0284c7; font-weight: 600; }
.update-note a:hover { text-decoration: underline; }

/* === FOOTER === */
footer { background: #0f172a; color: #475569; text-align: center; padding: 1.25rem; font-size: 0.78rem; }
footer a { color: #38bdf8; }
footer a:hover { color: #7dd3fc; text-decoration: none; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .hdr-inner h1 { font-size: 1.3rem; }
  .sh-inner h1  { font-size: 1.2rem; }
  .nav-brand    { display: none; }
  .legend-hint  { display: none; }
  .card-body    { padding: 1rem; }
  th, td        { padding: 0.5rem 0.6rem; }
  .rank-strip   { flex-direction: column; gap: 0.5rem; text-align: center; }
  .rk-big       { font-size: 1.5rem; }
}
