/* ============================================================
   ICA – Instituto Cardiovascular Adventista
   Sitio público de procedimientos
   Colores: azul y rojo institucionales ICA + blanco + acentos médicos
   ============================================================ */

:root {
  /* Paleta ICA (de clinicaadventista.org/instituto-cardiovascular-adventista/ica) */
  --ica-blue-dark:   #1d3658;
  --ica-blue:        #00538c;
  --ica-blue-mid:    #32bbd8;
  --ica-blue-light:  #e8f2fc;
  --ica-blue-pale:   #f0f6ff;
  --ica-accent:      #00a859;
  --ica-accent-dark: #007a3e;
  --ica-red:         #e31818;
  --ica-orange:      #e65c00;

  /* Neutros */
  --bg:              #f4f7fb;
  --surface:         #ffffff;
  --surface-soft:    #f8fafd;
  --border:          #dce6f0;
  --text:            #12243a;
  --text-mid:        #3d5472;
  --text-soft:       #6e87a2;

  /* Sombras */
  --shadow-sm:  0 1px 4px rgba(0,45,110,.08);
  --shadow-md:  0 4px 16px rgba(0,45,110,.12);
  --shadow-lg:  0 8px 32px rgba(0,45,110,.16);

  /* Dimensiones */
  --header-h:      64px;
  --sidebar-w:     240px;
  --detail-w:      520px;
  --radius:        10px;
  --radius-sm:     6px;
  --transition:    .22s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Evitar que display:flex pise el atributo hidden */
[hidden] { display: none !important; }

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── HEADER ── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.header-titles {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  padding-left: 12px;
}

.header-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ica-blue-dark);
  line-height: 1.2;
}

.header-subtitle {
  font-size: .72rem;
  color: var(--text-soft);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}

/* ── BUSCADOR ── */
.search-wrapper {
  position: relative;
  max-width: 400px;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-input::placeholder { color: var(--text-soft); }

.search-input:focus {
  background: #fff;
  border-color: var(--ica-blue-mid);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--ica-blue-pale); }

.search-item-code {
  font-size: .72rem;
  background: var(--ica-blue-light);
  color: var(--ica-blue);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.search-item-title {
  font-size: .88rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
}

.search-item-cat {
  font-size: .72rem;
  color: var(--text-soft);
}

/* ── BOTONES HEADER ── */
.btn-header-action {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}

.btn-action-green {
  background: var(--ica-accent);
  color: #fff;
}
.btn-action-green:hover { background: var(--ica-accent-dark); }

.btn-action-blue {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
}
.btn-action-blue:hover { background: rgba(255,255,255,.25); }

/* ── LAYOUT ── */
.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h) - 48px);
}

/* ── ÁREA PRINCIPAL ── */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: calc(100vh - var(--header-h) - 48px);
}

/* ── TABS DE VISTA ── */
.view-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  padding: 0 16px;
  gap: 2px;
}

.view-tab {
  padding: 12px 18px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.view-tab:hover { color: var(--ica-blue-mid); }

.view-tab.active {
  color: var(--ica-blue);
  border-bottom-color: var(--ica-blue);
  font-weight: 700;
}

/* ── PANELES DE VISTA ── */
.view-panel {
  flex: 1;
  overflow: auto;
}

/* ── MAPA DE PROCEDIMIENTOS ── */
#graph-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - var(--header-h) - 46px - 48px);
  overflow: hidden;
  background: var(--bg);
}

/* Grid de tiles de categoría */
#map-tiles {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  padding: 16px 16px 12px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: color-mix(in srgb, var(--tile-color) 10%, white);
  cursor: pointer;
  transition: all .18s ease;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.cat-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--tile-color);
  opacity: 0;
  transition: opacity .18s ease;
}

.cat-tile:hover::before  { opacity: .08; }
.cat-tile.selected::before { opacity: .12; }

.cat-tile:hover,
.cat-tile.selected {
  border-color: var(--tile-color);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--tile-color) 30%, transparent);
  transform: translateY(-2px);
}

.cat-tile-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ica-blue-dark), var(--ica-red));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cat-tile-icon-box svg {
  width: 22px;
  height: 22px;
}

.cat-tile-name {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
  position: relative;
}

