* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #1e1e1e; color: #eee; min-height: 100vh; padding: 1rem; }

.view { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Botón casita (igual que territorios) ── */
.btn-home {
  position: fixed; top: 14px; right: 14px; z-index: 100;
  width: 44px; height: 44px; border-radius: 12px;
  background: #252525; border: 0.5px solid #444; color: #888;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-home.visible { display: flex; }
.btn-home:hover { background: #333; color: #eee; }

/* ── Cover ── */
.cover {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: calc(100vh - 2rem);
  gap: 14px; max-width: 320px; margin: 0 auto; padding: 2rem 0;
}
.cover-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: rgba(127,119,221,0.15); border: 1px solid rgba(127,119,221,0.3);
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.cover-title {
  font-size: 48px; font-weight: 500; color: #eee;
  letter-spacing: -0.5px; line-height: 1;
}
.cover-subtitle { font-size: 16px; color: #7F77DD; margin-bottom: 4px; font-weight: 500; }
.grupo-label { font-size: 14px; color: #888; margin-bottom: 4px; }

/* ── Modo cards (idéntico a territorios) ── */
.modo-card {
  width: 100%; max-width: 320px; background: #2a2a2a;
  border: 1.5px solid #444; border-radius: 14px;
  padding: 1.25rem 1.5rem; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 16px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.modo-card:hover { transform: scale(1.02); }
.modo-card:active { transform: scale(0.98); }
.modo-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.modo-card-title { font-size: 16px; font-weight: 500; color: #eee; margin-bottom: 3px; }
.modo-card-sub { font-size: 13px; color: #888; }

.modo-ver   { border-color: #1D9E75; }
.modo-ver:hover { background: rgba(29,158,117,0.08); }
.modo-buscar { border-color: #378ADD; }
.modo-buscar:hover { background: rgba(55,138,221,0.08); }
.modo-encargado { border-color: #555; }
.modo-encargado:hover { background: rgba(127,119,221,0.08); border-color: #7F77DD; }

/* ── Section titles (igual territorios) ── */
.section-title { font-size: 22px; font-weight: 500; color: #eee; margin-bottom: 4px; text-align: center; }
.section-sub { font-size: 14px; color: #888; margin-bottom: 16px; text-align: center; }

/* ── Loading / Error ── */
.loading-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; gap: 14px; }
.spinner { width: 32px; height: 32px; border: 3px solid #333; border-top-color: #7F77DD; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 14px; color: #888; }
.error-wrap { background: #2e1a1a; border: 0.5px solid #A32D2D; border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 16px; font-size: 13px; color: #F09595; }

/* ── Reunion card ── */
.reunion-card {
  background: #2a2a2a; border: 0.5px solid #333; border-radius: 12px;
  overflow: hidden; margin-bottom: 12px;
}
.reunion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
}
.reunion-dia { font-size: 18px; font-weight: 500; }
.reunion-fecha { font-size: 13px; color: #888; }
.roles-list { padding: 8px 14px 12px; }
.rol-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 0.5px solid #2e2e2e;
}
.rol-row:last-child { border-bottom: none; }
.rol-label { font-size: 12px; color: #888; flex-shrink: 0; width: 140px; }
.rol-valor { font-size: 13px; color: #ddd; text-align: right; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #555; font-size: 14px; }

/* ── Buscar hermano ── */
.buscar-wrap { max-width: 400px; }
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: #2a2a2a; border: 0.5px solid #444; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px;
}
.search-box input {
  background: none; border: none; color: #eee; font-size: 15px;
  flex: 1; outline: none;
}
.search-box input::placeholder { color: #555; }
.search-suggestions {
  background: #252525; border: 0.5px solid #444; border-radius: 10px;
  overflow: hidden; margin-bottom: 12px;
}
.sugg-item {
  display: block; width: 100%; padding: 10px 14px; background: none;
  border: none; border-bottom: 0.5px solid #333; color: #ccc;
  font-size: 14px; text-align: left; cursor: pointer;
}
.sugg-item:last-child { border-bottom: none; }
.sugg-item:hover { background: #2e2e2e; color: #eee; }
.buscar-nombre { font-size: 22px; font-weight: 500; color: #eee; margin-bottom: 2px; }
.buscar-semana { font-size: 13px; color: #888; margin-bottom: 14px; }
.asig-card {
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px; border: 0.5px solid #333;
}
.asig-dia { font-size: 15px; font-weight: 500; min-width: 90px; }
.asig-fecha { font-size: 12px; color: #888; flex: 1; }
.asig-rol {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: rgba(127,119,221,0.15); color: #7F77DD; border: 0.5px solid rgba(127,119,221,0.3);
}
.buscar-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 3rem 1rem; color: #555; font-size: 14px;
}

/* ── Encargado menú ── */
.enc-menu { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ── Editar ── */
.edit-card {
  background: #2a2a2a; border: 0.5px solid #333; border-radius: 12px;
  padding: 14px; margin-bottom: 14px;
}
.edit-rol-row { margin-bottom: 8px; }
.edit-rol-label { font-size: 12px; color: #888; display: block; margin-bottom: 3px; }
.edit-rol-select {
  width: 100%; font-size: 13px; padding: 6px 8px; border: 0.5px solid #444;
  border-radius: 8px; background: #1e1e1e; color: #eee;
}
.edit-rol-select option { background: #2a2a2a; }
.semana-nav-btn {
  font-size: 18px; padding: 2px 12px; border: 0.5px solid #444;
  border-radius: 8px; background: #2a2a2a; color: #aaa; cursor: pointer;
}
.semana-nav-btn:hover { background: #333; color: #eee; }

/* ── Auto info ── */
.auto-info {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: #888; background: #252525;
  border: 0.5px solid #333; border-radius: 10px; padding: 12px 14px;
  margin-bottom: 14px;
}

/* ── Tabla imagen ── */
.card-tabla {
  background: #1e1e1e; border: 0.5px solid #7F77DD;
  border-radius: 16px; overflow: hidden;
}
.card-tabla-header {
  background: #12122a; padding: 14px 18px;
  border-bottom: 0.5px solid rgba(127,119,221,0.3);
}
.card-tabla-top { font-size: 11px; color: #7F77DD; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.card-tabla-main { font-size: 16px; font-weight: 500; color: #eee; }
.tabla-reunion-wrap { padding: 14px 18px; border-bottom: 0.5px solid #2a2a2a; }
.tabla-reunion-wrap:last-child { border-bottom: none; }
.tabla-dia-header { font-size: 16px; font-weight: 500; padding-bottom: 8px; margin-bottom: 8px; }
.tabla-roles { width: 100%; border-collapse: collapse; }
.tabla-rol { font-size: 12px; color: #888; padding: 4px 0; width: 140px; }
.tabla-val { font-size: 13px; color: #ddd; padding: 4px 0; }

/* ── Botones comunes ── */
.btn-primary {
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  background: #7F77DD; color: white; border: none; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary:hover { background: #6a62c4; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-secondary {
  padding: 10px 16px; font-size: 14px; border: 0.5px solid #555;
  border-radius: 8px; background: #2a2a2a; color: #ccc; cursor: pointer;
  display: inline-block;
}
.btn-secondary:hover { background: #333; }
.btn-guardar {
  width: 100%; padding: 12px; font-size: 15px; font-weight: 500;
  background: #1D9E75; color: white; border: none; border-radius: 8px; cursor: pointer;
}
.btn-guardar:hover { background: #0F6E56; }
.btn-guardar:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-save {
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  background: #7F77DD; color: white; border: none; border-radius: 8px; cursor: pointer;
}
.btn-save:hover { background: #6a62c4; }
.save-status { text-align: center; font-size: 13px; margin-top: 10px; min-height: 20px; }

/* ── PIN (igual a territorios) ── */
.pin-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.pin-card {
  background: #252525; border: 1px solid #7F77DD; border-radius: 20px;
  padding: 28px 24px; width: 300px; text-align: center;
}
.pin-title { font-size: 26px; font-weight: 500; color: #7F77DD; margin-bottom: 6px; }
.pin-sub { font-size: 14px; color: #888; margin-bottom: 22px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 22px; }
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #555; background: transparent; transition: all 0.1s;
}
.pin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.pin-btn {
  padding: 16px; font-size: 22px; border-radius: 12px;
  border: 0.5px solid #444; background: #2a2a2a; color: #eee; cursor: pointer;
  transition: background 0.1s;
}
.pin-btn:hover { background: #333; }
.pin-btn:active { background: rgba(127,119,221,0.2); }
.pin-del { font-size: 16px; }
.pin-error { font-size: 13px; color: #F09595; min-height: 20px; margin-bottom: 8px; }
.pin-cancel { background: none; border: none; color: #555; font-size: 13px; cursor: pointer; padding: 4px 8px; }
.pin-cancel:hover { color: #888; }

/* ── App container ── */
.app { max-width: 480px; margin: 0 auto; }

/* ── Fixes adicionales ── */

/* Botón casita — oculto por defecto, visible con clase */
.btn-home {
  position: fixed; top: 14px; right: 14px; z-index: 100;
  width: 44px; height: 44px; border-radius: 12px;
  background: #252525; border: 0.5px solid #444; color: #888;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.btn-home.visible { display: flex; }
.btn-home:hover { background: #333; color: #eee; }

/* Bordes específicos para cards del encargado */
.modo-editar  { border-color: #378ADD !important; }
.modo-editar:hover { background: rgba(55,138,221,0.08) !important; }
.modo-auto    { border-color: #1D9E75 !important; }
.modo-auto:hover { background: rgba(29,158,117,0.08) !important; }
.modo-imagen  { border-color: #FAC775 !important; }
.modo-imagen:hover { background: rgba(250,199,117,0.08) !important; }
.modo-encargado { border-color: #7F77DD !important; }
.modo-encargado:hover { background: rgba(127,119,221,0.08) !important; border-color: #7F77DD !important; }

/* Layout buscar — que no quede el botón volver pegado abajo */
.view-buscar-layout {
  min-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
}
.view-buscar-layout .buscar-wrap { flex: 1; }

/* Section title más grande */
.section-title { font-size: 28px !important; font-weight: 500; }

/* ── Buscar hermano — semanas ── */
.semana-bloque { margin-bottom: 16px; }
.semana-bloque-title {
  font-size: 12px; color: #666; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px; padding-left: 2px;
}
.asig-tiene { opacity: 1; }
.asig-libre { opacity: 0.45; }
.asig-rol-libre {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: rgba(80,80,80,0.15); color: #555;
  border: 0.5px solid #333;
}

/* Sugerencia activa con teclado */
.sugg-active { background: #333 !important; color: #eee !important; }

/* Semana bloque en buscar */
.semana-bloque { margin-bottom: 16px; }
.semana-bloque-title { font-size: 12px; color: #7F77DD; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; padding: 4px 0; border-bottom: 0.5px solid #2a2a2a; }
.asig-libre { opacity: 0.45; }
.asig-rol-libre { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: #2a2a2a; color: #555; border: 0.5px solid #333; }

/* ── Gestionar hermanos ── */
.hermano-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #2a2a2a; border: 0.5px solid #333; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; gap: 10px;
}
.hermano-info { flex: 1; min-width: 0; }
.hermano-nombre { font-size: 14px; font-weight: 500; color: #eee; margin-bottom: 4px; }
.hermano-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.rol-chip {
  font-size: 11px; padding: 2px 7px; border-radius: 12px;
  background: rgba(127,119,221,0.15); color: #9990ee;
  border: 0.5px solid rgba(127,119,221,0.3);
}
.hermano-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-edit-hermano {
  padding: 6px 8px; border-radius: 8px; border: 0.5px solid #444;
  background: #2a2a2a; cursor: pointer; font-size: 14px;
}
.btn-edit-hermano:hover { background: #333; }
.btn-del-hermano {
  padding: 6px 8px; border-radius: 8px; border: 0.5px solid #A32D2D;
  background: #2e1a1a; color: #F09595; cursor: pointer; font-size: 12px;
}
.btn-del-hermano:hover { background: #3a2020; }

/* Modal hermano */
.modal-hermano-card {
  background: #252525; border: 1px solid #7F77DD; border-radius: 16px;
  padding: 24px; width: 90%; max-width: 380px; max-height: 90vh;
  overflow-y: auto;
}
.modal-hermano-titulo { font-size: 20px; font-weight: 500; color: #7F77DD; margin-bottom: 16px; }
.modal-hermano-roles-titulo { font-size: 12px; color: #888; margin-bottom: 8px; }
.modal-roles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.rol-checkbox {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: #ccc; cursor: pointer;
  background: #1e1e1e; border: 0.5px solid #333; border-radius: 8px;
  padding: 7px 10px; transition: background 0.1s;
}
.rol-checkbox:hover { background: #2a2a2a; }
.rol-checkbox input { accent-color: #7F77DD; width: 14px; height: 14px; cursor: pointer; }
.rol-checkbox input:checked + span { color: #eee; }

/* Card gestionar en encargado */
.modo-gestionar { border-color: #1D9E75 !important; }
.modo-gestionar:hover { background: rgba(29,158,117,0.08) !important; }


/* ── Offline banner ── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #2e1a1a;
  border-bottom: 1.5px solid #A32D2D;
  color: #F09595;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  padding: 10px;
  z-index: 999;
  display: none;
}
.offline-banner.visible {
  display: block;
}

/* ── Modal preview automático ── */
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.preview-modal-card {
  background: #2a2a2a;
  border: 0.5px solid #555;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 0.5px solid #444;
  position: sticky;
  top: 0;
  background: #2a2a2a;
  z-index: 1;
  flex-shrink: 0;
}
.preview-modal-title {
  font-size: 15px;
  font-weight: 500;
  color: #eee;
}
.preview-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0.5px solid #555;
  background: #1e1e1e;
  color: #aaa;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-modal-close:hover { background: #333; color: #eee; }
.preview-modal-body { padding: 12px 16px; }
