.panel-body { background: var(--bg-soft); min-height: 100vh; }

/* Login card */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 400px; }
.login-card .brand { display: flex; justify-content: center; margin-bottom: 10px; }
.login-card h2 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login-hint { margin-top: 16px; font-size: 12.5px; color: var(--muted); text-align: center; background: var(--bg-soft); padding: 10px; border-radius: 10px; }

/* Layout app */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; align-items: start; }
/* Barra lateral fija: queda pegada arriba y ocupa toda la altura de la ventana,
   con su propio scroll interno. No se mueve con el scroll del contenido. */
.sidebar {
  background: #1a1a1a; color: #fff; padding: 24px 16px;
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand { color: #fff; margin-bottom: 28px; padding: 0 8px; flex-shrink: 0; }
/* La navegación toma el espacio disponible; si no cabe, scrollea dentro del sidebar. */
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; overflow-y: auto; }
.side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: none; color: #c9c2d6; padding: 11px 14px; border-radius: 10px;
  cursor: pointer; font-size: 15px; font-weight: 500; font-family: inherit;
}
.side-nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav button.active { background: var(--primary); color: #fff; }
.sidebar .side-foot { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); flex-shrink: 0; }
.sidebar .side-foot .biz { font-size: 13px; color: #c9c2d6; padding: 0 8px 12px; }
/* Botón "Cerrar sesión" en el sidebar oscuro: contorno claro, texto blanco,
   fondo transparente. Buen contraste y hover legible. */
.sidebar .side-foot .btn {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.28);
}
.sidebar .side-foot .btn:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.5);
  color: #fff;
}

.main-area { padding: 28px 32px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 26px; letter-spacing: -.5px; }
.page-head p { color: var(--muted); font-size: 14px; }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  /* En móvil el sidebar vuelve a ser una barra superior (no de altura completa).
     Se organiza como: marca (izq) + "Cerrar sesión" (der) en la fila superior,
     y la navegación en una fila propia debajo que scrollea horizontal. */
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 12px; }
  .sidebar .brand { margin-bottom: 0; }
  .side-nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; -webkit-overflow-scrolling: touch; }
  /* El pie deja de ocultarse: se vuelve un botón compacto arriba a la derecha. */
  .sidebar .side-foot {
    display: flex; align-items: center;
    margin-top: 0; margin-left: auto; padding-top: 0; border-top: none;
    order: 2;
  }
  .sidebar .side-foot .biz { display: none; }      /* el nombre del negocio no es crítico en móvil */
  .sidebar .side-foot .btn { width: auto; padding: 9px 16px; font-size: 14px; white-space: nowrap; }
  /* Selector de sucursal (si existe): fila propia a ancho completo, bajo la nav. */
  .sidebar .branch-switcher { order: 4; flex: 1 1 100%; margin: 2px 0 0; }
}

/* Cards de métricas */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.metric .m-num { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.metric .m-lbl { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .metrics { grid-template-columns: repeat(2, 1fr); } }

/* Tablas */
.data-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; width: 100%; box-sizing: border-box; }
/* Permite scroll horizontal de las tablas sin cortar columnas en pantallas chicas.
   display:block + width:100% evita que el contenedor con overflow se encoja al
   contenido (que dejaba la grilla sin ocupar todo el ancho). */
.data-card:has(table.data) { overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; width: 100%; }
table.data { width: 100%; min-width: 100%; border-collapse: collapse; }
/* El separador de fila va en el <tr> (una sola línea continua), no en cada
   <td>, para que no se descuadre cuando una celda (p. ej. el menú ⋯) es más
   alta que las demás. */
