:root {
  --brand-blue: #0d4f92;
  --brand-blue-deep: #0a3970;
  --brand-gold: #c49a35;
  --brand-gold-soft: #e3c982;
  --brand-green: #1f7a59;
  --brand-red: #c5443c;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #182431;
  --muted: #5e6e7f;
  --line: #d9e3ef;
  --shadow-lg: 0 20px 60px rgba(10, 57, 112, 0.12);
  --shadow-md: 0 12px 32px rgba(13, 79, 146, 0.08);
  --ok-bg: #e8f7ee;
  --ok: #1a6a46;
  --warn-bg: #fff4dd;
  --warn: #8a5a00;
  --danger-bg: #fdeceb;
  --danger: #a33232;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 154, 53, 0.12), transparent 22%),
    linear-gradient(180deg, #eef4fb 0%, #f6f9fc 220px, var(--bg) 220px, var(--bg) 100%);
}

img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select { font: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  color: #fff;
  background:
    linear-gradient(130deg, rgba(10, 57, 112, 0.98), rgba(13, 79, 146, 0.95) 60%, rgba(27, 108, 176, 0.92)),
    linear-gradient(180deg, var(--brand-blue), var(--brand-blue-deep));
  position: relative;
  overflow: hidden;
}

.site-header::before,
.site-header::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.site-header::before {
  width: 440px;
  height: 440px;
  background: rgba(255, 255, 255, 0.08);
  top: -220px;
  right: -130px;
}

.site-header::after {
  width: 240px;
  height: 240px;
  background: rgba(196, 154, 53, 0.17);
  left: -70px;
  bottom: -90px;
}

.header-top {
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(6, 31, 62, 0.16);
  backdrop-filter: blur(8px);
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.institution-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.88rem;
  font-weight: 600;
}

.institution-chip.secondary {
  background: rgba(196, 154, 53, 0.18);
  border-color: rgba(255, 255, 255, 0.15);
}

.hero {
  padding: 36px 0 84px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(290px, 400px) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}

.logos-wrap {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 20px;
  align-items: center;
}

.logo-card {
  background: rgba(255,255,255,0.97);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
}

.logo-card img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.logo-card-hospital { padding: 18px; }
.logo-card-ogc { padding: 14px; }

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--brand-gold-soft);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 1.08;
}

.hero-text {
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.92);
  max-width: 780px;
}

.hero-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.point-card {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 16px 18px;
  backdrop-filter: blur(8px);
}

.point-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.point-text {
  display: block;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5;
  font-size: 0.95rem;
}

.author-highlight {
  margin-top: 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  background: linear-gradient(135deg, rgba(196, 154, 53, 0.22), rgba(255, 255, 255, 0.10));
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  padding: 16px 18px;
  backdrop-filter: blur(8px);
}

.author-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,0.15);
  font-size: 1.25rem;
  font-weight: 800;
}

.author-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-gold-soft);
  font-weight: 700;
}

.author-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-top: 2px;
}

.author-role {
  margin-top: 4px;
  color: rgba(255,255,255,0.88);
  line-height: 1.5;
}

.main-content {
  margin-top: -52px;
  padding-bottom: 52px;
}