.cat-tile-count {
  font-size: .72rem;
  color: var(--text-soft);
  font-weight: 500;
  position: relative;
}

/* Panel de procedimientos de la categoría */
#map-procs {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.map-hint {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-soft);
  font-size: 1rem;
  font-style: italic;
}

.map-procs-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.map-procs-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ica-blue-dark), var(--ica-red));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.map-procs-icon-box svg {
  width: 26px;
  height: 26px;
}

.map-procs-title {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
}

.map-procs-sub {
  font-size: .85rem;
  color: var(--text-soft);
  margin-top: 3px;
}

.map-procs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.map-proc-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all .18s ease;
}

.map-proc-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.mpc-code {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.mpc-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.mpc-summary {
  font-size: .85rem;
  color: var(--text-mid);
  line-height: 1.5;
}

.mpc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.mpc-tag {
  font-size: .73rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
  background: var(--ica-blue-light);
  color: var(--ica-blue);
}
.mpc-tag.warn   { background: #fff3e0; color: #e65c00; }
.mpc-tag.danger { background: #ffebee; color: #c62828; }
.mpc-tag.purple { background: #f3e8fd; color: #6a1bab; }
.mpc-tag.green  { background: #e8f5e9; color: #2e7d32; }

.mpc-cta {
  font-size: .85rem;
  font-weight: 600;
  color: var(--ica-blue);
  margin-top: 6px;
}

@media (max-width: 1100px) {
  #map-tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  #map-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ── LISTA DE PROCEDIMIENTOS ── */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-mid);
}

.filter-group select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
}

.results-count {
  font-size: .8rem;
  color: var(--text-soft);
}

.procedure-list {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.proc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.proc-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.proc-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.proc-card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.proc-card-code {
  font-size: .72rem;
  background: var(--ica-blue-light);
  color: var(--ica-blue);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.proc-card-summary {
  font-size: .8rem;
  color: var(--text-mid);
  line-height: 1.45;
  margin-bottom: 10px;
}

.proc-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.proc-tag {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.proc-tag.consent { background: #fff3e0; color: #e65c00; }
.proc-tag.companion { background: #fce4ec; color: #c62828; }
.proc-tag.weight { background: #f3e5f5; color: #6a1b9a; }
.proc-tag.duration { background: #e8f5e9; color: #2e7d32; }
.proc-tag.delivery { background: #e3f2fd; color: #1565c0; }

/* ── PANEL DETALLE (flotante, no reserva espacio cuando está cerrado) ── */
.detail-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 48px;
  width: var(--detail-w);
  height: auto;
  box-shadow: -8px 0 24px rgba(0,45,110,.12);
  z-index: 80;
  transform: translateX(0);
  transition: transform var(--transition);
}

.detail-backdrop {
  position: fixed;
  inset: var(--header-h) 0 48px 0;
  background: rgba(10,20,35,.35);
  z-index: 70;
  opacity: 1;
  transition: opacity var(--transition);
}

.detail-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.detail-panel.hidden {
  transform: translateX(var(--detail-w));
}

.detail-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--ica-blue-pale);
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  transition: all var(--transition);
}
.detail-close:hover { background: #ffebee; color: var(--ica-red); border-color: var(--ica-red); }

.detail-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  color: #fff;
  margin-bottom: 10px;
}

.detail-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ica-blue-dark);
  line-height: 1.3;
  margin-bottom: 8px;
  padding-right: 32px;
}

.detail-summary {
  font-size: .85rem;
  color: var(--text-mid);
  line-height: 1.5;
}

/* ── META CHIPS ── */
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.meta-chip strong { color: var(--text); }
.meta-chip span { color: var(--text-soft); }

/* ── DETALLE BODY ── */
.detail-body {
  padding: 16px 20px;
  flex: 1;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-soft);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.detail-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: .85rem;
  color: var(--text-mid);
  line-height: 1.45;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.detail-step:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: var(--ica-blue-light);
  color: var(--ica-blue);
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.admin-note-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-left: 4px solid #f9a825;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .83rem;
  color: #5d4037;
  line-height: 1.5;
}

.alert-box {
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.alert-box.warning { background: #fff3e0; color: #e65c00; border: 1px solid #ffcc80; }

.alert-box-link {
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.alert-box-link:hover { background: #ffe6c2; box-shadow: 0 2px 8px rgba(230,92,0,.18); }
.alert-box.danger  { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.alert-box.info    { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.alert-box.turno-ica {
  background: #e0f4fb;
  color: #08445f;
  border: 1px solid #81d4fa;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
}

/* ── DETAIL FOOTER ── */
/* ── BOTONES GENERALES ── */
.btn-primary {
  padding: 9px 18px;
  background: var(--ica-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--ica-blue-dark); }

.btn-secondary {
  padding: 9px 18px;
  background: var(--surface);
  color: var(--text-mid);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.btn-secondary:hover { background: var(--ica-blue-pale); border-color: var(--ica-blue-mid); color: var(--ica-blue); }

/* ── MODALES ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--ica-blue-pale);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ica-blue-dark);
}

.modal-close {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  transition: all var(--transition);
}
.modal-close:hover { background: #ffebee; color: var(--ica-red); border-color: var(--ica-red); }

.modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-mid);
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus {
  border-color: var(--ica-blue-mid);
  box-shadow: 0 0 0 3px rgba(0,119,204,.1);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 400;
  transform: translateY(0);
  transition: all .3s ease;
  max-width: 360px;
}
.toast.success { background: var(--ica-accent-dark); }
.toast.error   { background: var(--ica-red); }

/* ── BOTÓN VOLVER (solo visible en móvil) ── */
.mobile-back-btn {
  display: none;
}

/* ── TARJETAS DE DOCUMENTOS ── */
.doc-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ica-blue-pale);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ica-blue);
  font-weight: 600;
  font-size: .88rem;
  transition: background .15s, border-color .15s;
}
.doc-link-card:hover {
  background: #d0e8ff;
  border-color: var(--ica-blue);
}

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-soft);
  gap: 12px;
}
.empty-state-icon { font-size: 2.5rem; }
.empty-state p { font-size: .9rem; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0c4d8; }

/* ── FOOTER ── */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background: linear-gradient(90deg, var(--ica-red) 0%, var(--ica-blue-dark) 55%);
  border-top: 1px solid rgba(255,255,255,.1);
  z-index: 90;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
  gap: 16px;
}

.footer-brand {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
  white-space: nowrap;
}
.footer-brand strong { color: #fff; }

.footer-contacts {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: .82rem;
  color: rgba(255,255,255,.8);
}
.footer-contacts strong { color: #fff; }
.footer-contacts a {
  color: rgba(255,255,255,.8);
  text-decoration: none;
}
.footer-contacts a:hover { color: #fff; text-decoration: underline; }

/* ── PRINT ── */
@media print {
  .header, .sidebar, .view-tabs, .graph-toolbar,
  .site-footer, .detail-footer, .modal-overlay { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; height: auto; border: none; }
  .main-area { display: none; }
}

/* ── RESPONSIVE ── */
@media (max-width: 1200px) {
  :root { --detail-w: 420px; }
  #map-tiles { grid-template-columns: repeat(4, 1fr); }
}

/* ── NOTEBOOK 13" (861px – 1400px): sidebar de categorías ── */
@media (min-width: 861px) and (max-width: 1400px) {
  #graph-container {
    flex-direction: row;
  }

  /* Categorías → columna lateral izquierda */
  #map-tiles {
    display: flex;
    flex-direction: column;
    width: 200px;
    flex-shrink: 0;
    border-bottom: none;
    border-right: 2px solid var(--border);
    overflow-y: auto;
    padding: 10px 8px;
    gap: 4px;
  }

  .cat-tile {
    flex-direction: row;
    padding: 10px 12px;
    gap: 10px;
    text-align: left;
    border-radius: 8px;
    transform: none !important;
  }

  .cat-tile-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
  }

  .cat-tile-icon-box svg {
    width: 18px;
    height: 18px;
  }

  .cat-tile-name {
    font-size: .8rem;
    text-align: left;
    flex: 1;
    line-height: 1.3;
  }

  .cat-tile-count {
    font-size: .68rem;
    white-space: nowrap;
  }

  /* Procedimientos → ocupa todo el espacio restante */
  #map-procs {
    min-width: 0;
    flex: 1;
  }

  /* Tarjetas de procedimientos: 2 columnas más compactas */
  .map-procs-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
  }

  .map-procs-header {
    padding: 14px 16px;
    margin-bottom: 14px;
  }

  .map-procs-icon-box {
    width: 44px;
    height: 44px;
  }

  .map-procs-title {
    font-size: 1.15rem;
  }
}

@media (max-width: 860px) {
  :root { --detail-w: 100vw; }
  .header-titles { display: none; }
  .footer-contacts { gap: 12px; font-size: .75rem; }
  .btn-header-action { font-size: .75rem; padding: 6px 10px; }
  .procedure-list { grid-template-columns: 1fr; }
}

/* ── MÓVIL (≤ 600px) ── */
@media (max-width: 600px) {
  :root {
    --header-h: 56px;
    --detail-w: 100vw;
  }

  html { font-size: 14px; }

  /* Header compacto */
  .header-inner { padding: 0 10px; gap: 8px; }
  .header-logo { height: 28px; }
  .header-titles { display: none; }
  .search-input { font-size: .82rem; padding: 7px 10px 7px 30px; }

  /* Tabs */
  .view-tabs { padding: 0 4px; }
  .view-tab { padding: 10px 10px; font-size: .8rem; }

  /* Tiles de categoría — 2 columnas, texto truncado en una línea */
  #map-tiles {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .cat-tile { padding: 10px 6px; gap: 4px; }
  .cat-tile-icon-box { width: 36px; height: 36px; border-radius: 9px; }
  .cat-tile-icon-box svg { width: 18px; height: 18px; }

  .cat-tile-name {
    font-size: .76rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    align-self: stretch;
    text-align: center;
  }

  .cat-tile-count { font-size: .66rem; }

  /* Área de procedimientos del mapa */
  #graph-container {
    height: calc(100dvh - var(--header-h) - 44px - 48px);
  }
  #map-procs { padding: 10px; }
  .map-procs-grid { grid-template-columns: 1fr; gap: 10px; }
  .map-procs-header { padding: 10px 12px; gap: 10px; margin-bottom: 12px; }
  .map-procs-icon-box { width: 40px; height: 40px; border-radius: 10px; }
  .map-procs-icon-box svg { width: 20px; height: 20px; }
  .map-procs-title { font-size: 1.05rem; }

  /* Lista — columna única */
  .procedure-list { grid-template-columns: 1fr; padding: 10px; gap: 8px; }
  .list-toolbar { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }

  /* Panel de detalle — pantalla completa */
  .detail-panel { top: 0; bottom: 0; width: 100vw; height: 100dvh; }
  .detail-backdrop { inset: 0; }
  .detail-header { padding: 16px 14px 12px; }
  .detail-meta { padding: 10px 14px; gap: 5px; }
  .meta-chip { font-size: .72rem; padding: 4px 8px; }
  .detail-body { padding: 12px 14px; }

  /* Footer — ocultar email en pantallas muy chicas */
  .footer-inner { padding: 0 10px; gap: 6px; }
  .footer-brand { font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .footer-contacts { gap: 6px; font-size: .68rem; }
  .footer-contacts span:last-child { display: none; }

  /* Toast */
  .toast { right: 10px; bottom: 58px; left: 10px; max-width: none; }

  /* Botón volver — visible solo en móvil */
  .mobile-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--ica-blue-pale);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--ica-blue);
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    text-align: left;
  }

  /* Al seleccionar categoría en móvil: ocultar tiles y expandir procedimientos */
  #graph-container.cat-selected #map-tiles { display: none; }
  #graph-container.cat-selected #map-procs {
    height: calc(100dvh - var(--header-h) - 44px - 48px);
    overflow-y: auto;
  }
}

/* ── MÓVIL MUY PEQUEÑO (≤ 380px) ── */
@media (max-width: 380px) {
  #map-tiles { gap: 6px; padding: 8px; }
  .cat-tile { padding: 8px 4px; }
  .cat-tile-name { font-size: .72rem; }
  .view-tab { font-size: .75rem; padding: 10px 8px; }
  .footer-contacts { display: none; }
}