table.data th, table.data td { text-align: left; padding: 13px 16px; font-size: 14.5px; vertical-align: middle; }
table.data thead tr { border-bottom: 1px solid var(--line); }
table.data tbody tr { border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child { border-bottom: none; }
table.data th { background: var(--bg-soft); color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
table.data tr:hover td { background: #faf9fd; }

/* Mantenedor de notificaciones: grupos + filas con interruptor (switch) */
.notif-group { margin-bottom: 14px; }
.notif-group:last-child { margin-bottom: 0; }
.notif-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 4px 0 8px; }
.notif-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notif-row:last-child { border-bottom: none; }
.notif-label { font-size: 14.5px; }
/* Interruptor tipo toggle (prender/apagar) */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: #cfd4da; border-radius: 999px; transition: background .2s ease; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--brand, #0f9d7a); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Teléfono del cliente como enlace a WhatsApp. */
.wa-link { color: #128c7e; font-weight: 600; text-decoration: none; white-space: nowrap; }
.wa-link:hover { text-decoration: underline; }
.wa-link .wa-ico { font-size: 12px; }

.tag-status { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag-status.active, .tag-status.confirmed { background: #e6f9f2; color: #067a55; }
.tag-status.trialing, .tag-status.pending { background: #fff3d6; color: #8a6100; }
.tag-status.cancelled { background: #fdecec; color: var(--danger); }
.tag-status.done { background: var(--primary-light); color: var(--primary); }

/* Columna de acciones: ancho fijo acotado y botones que ENVUELVEN dentro de ese
   ancho (nunca se desbordan de la tarjeta, tengan 1 o 6 botones). El resto de
   columnas reparten el ancho disponible. */
/* ---- Columna de acciones: menú desplegable (⋯) para todas las grillas ----
   En vez de varios botones sueltos (que se desbordaban), cada fila tiene un
   único botón "⋯" que abre un menú con las acciones. Limpio y uniforme. */
td.row-actions { text-align: right; white-space: nowrap; padding-top: 6px; padding-bottom: 6px; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; }

/* Botón que abre el menú (kebab) */
.actions-menu { position: relative; display: inline-block; }
.actions-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1;
  transition: border-color .15s ease, background .15s ease;
}
.actions-trigger:hover { border-color: var(--primary); color: var(--primary); background: #faf7ff; }
.actions-menu.open .actions-trigger { border-color: var(--primary); color: var(--primary); background: #faf7ff; }

/* Panel del menú: position fixed (coordenadas calculadas en JS al abrir) para
   que NO lo recorte el overflow de la tarjeta. */
.actions-pop {
  position: fixed; z-index: 2000;
  min-width: 190px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.2);
  padding: 6px; display: none; text-align: left;
}
.actions-menu.open .actions-pop { display: block; }
.actions-pop button, .actions-pop a {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--ink); padding: 9px 11px; border-radius: 7px; cursor: pointer; text-decoration: none;
}
.actions-pop button:hover, .actions-pop a:hover { background: var(--bg-soft, #f4f2f8); color: var(--primary); }
.actions-pop button.danger:hover { background: #fdecec; color: var(--danger); }
.actions-pop .menu-sep { height: 1px; background: var(--line); margin: 5px 2px; }

/* Botones sueltos antiguos (aún usados en modales/toolbars). */
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 600; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.toolbar { display: flex; align-items: flex-end; margin-bottom: 16px; gap: 14px; flex-wrap: wrap; }
.tb-group { display: flex; flex-direction: column; gap: 5px; }
.tb-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.tb-group input[type="date"], .tb-group select { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; background: #fff; height: 40px; }
.tb-group .cal-nav .icon-btn { height: 40px; }
.tb-group .view-toggle { height: 40px; }
.toolbar .staff-legend { margin-left: auto; align-self: center; }

/* Chips de servicios / horarios */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--primary-light); color: var(--primary); padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.chip.muted { background: var(--bg-soft); color: var(--muted); }

/* Editor de horario semanal */
.week-editor { display: flex; flex-direction: column; gap: 10px; }
.week-row { display: grid; grid-template-columns: 120px 1fr 1fr 40px; gap: 10px; align-items: center; }
.week-row .day-label { font-weight: 600; font-size: 14px; }
.week-row.disabled { opacity: .45; }
.week-toggle { display: flex; align-items: center; gap: 8px; }

.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checklist label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.checklist label:hover { border-color: var(--primary); }
.checklist input { width: auto; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; transform: translateY(10px); transition: all .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.share-box { background: var(--primary-light); border: 1px solid var(--primary); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.share-box code { background: #fff; padding: 6px 10px; border-radius: 8px; font-size: 13px; }

/* Timeline de historial */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.tl-content { flex: 1; min-width: 0; }
.tl-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tl-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tl-detail { font-size: 14px; color: var(--ink); margin: 2px 0; }
.tl-actor { font-size: 12px; color: var(--muted); }

/* Aviso de vencimiento (niveles) */
.notice { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 15px; }
.notice.info { background: #eef4ff; color: #1e4fa3; border: 1px solid #cfe0ff; }
.notice.warning { background: #fff3d6; color: #8a6100; border: 1px solid #ffe1a3; }
.notice.critical { background: #fdecec; color: var(--danger); border: 1px solid #f6c9cb; }

/* Toggle Lista / Calendario */
.view-toggle { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.vt-btn { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); font-family: inherit; }
.vt-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* Leyenda de barberos */
.staff-legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-left: auto; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.staff-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }

/* Calendario */
.cal-wrap { display: flex; width: 100%; min-width: max-content; }
.cal-days { flex: 1; }
/* Columna de horas: fija a la izquierda (sticky) para que SIEMPRE se vea al
   hacer scroll horizontal en la vista semana. z-index alto para quedar sobre
   los eventos. */
.cal-hours { width: 56px; flex-shrink: 0; border-right: 1px solid var(--line); background: #fff; position: sticky; left: 0; z-index: 5; }
.cal-corner { height: 44px; box-sizing: border-box; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 6; }
/* Cuerpo de la columna de horas: contenedor relativo de la MISMA altura que el
   cuerpo de cada día, con las etiquetas posicionadas en absoluto (top). Así la
   hora cuadra pixel a pixel con la línea y el evento, sin desfase acumulado. */
.cal-hours-body { position: relative; }
.cal-hour { position: absolute; right: 8px; transform: translateY(-6px); font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.cal-days { display: flex; }
.cal-day { min-width: 170px; flex: 1; border-right: 1px solid var(--line); }
.cal-day:last-child { border-right: none; }
/* Altura FIJA del encabezado de día (y debe coincidir con .cal-corner = 44px).
   box-sizing + overflow evitan que el tag "cerrado" agrande el header de ciertos
   días y desalinee la rejilla respecto de la columna de horas. */
.cal-day-head { height: 44px; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 6px; row-gap: 0; font-weight: 700; font-size: 12.5px; text-transform: capitalize; border-bottom: 1px solid var(--line); background: var(--bg-soft); position: sticky; top: 0; z-index: 2; }
.cal-day-body { position: relative; }
.cal-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); opacity: .25; }
.cal-line.cal-line-half { border-top-style: solid; opacity: .45; }
.cal-line.cal-line-hour { border-top-style: solid; opacity: .75; }
/* IMPORTANTE: los eventos usan [data-tip] para el tooltip, y la regla global
   [data-tip]{position:relative} (ver más abajo) tiene la misma especificidad y
   la pisaría por orden de cascada, dejándolos en relative y apilándolos. Por eso
   la posición absoluta se declara con mayor especificidad (.cal-day-body .cal-event). */
.cal-day-body .cal-event { position: absolute; }
.cal-event { left: 2px; width: calc(100% - 6px); border-radius: 8px; padding: 4px 8px; font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: box-shadow .15s ease, filter .15s ease; display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; }
.cal-event:hover { box-shadow: var(--shadow); filter: brightness(.97); z-index: 6; }
/* Nombre del cliente: hora en negrita + nombre. Permite hasta 2 líneas antes de recortar,
   para que no se pierda el texto en columnas angostas. */
.cal-event .ce-name { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.cal-event .ce-time { font-weight: 800; font-size: 11px; margin-right: 3px; }
/* Servicio · profesional: una línea, con puntos suspensivos si no cabe. */
.cal-event .ce-svc { display: block; opacity: .8; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* En cajas muy bajas (servicios cortos) ocultamos la 2ª línea para que no se amontone. */
.cal-event.cal-event-sm { padding: 3px 7px; gap: 0; }
.cal-event.cal-event-sm .ce-name { -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; }
.cal-event.cal-event-sm .ce-svc { display: none; }

/* Tooltip flotante del calendario */
.cal-tooltip { position: fixed; z-index: 300; background: var(--ink); color: #fff; padding: 10px 13px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; max-width: 260px; box-shadow: var(--shadow-lg); pointer-events: none; opacity: 0; transition: opacity .12s ease; }
.cal-tooltip.show { opacity: 1; }

/* Editor de días habilitados (negocio) */
.day-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.day-toggle { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600; user-select: none; }
.day-toggle input { width: auto; }
.day-toggle.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.timeoff-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.timeoff-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }

/* Calendario full: rango, celdas clicables, días cerrados */
.cal-range { padding: 12px 16px; font-weight: 700; font-size: 14px; text-transform: capitalize; border-bottom: 1px solid var(--line); background: #fff; position: sticky; left: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-range .cal-range-text { text-transform: capitalize; }
.cal-range .cal-hint { font-weight: 500; color: var(--muted); text-transform: none; font-size: 13px; }
.cal-range .cal-nav { flex-shrink: 0; }
.cal-cell { position: absolute; left: 0; right: 0; cursor: pointer; }
.cal-cell:hover { background: rgba(0,0,0,.05); }
.cal-day.cal-closed .cal-day-body { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 8px, #f0f0f1 8px, #f0f0f1 16px); }
.cal-day.cal-closed .cal-day-head { color: var(--muted); }
.cal-closed-tag { font-size: 11px; font-weight: 600; color: var(--danger); background: #fdecec; padding: 1px 7px; border-radius: 999px; text-transform: none; }
.cal-day.cal-today .cal-day-head { background: var(--primary-light); color: var(--primary); }
.cal-event { z-index: 2; }
/* Reserva provisoria (sin confirmar): borde punteado para distinguirla a simple vista. */
.cal-event.cal-event-pending { border: 1.5px dashed rgba(0,0,0,.35); border-left-width: 3px; }
.cal-event .ce-prov { font-weight: 600; opacity: .75; font-size: 10.5px; }

/* Drag & drop de reservas en el calendario */
.cal-event { user-select: none; }
.cal-event[draggable="true"] { cursor: grab; }
.cal-event.dragging { opacity: .45; cursor: grabbing; }
.cal-cell.drop-hover { background: rgba(0,0,0,.06); box-shadow: inset 0 0 0 2px var(--primary); }

/* Enlace a la página principal desde el login */
.login-home { display: inline-block; margin-bottom: 16px; font-size: 13.5px; font-weight: 600; color: var(--primary); }
.login-home:hover { text-decoration: underline; }

/* Navegación de semanas del calendario */
.cal-nav { display: inline-flex; align-items: center; gap: 4px; }
.cal-nav .icon-btn { min-width: 38px; font-size: 16px; font-weight: 700; }
.cal-nav .icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Logo del negocio */
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 96px; height: 96px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-soft); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 13px; }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Avatar del profesional */
.avatar-preview { width: 80px; height: 80px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-soft); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-weight: 700; font-size: 22px; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; overflow: hidden; flex-shrink: 0; }
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

/* Galería */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery-item { position: relative; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-del { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; cursor: pointer; line-height: 1; display: grid; place-items: center; }
.gallery-del:hover { background: var(--danger); }

/* HOME del panel: hero con logo + carrusel */
.home-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.home-logo { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.home-logo-ph { display: grid; place-items: center; background: var(--primary-light); color: var(--ink); font-weight: 800; font-size: 24px; }
.home-hero-info h1 { font-size: 24px; letter-spacing: -.5px; }
.home-hero-info p { color: var(--muted); font-size: 14px; }
.home-gallery-note { margin: -8px 0 20px; font-size: 13px; color: var(--muted); }
.home-gallery-note a { color: var(--primary); font-weight: 600; }
.carousel-slide-ph { width: 100%; height: 100%; }

/* Carrusel (reutilizado en el panel) — full-width y compacto en altura */
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow); background: #000; width: 100%; }
.carousel-track { display: flex; transition: transform .6s ease; }
.carousel-slide { min-width: 100%; height: 180px; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; }
.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(255,255,255,.9); color: #1a1a1a; font-size: 18px; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); }
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-btn:hover { background: #fff; }
.carousel-dots { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; }
.cdot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.5); cursor: pointer; }
.cdot.on { background: #fff; }

/* Editor de horario de atención del negocio (por día) */
.hours-editor { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.hours-row { display: grid; grid-template-columns: 150px 1fr auto 1fr; align-items: center; gap: 10px; }
.hours-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.hours-toggle input { width: auto; }
.hours-day { font-weight: 600; font-size: 14px; }
.hours-row.off .hours-day { color: var(--muted); }
.hours-row.off { opacity: .55; }
.hours-sep { color: var(--muted); font-size: 13px; text-align: center; }
.hours-row input[type="time"] { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; }
.hours-row input[type="time"]:disabled { background: var(--bg-soft); }
@media (max-width: 540px) { .hours-row { grid-template-columns: 110px 1fr auto 1fr; } }

/* ============================================================
   Responsive móvil (iPhone y pantallas chicas)
   ============================================================ */
@media (max-width: 640px) {
  .main-area { padding: 16px 14px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 21px; }
  .page-head p { font-size: 13px; }

  /* El header de página con botón de acción se apila */
  .page-head > div:last-child { width: 100%; }

  /* Métricas: 2 columnas compactas */
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .metric { padding: 14px; }
  .metric .m-num { font-size: 24px; }
  .metric .m-lbl { font-size: 12px; }

  /* Toolbar en columna, controles a ancho completo */
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar .field { width: 100%; }
  .toolbar .field input, .toolbar .field select { width: 100%; }
  .view-toggle { width: 100%; justify-content: center; }
  .vt-btn { flex: 1; }
  .staff-legend { margin-left: 0; }

  /* Tablas: en móvil la tarjeta scrollea horizontalmente (overflow-x:auto),
     así que basta con reducir el padding; no forzamos min-width ni nowrap. */
  table.data th, table.data td { padding: 10px 12px; font-size: 13.5px; }

  /* Share box y tarjetas apiladas */
  .share-box { flex-direction: column; align-items: stretch; }
  .share-box code { word-break: break-all; }

  /* Hero del HOME */
  .home-hero { gap: 12px; }
  .home-hero button { margin-left: 0 !important; width: 100%; }
  .home-logo { width: 56px; height: 56px; }
  .home-hero-info h1 { font-size: 20px; }

  /* Carrusel más bajo en móvil */
  .carousel-slide { height: 140px; }

  /* Modales a ancho completo */
  .modal { max-width: 100%; padding: 22px 18px; border-radius: 16px; }
  .grid-2 { grid-template-columns: 1fr; }

  /* Editor de horario: etiqueta de día más angosta */
  .hours-row { grid-template-columns: 84px 1fr auto 1fr; gap: 6px; }
  .hours-row input[type="time"] { padding: 7px 6px; font-size: 13px; }

  /* Calendario: columnas más angostas pero legibles (scroll horizontal) */
  .cal-day { min-width: 128px; }
  .cal-hours { width: 46px; }

  /* Sidebar como barra superior horizontal */
  .sidebar { padding: 12px; row-gap: 10px; }
  .sidebar .brand { margin-bottom: 0; }
  .side-nav { margin-top: 2px; }
  .side-nav button { white-space: nowrap; font-size: 14px; padding: 9px 12px; }
  .sidebar .side-foot .btn { padding: 8px 14px; font-size: 13.5px; }
}

/* Pantallas medianas (tablet) */
@media (min-width: 641px) and (max-width: 900px) {
  .main-area { padding: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

/* Top clientes (HOME) */
.top-customers { display: flex; flex-direction: column; gap: 2px; }
.top-cust-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.top-cust-row:hover { background: var(--bg-soft); }
.top-rank { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-light); color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.top-cust-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top-cust-info small { color: var(--muted); }

/* Estadísticas del HOME (servicios/profesionales) */
.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 760px) { .stats-grid-2 { grid-template-columns: 1fr; } }
.stat-bars { display: flex; flex-direction: column; gap: 10px; }
.stat-bar-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px; }
.stat-bar-label { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-bar-track { background: var(--bg-soft); border-radius: 999px; height: 10px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.stat-bar-val { font-weight: 700; font-size: 13px; min-width: 24px; text-align: right; }

/* Buscador de clientes (grande) */
.cust-search-wrap { position: relative; max-width: 520px; margin-bottom: 16px; }
.cust-search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 16px; opacity: .6; pointer-events: none; }
.cust-search { width: 100%; padding: 14px 16px 14px 44px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 15px; font-family: inherit; background: #fff; }
.cust-search:focus { outline: none; border-color: var(--primary); }

/* "Mi negocio": layout de 2 columnas aprovechando el ancho */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.settings-col { display: flex; flex-direction: column; gap: 20px; }
.settings-grid .data-card form { max-width: none; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

/* Selector de sucursal (sidebar) */
.branch-switcher { margin: 0 8px 18px; }
.branch-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #9a94a8; margin-bottom: 5px; }
.branch-select { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fff; font-size: 14px; font-family: inherit; }
.branch-select option { color: #1a1a1a; }
.branch-single { font-size: 13px; color: #c9c2d6; padding: 6px 2px; }

/* Contenedor derecho (barra de sucursal + contenido) */
.main-wrap { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.main-wrap .main-area { flex: 1; }
.branch-topbar { background: #faf7ff; border-bottom: 1px solid var(--line); padding: 10px 32px; font-size: 14px; color: var(--ink); display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20; }
.branch-topbar .bt-icon { font-size: 15px; }
.branch-topbar strong { font-weight: 700; }
.branch-topbar .bt-change { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; font-size: 14px; padding: 0; text-decoration: underline; }
@media (max-width: 640px) { .branch-topbar { padding: 9px 14px; font-size: 13px; } }

/* ---------------------------------------------------------------------------
   Tooltips explicativos (pura CSS). Cualquier elemento con [data-tip] muestra
   una burbuja al pasar el cursor o al enfocar con teclado (accesible).

   Alineación horizontal (para no salirse por los bordes de la web):
     - por defecto: centrada.
     - data-tip-align="left":  la burbuja se alinea al borde IZQUIERDO del
       elemento (úsalo en el menú lateral y controles pegados a la izquierda).
     - data-tip-align="right": la burbuja se alinea al borde DERECHO del
       elemento (úsalo en botones de acción al final de las tablas).
   Posición vertical: por defecto abre hacia arriba; data-tip-pos="bottom"
   abre hacia abajo (para elementos pegados al borde superior).
   --------------------------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .1px;
  padding: 8px 11px;
  border-radius: 8px;
  width: max-content;
  max-width: min(280px, 80vw);
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease;
  z-index: 1000;
}
[data-tip]::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1f2430;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease;
  z-index: 1000;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after,
[data-tip]:hover::before, [data-tip]:focus-visible::before { opacity: 1; }

/* --- Alineación izquierda: burbuja pegada al borde izquierdo del elemento --- */
[data-tip-align="left"]::after { left: 0; transform: none; }
[data-tip-align="left"]::before { left: 16px; transform: none; }

/* --- Alineación derecha: burbuja pegada al borde derecho del elemento --- */
[data-tip-align="right"]::after { left: auto; right: 0; transform: none; }
[data-tip-align="right"]::before { left: auto; right: 16px; transform: none; }

/* --- Posición vertical hacia abajo --- */
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 9px); }
[data-tip-pos="bottom"]::before { bottom: auto; top: calc(100% + 3px); border-top-color: transparent; border-bottom-color: #1f2430; }

/* Insignia de ayuda "?" junto a títulos y etiquetas. */
.help-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--line, #e6e6ea);
  color: var(--muted, #6b7280);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  border: none;
}
.help-badge:hover { background: var(--primary, #6c2bd9); color: #fff; }

/* Barra superior fija del contenido con el botón "Actualizar".
   Va DENTRO del flujo (sticky), ocupa su propio espacio y nunca se superpone
   al contenido. Se queda pegada arriba al hacer scroll. */
/* Fila superior fija: contiene el banner de sucursal (izquierda) y el botón
   Actualizar (derecha), en una sola barra para no perder espacio vertical. */
.topbar-row {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: stretch; gap: 0;
  background: #faf7ff; border-bottom: 1px solid var(--line, #e6e6ea);
}
.topbar-row .branch-topbar { flex: 1 1 auto; border-bottom: none; position: static; }
.topbar-row .reload-fab { align-self: center; margin: 0 18px 0 10px; flex: 0 0 auto; }
/* Si el banner de sucursal está oculto, la fila igual muestra el botón a la derecha. */
.topbar-row { justify-content: space-between; }
/* En el super-admin no hay banner de sucursal: la fila solo lleva el botón. */
.topbar-row.topbar-row-plain { justify-content: flex-end; padding: 8px 18px; }
/* Botón minimalista "Actualizar": círculo con ícono SVG centrado. */
.reload-fab {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; box-sizing: border-box;
  background: #fff; color: var(--primary, #6c2bd9); border: 1px solid var(--line, #e6e6ea);
  border-radius: 50%; cursor: pointer; padding: 0; margin: 0; line-height: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  transition: box-shadow .15s ease, background .15s ease;
}
.reload-fab:hover { box-shadow: 0 3px 10px rgba(0,0,0,.16); background: #faf7ff; }
.reload-fab:active { background: #f0e9fb; }
.reload-fab:disabled { cursor: progress; }
.reload-fab .reload-ico { display: block; width: 18px; height: 18px; transform-origin: 50% 50%; }
.reload-fab .reload-ico svg { display: block; width: 18px; height: 18px; }
.reload-fab.spinning .reload-ico { animation: reloadSpin .7s linear infinite; }
@keyframes reloadSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .topbar-row .reload-fab { margin: 0 12px; }
  .topbar-row.topbar-row-plain { padding: 8px 12px; }
}

/* Banner de modo super-administrador (impersonación). */
.imper-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3000;
  background: #7a1f1f; color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.imper-banner strong { font-weight: 800; }
.imper-banner button {
  background: #fff; color: #7a1f1f; border: none; border-radius: 7px;
  padding: 4px 12px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit;
}
.imper-banner button:hover { background: #ffecec; }
/* Empuja el contenido hacia abajo para no tapar con el banner fijo. */
body.has-imper-banner .app-shell { margin-top: 38px; }

/* Resumen clave-valor (usado en fichas: suscripción, cliente, liquidación, etc.).
   Estas reglas existían solo en book.css; se agregan aquí para el panel. */
.summary { background: var(--bg-soft); border-radius: 14px; padding: 16px 18px; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 14.5px; }
.summary-row:not(:last-child) { border-bottom: 1px solid var(--line); }
.summary-row .k { color: var(--muted); flex-shrink: 0; }
.summary-row .v { font-weight: 600; text-align: right; }
.summary-total { border-top: 2px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 15.5px; }