.search-panel,
.stat-card,
.info-band,
.doc-card,
.empty,
.error {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.search-panel {
  border-radius: 24px;
  padding: 24px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.search-box { position: relative; }

.search-box input {
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid #cdd9e6;
  background: #fff;
  padding: 0 50px 0 18px;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.search-box input:focus,
select:focus {
  border-color: rgba(13, 79, 146, 0.55);
  box-shadow: 0 0 0 4px rgba(13, 79, 146, 0.12);
}

.search-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.filters {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.field-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #35506d;
}

select {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid #cdd9e6;
  background: #fff;
  padding: 0 12px;
  color: var(--text);
  outline: none;
}

.active-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  min-height: 24px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf4fb;
  color: var(--brand-blue-deep);
  border: 1px solid #d7e4f2;
  font-size: 0.85rem;
  font-weight: 600;
}

.stats-section {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
}

.stat-card {
  border-radius: 20px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.stat-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  background: linear-gradient(135deg, rgba(13,79,146,0.1), rgba(196,154,53,0.13));
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--brand-blue-deep);
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.info-band {
  border-radius: 20px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}

.info-band-item {
  color: #35506d;
  line-height: 1.6;
  font-size: 0.95rem;
}

.results-section { margin-top: 20px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.result-count {
  font-weight: 700;
  color: #2c425a;
}

.updated {
  font-size: 0.9rem;
  color: var(--muted);
}

.results-grid {
  display: grid;
  gap: 16px;
}

.doc-card {
  border-radius: 20px;
  padding: 22px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: #c6d8eb;
  box-shadow: 0 20px 45px rgba(13, 79, 146, 0.10);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.category {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--brand-blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #edf4fb;
  border: 1px solid #dbe9f8;
  padding: 6px 10px;
  border-radius: 999px;
}

.doc-title {
  margin: 10px 0 0;
  font-size: 1.14rem;
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.79rem;
  font-weight: 800;
}

.badge.vigente { background: var(--ok-bg); color: var(--ok); }
.badge.revision { background: var(--warn-bg); color: var(--warn); }
.badge.derogado,
.badge.reemplazado { background: var(--danger-bg); color: var(--danger); }
.badge.default { background: #eef2f7; color: #53657a; }

.meta {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px 18px;
}

.meta-item {
  min-width: 0;
  background: var(--surface-soft);
  border: 1px solid #ebf1f7;
  border-radius: 14px;
  padding: 12px 12px 11px;
}

.meta-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7b8da0;
  margin-bottom: 5px;
  font-weight: 700;
}

.meta-value {
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.keywords {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

.card-actions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #edf2f7;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.card-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.btn,
.doc-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn:hover,
.doc-link:hover,
button:hover { transform: translateY(-1px); }

.btn-primary,
.doc-link {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-deep));
  color: #fff;
  box-shadow: 0 10px 22px rgba(10, 57, 112, 0.16);
}

.btn-primary:hover,
.doc-link:hover {
  background: linear-gradient(135deg, #135da8, #0b4788);
}

.btn-secondary {
  background: #f4f7fa;
  border-color: #d5e0ea;
  color: #35506d;
}

.disabled,
button.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.empty,
.error {
  border-radius: 20px;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

.error {
  color: var(--danger);
  border-color: #f0cbcb;
}

.loader {
  display: grid;
  place-items: center;
  min-height: 200px;
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 4px solid #dae4ef;
  border-top-color: var(--brand-blue);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.site-footer {
  border-top: 1px solid #d8e3ef;
  background: #fff;
  padding: 28px 0 34px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 22px;
}

.footer-title {
  font-weight: 800;
  color: var(--brand-blue-deep);
  margin-bottom: 10px;
}

.footer-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.92rem;
}

@media (max-width: 1024px) {
  .hero-grid,
  .stats-section,
  .footer-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero-grid { align-items: start; }
  .hero-brand { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .filters,
  .stats-section,
  .meta,
  .info-band,
  .footer-grid,
  .hero-points { grid-template-columns: 1fr 1fr; }
  .toolbar,
  .panel-heading,
  .card-actions { flex-direction: column; align-items: stretch; }
}

@media (max-width: 620px) {
  .container { width: min(100% - 22px, 1200px); }
  .hero { padding: 24px 0 76px; }
  .hero-grid,
  .filters,
  .stats-section,
  .meta,
  .info-band,
  .footer-grid,
  .hero-points,
  .logos-wrap {
    grid-template-columns: 1fr;
  }
  .top-row { padding: 10px 0; }
  .institution-chip { width: 100%; justify-content: center; text-align: center; }
  .main-content { margin-top: -44px; }
  .search-panel { padding: 18px; border-radius: 20px; }
  .stat-card { padding: 16px; }
  .doc-card { padding: 18px; }
  .card-top { flex-direction: column; }
  .badge { align-self: flex-start; }
  .card-actions .doc-link,
  .card-actions button { width: 100%; }
  .updated { text-align: left; }
}


/* Refinamiento institucional V2.1 */
.hero-grid {
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 46px;
}

.logos-wrap {
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 300px;
  margin: 0 auto;
}

.logo-card {
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.20);
  box-shadow: 0 18px 45px rgba(4, 29, 60, .22);
}

.logo-card-hospital {
  padding: 14px;
}

.logo-card-ogc {
  width: 70%;
  justify-self: center;
  padding: 12px;
}

.hero-copy {
  max-width: 820px;
}

.hero-copy h1 {
  max-width: 760px;
  letter-spacing: -0.03em;
}

.hero-text {
  max-width: 800px;
  font-size: 1.02rem;
}

.hero-points-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 760px;
}

.point-card-main {
  position: relative;
  padding-left: 22px;
  background: rgba(255,255,255,.08);
}

.point-card-main::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 999px;
  background: var(--brand-gold-soft);
}

.author-highlight { display: none; }

.search-panel {
  box-shadow: 0 22px 55px rgba(10,57,112,.11);
}

.stat-card {
  box-shadow: 0 10px 26px rgba(10,57,112,.06);
}

.site-footer {
  padding: 0;
  background: #fff;
  border-top: 1px solid #d7e1ec;
}

.footer-main {
  display: grid;
  grid-template-columns: 1.3fr .7fr;
  gap: 28px;
  padding: 28px 0;
  align-items: start;
}

.footer-notice {
  color: #5d6d7d;
  line-height: 1.65;
  font-size: .9rem;
  background: #f6f9fc;
  border: 1px solid #e1e9f1;
  border-radius: 14px;
  padding: 14px 16px;
}

.footer-bottom {
  background: #0a3970;
  color: rgba(255,255,255,.88);
}

.copyright-row {
  min-height: 82px;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font-size: .82rem;
}

.author-credit {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.45;
}

.author-credit > span:first-child {
  color: #e5c979;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.author-credit strong {
  color: #fff;
  font-size: .92rem;
}

@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 260px minmax(0,1fr); gap: 32px; }
  .hero-brand { grid-column: auto; }
}

@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-brand { grid-column: auto; }
  .logos-wrap { grid-template-columns: 1fr 1fr; max-width: 390px; }
  .logo-card-ogc { width: 100%; }
  .footer-main { grid-template-columns: 1fr; }
  .copyright-row { flex-direction: column; align-items: flex-start; }
  .author-credit { text-align: left; }
}

@media (max-width: 520px) {
  .logos-wrap { grid-template-columns: 1fr; max-width: 230px; }
  .logo-card-ogc { width: 72%; justify-self: center; }
  .hero-copy h1 { font-size: clamp(2rem, 11vw, 2.75rem); }
}
