@view-transition {
  navigation: auto;
}

:root {
  /* La pagina esta pensada en claro. Sin esto, un navegador con el modo oscuro
     automatico la reinterpreta y apaga los colores de las doctoras. */
  color-scheme: light;
  --orange: #d9622b;
  --orange-dark: #b94f1f;
  --gray-900: #1f2430;
  --gray-700: #4a5163;
  --gray-400: #98a0b3;
  --gray-200: #e3e6ec;
  --gray-100: #f4f5f8;
  --white: #ffffff;
  --danger: #c0392b;
  --good: #3f7d5c;
  --good-wash: #e4f1ea;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
}

.topbar {
  background: var(--orange);
  border-bottom: 1px solid var(--orange-dark);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: var(--white);
  padding: 6px 14px;
  border-radius: 8px;
}
.brand img { height: 28px; width: auto; display: block; }
.brand span { color: var(--orange); font-style: italic; }

.topbar nav {
  display: flex;
  align-items: center;
}
.topbar nav a {
  margin-left: 24px;
  text-decoration: none;
  color: var(--white);
  font-weight: 600;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--gray-900); }

.user-chip {
  margin-left: 24px;
  font-size: 13px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.22);
  padding: 5px 12px;
  border-radius: 20px;
}

.auth-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  font-family: "Segoe UI", Arial, sans-serif;
}
.auth-box {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 32px;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0,0,0,0.06);
}
.auth-box h2 { text-align: center; margin-top: 4px; }
.auth-box label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 14px 0 4px;
}
.auth-box input, .auth-box select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
}
.brand.center { display: flex; justify-content: center; margin-bottom: 4px; }
.brand.center img { height: 48px; width: auto; }
.btn-primary.full { width: 100%; margin-top: 20px; padding: 11px; }

.pasos { line-height: 1.9; padding-left: 20px; }
.pasos code, .card code {
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.container:has(.wsp-layout),
.container:has(.agenda-layout),
.container:has(.layout) {
  max-width: 100%;
  padding-top: 0;
  padding-left: 8px;
  padding-right: 8px;
}
.container:has(.layout) {
  padding-top: 16px;
}
.container:has(.pagina-ancha) {
  max-width: 100%;
  padding-left: 8px;
  padding-right: 8px;
}

.footer {
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  padding: 20px;
}

.flash {
  background: #fff3cd;
  border: 1px solid #ffe08a;
  color: #7a5c00;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .layout .sidebar { order: 2; }
  .layout .content { order: 1; }
}

.layout-paciente {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout-paciente { grid-template-columns: 1fr; }
}

.historial-col .card { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.historial-lista { display: flex; flex-direction: column; gap: 10px; }
.historial-item {
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fdf6f1;
}
.historial-item.estado-disponible { border-left-color: var(--gray-400); background: var(--gray-100); }
.historial-item.estado-atendido,
.historial-item.estado-atencion_sin_cita { border-left-color: var(--good); background: var(--good-wash); }
.historial-item.estado-no_asistio,
.historial-item.estado-no_responde { border-left-color: var(--danger); background: #fceceb; }
.historial-item.estado-cancelado { border-left-color: var(--gray-400); background: var(--gray-100); opacity: 0.8; }
.historial-item.estado-reprogramado { border-left-color: var(--orange); background: #fdf1e6; }

.historial-fecha { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; }
.historial-doctor { font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.historial-detalle { font-size: 12px; color: var(--gray-700); margin-top: 2px; }
.historial-notas { font-size: 12px; color: var(--gray-400); font-style: italic; margin-top: 4px; }
.historial-item .tag { margin-top: 6px; margin-right: 4px; display: inline-block; }

.sidebar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  height: fit-content;
}
.sidebar h3 { margin-top: 0; font-size: 13px; text-transform: uppercase; color: var(--gray-400); }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list a {
  display: flex;
  justify-content: space-between;
  text-decoration: none;
  color: var(--gray-700);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 2px;
}
.cat-list a:hover { background: var(--gray-100); }
.cat-list a.active { background: var(--orange); color: var(--white); }
.badge {
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 12px;
}
.cat-list a.active .badge { background: rgba(255,255,255,0.3); color: var(--white); }

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

.search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filtro-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-700);
  white-space: nowrap;
  background: var(--gray-100);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.search input {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  min-width: 260px;
  font-size: 14px;
}
.filtro-check input { width: auto; min-width: 0; margin: 0; }
.search button {
  padding: 9px 16px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-danger { background: #fceceb; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--white); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.tabla {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.tabla th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
}
.tabla td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.tabla tbody tr[onclick] { cursor: pointer; }
.tabla tbody tr[onclick]:hover { background: var(--gray-100); }
.fila-tratamiento.seleccionada { background: #fceceb; outline: 2px solid var(--danger); }
.tabla .nombre { font-weight: 600; }
.tabla .empty { text-align: center; color: var(--gray-400); padding: 40px; }
.tabla .acciones { display: flex; gap: 8px; }

.tag {
  background: #fdece2;
  color: var(--orange-dark);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { margin-top: 0; }
.card h4 { margin-bottom: 8px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.grid-2 .span-2 { grid-column: 1 / -1; }
.grid-2 label, .card label, .modal-box label {
  display: block;
  font-size: 12px;
  color: var(--gray-700);
  margin-bottom: 4px;
  font-weight: 600;
}
.grid-2 input, .grid-2 select, .grid-2 textarea,
.modal-box input, .modal-box select, .modal-box textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.upload-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.upload-form select { padding: 9px; border-radius: 6px; border: 1px solid var(--gray-200); }

.productos-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.tratamientos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  flex-wrap: wrap;
  gap: 10px;
}

.producto-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.producto-img {
  width: 100%;
  height: 90px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.producto-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.producto-img-vacia { color: var(--gray-400); font-size: 13px; }
.producto-info { padding: 14px 16px; }
.producto-info h4 { margin: 0 0 4px; font-size: 15px; }
.producto-info p { margin: 0 0 4px; font-size: 13px; color: var(--gray-700); }
.producto-precio { font-weight: 700; color: var(--orange-dark); font-size: 14px !important; }
.producto-editar-btn { margin-top: 8px; }

.producto-item.seleccionada { outline: 2px solid var(--danger); }
#productos-grid.modo-eliminar .producto-item { cursor: pointer; }
#productos-grid.modo-eliminar .producto-item:hover { outline: 2px solid var(--gray-400); }
#productos-grid.modo-eliminar .producto-editar-btn { display: none; }

.producto-add {
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
  background: var(--gray-100);
  border: 2px dashed var(--gray-200);
  color: var(--gray-700);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.producto-add:hover { border-color: var(--orange); color: var(--orange); }
.producto-add-icono { font-size: 30px; line-height: 1; color: var(--orange); }

.presupuesto-item-row {
  display: grid;
  grid-template-columns: 1fr 70px 110px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.presupuesto-item-row input {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
}

.back-link { text-decoration: none; color: var(--gray-700); font-size: 14px; }

.ficha-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: 10px 0 20px;
}
.ficha-meta { color: var(--gray-400); font-size: 13px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}
.grid-cards .card { display: flex; flex-direction: column; }
.grid-cards .card h3 {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 0 0 6px;
}
.plantilla-botones { display: flex; flex-direction: column; gap: 8px; }
.btn-plantilla {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 12px 16px;
}
.plantilla-idioma {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 -2px;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.plantilla-idioma::before,
.plantilla-idioma::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.plantilla-botones > .plantilla-idioma:first-child { margin-top: 0; }

.plantillas-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

.plantillas-grid.modo-eliminar .plantilla-item,
#plantillas-grid.modo-eliminar .plantilla-item {
  cursor: pointer;
  background: var(--white);
  color: var(--gray-900);
  border: 2px solid var(--gray-200);
}
#plantillas-grid.modo-eliminar .plantilla-item:hover { border-color: var(--danger); }
#plantillas-grid.modo-eliminar .plantilla-item.seleccionada {
  background: #fceceb;
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  width: 420px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-box h3 { margin-top: 0; }
.modal-box label { margin-top: 10px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Agenda ---------- */
.agenda-fecha-titulo { color: var(--orange); font-weight: 700; font-size: 16px; margin-top: 2px; }
.agenda-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agenda-fecha-form input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
}

.agenda-tabla-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
}

/* Barras de scroll finas y discretas dentro de los paneles a pantalla completa */
.agenda-principal .agenda-tabla-wrap,
.agenda-sidebar,
.wsp-mensajes,
.wsp-lista-items {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}
.agenda-principal .agenda-tabla-wrap::-webkit-scrollbar,
.agenda-sidebar::-webkit-scrollbar,
.wsp-mensajes::-webkit-scrollbar,
.wsp-lista-items::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.agenda-principal .agenda-tabla-wrap::-webkit-scrollbar-thumb,
.agenda-sidebar::-webkit-scrollbar-thumb,
.wsp-mensajes::-webkit-scrollbar-thumb,
.wsp-lista-items::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: 8px;
}
.agenda-principal .agenda-tabla-wrap::-webkit-scrollbar-track,
.agenda-sidebar::-webkit-scrollbar-track,
.wsp-mensajes::-webkit-scrollbar-track,
.wsp-lista-items::-webkit-scrollbar-track {
  background: transparent;
}

.agenda-tabla-horario {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  table-layout: fixed;
}
.agenda-tabla-horario th {
  position: sticky;
  top: 0;
  background: var(--gray-100);
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  z-index: 1;
}
.agenda-tabla-horario th[style*="background"] { filter: saturate(1.5) brightness(0.95); }
.agenda-tabla-horario .col-hora {
  width: 64px;
  font-size: 11px;
  color: var(--gray-400);
  text-align: right;
  padding-right: 8px;
  vertical-align: top;
  white-space: nowrap;
  border-right: 1px solid var(--gray-200);
  /* La columna de horas esta en TODAS las filas, asi que aqui se fija el alto
     minimo de cada media hora. Sin esto, una fila que quede totalmente cubierta
     por una cita larga se encoge y el bloque se ve mas corto de lo que dura. */
  height: 26px;
}
.agenda-tabla-horario tr.franja-en-punto .col-hora { padding-top: 2px; }
.agenda-tabla-horario td { border-bottom: 1px solid var(--gray-100); }
.agenda-tabla-horario tr.franja-en-punto td { border-bottom: 1px solid var(--gray-200); }
.agenda-tabla-horario tr td.col-hora { border-bottom: none; }

.celda-libre {
  height: 26px;
  cursor: pointer;
}
.celda-libre:hover { background: var(--gray-100); }

/* Un solo dia con una sola doctora: las citas se estiran a lo ancho y quedan
   muy bajitas, asi que cada media hora y el texto crecen un poco. */
.agenda-una-columna .col-hora { height: 38px; font-size: 12px; }
.agenda-una-columna .celda-libre { height: 38px; }
.agenda-una-columna .cita-hora { font-size: 12px; }
.agenda-una-columna .cita-paciente { font-size: 15px; }
.agenda-una-columna .cita-detalle { font-size: 13px; }
.agenda-una-columna .cita-disponible { font-size: 14px; }
.agenda-una-columna .celda-cita { padding: 8px 10px; }

/* Celda que agrupa las citas de un tramo. Si dos se pisan, la rejilla de adentro
   las reparte en carriles, una al lado de la otra. */
.celda-grupo {
  vertical-align: top;
  padding: 3px 5px;
  /* Altura minima de 1px: le da al navegador una referencia concreta para que la
     rejilla de adentro se estire aunque la celda abarque varias horas (rowspan). */
  height: 1px;
}
.grupo-citas {
  display: grid;
  gap: 3px;
  height: 100%;
}

.celda-cita {
  padding: 6px 8px;
  border-left: 6px solid var(--orange);
  background: #fdf6f1;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  box-sizing: border-box;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}
.celda-cita:hover { filter: brightness(0.98); }
.celda-cita.estado-disponible { border-left-color: var(--gray-400); background: var(--gray-100) !important; }

/* Modo "Disponible": los espacios libres invitan a tocarlos y los bloques
   disponibles muestran manijas arriba y abajo para estirarlos. */
.modo-disponible .celda-libre { background: #f9fbff; }
.modo-disponible .celda-libre:hover { background: #e8eefc; }
.modo-disponible .celda-cita[data-estado="disponible"] {
  position: relative;
  outline: 2px dashed var(--gray-400);
  outline-offset: -2px;
}
.manija-cita {
  position: absolute;
  left: 5px;
  right: 5px;
  height: 10px;
  cursor: ns-resize;
  z-index: 3;
}
.manija-cita::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 3px;
  border-radius: 3px;
  background: var(--gray-400);
}
.manija-arriba { top: 0; }
.manija-abajo { bottom: 0; }
.celda-cita.estado-atendido { border-left-color: var(--good); background: var(--good-wash); }
.celda-cita.estado-atencion_sin_cita { border-left-color: var(--good); background: var(--good-wash); }
.celda-cita.estado-no_asistio { border-left-color: var(--danger); background: #fceceb; opacity: 0.85; }
.celda-cita.estado-cancelado { border-left-color: var(--gray-400); background: var(--gray-100); opacity: 0.7; }
.celda-cita.estado-reprogramado { border-left-color: var(--orange); background: #fdf1e6; opacity: 0.85; }
.celda-cita.estado-no_responde { border-left-color: var(--danger); background: #fceceb; opacity: 0.85; }

/* Citas guardadas como "Solo para la agenda" (sin ficha en Pacientes):
   se distinguen con unas rayas amarillas en el borde derecho. */
.celda-cita.solo-agenda {
  position: relative;
  padding-right: 22px;
}
.celda-cita.solo-agenda::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 14px;
  border-radius: 0 8px 8px 0;
  background: repeating-linear-gradient(
    45deg,
    #e6b800 0 4px,
    rgba(255, 255, 255, 0.75) 4px 8px
  );
  pointer-events: none;
}

.agenda-layout {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.agenda-sidebar {
  width: 250px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px 12px 12px;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
}
.mini-calendario-mes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  color: var(--gray-900);
  margin-bottom: 8px;
  text-transform: capitalize;
}
.agenda-flecha-chica {
  width: 24px;
  height: 24px;
  font-size: 16px;
}
.agenda-principal {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  overflow: hidden;
}
.agenda-principal .agenda-toolbar,
.agenda-principal .agenda-hint {
  padding-left: 16px;
  padding-right: 16px;
}
.agenda-principal .agenda-tabla-wrap {
  flex: 1;
  overflow-y: auto;
  margin: 0;
}
.agenda-toggle-sidebar { display: none; }

.agenda-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.agenda-toolbar-izq {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
}
.agenda-toolbar-der { grid-column: 3; justify-self: end; }
.agenda-toolbar-der { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.agenda-flecha {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fdece2;
  color: var(--orange-dark);
  text-decoration: none;
  font-size: 20px;
  flex-shrink: 0;
}
.agenda-flecha:hover { background: var(--gray-200); }
.agenda-toolbar-fecha { text-align: center; }
.agenda-toolbar-fecha .agenda-fecha-titulo { margin: 0; font-size: 24px; }
.agenda-toolbar-fecha .agenda-fecha-form input[type="date"] {
  border: none;
  background: transparent;
  color: var(--gray-400);
  font-size: 12px;
  padding: 0;
}
.agenda-fecha-form-icono {
  width: 30px;
  height: 30px;
  overflow: hidden;
}
.agenda-fecha-form-icono input[type="date"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: transparent;
}
.agenda-toolbar-hoy { grid-column: 1; justify-self: start; }
.agenda-toolbar-hoy-grupo { display: flex; align-items: center; gap: 10px; }

.agenda-toolbar-efectivo { padding: 10px 0; }
.agenda-flecha-grande { width: 52px; height: 52px; font-size: 26px; }
.agenda-fecha-titulo-grande { font-size: 30px; }
.agenda-btn-hoy-grande {
  border: none;
  border-radius: 8px;
  padding: 14px 26px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.efectivo-layout {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.efectivo-principal { flex: 1; min-width: 0; padding: 20px; }
.efectivo-calendario {
  width: 320px;
  flex-shrink: 0;
  border: none;
  border-left: 1px solid var(--gray-200);
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}
@media (max-width: 900px) {
  .efectivo-layout { flex-direction: column; }
  .efectivo-calendario {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    border-left: none;
    border-top: 1px solid var(--gray-200);
  }
  .efectivo-calendario .mini-calendario-tabla,
  .efectivo-calendario .mini-calendario-mes { margin-left: auto; margin-right: auto; }
}

.agenda-btn-hoy {
  border: none;
  border-radius: 6px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.mini-calendario-tabla { border-collapse: collapse; }
.mini-calendario-tabla th { font-size: 10px; color: var(--gray-400); padding: 3px 5px; font-weight: 600; }
.mini-calendario-tabla td { text-align: center; padding: 1px; }
.mini-calendario-tabla td a {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  width: 28px; height: 30px; border-radius: 6px; text-decoration: none; color: var(--gray-700);
  padding-top: 2px;
}
.mini-calendario-tabla td a:hover { background: var(--gray-100); }
.mini-dia-fuera a { color: var(--gray-400); opacity: 0.5; }
.mini-dia-hoy a { font-weight: 700; color: var(--orange); background: #fdece2; }
.mini-dia-sel a { background: var(--orange); color: var(--white) !important; }
/* El hover generico pisaba el naranja del dia de hoy y del seleccionado: aqui se
   les devuelve su color, con un tono un poco mas oscuro como respuesta al mouse. */
.mini-calendario-tabla td.mini-dia-hoy a:hover { background: #fbdcc9; }
.mini-calendario-tabla td.mini-dia-sel a:hover { background: var(--orange-dark); }
.mini-dia-num { font-size: 11px; }
.mini-dia-puntos { display: flex; gap: 2px; }
.mini-dia-punto { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.mini-dia-punto.ausente { background: var(--gray-400) !important; opacity: 0.4; }
.mini-calendario-checks { min-width: 200px; }

.cita-hora { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; }
.cita-paciente { font-size: 13.5px; font-weight: 600; margin-top: 2px; }
.cita-detalle { font-size: 12px; color: var(--gray-700); margin-top: 2px; }
.cita-disponible { font-size: 13px; color: var(--gray-400); font-style: italic; margin-top: 2px; }

.celda-cita.celda-almuerzo {
  border-left-color: #e6b800;
  background: #fff9db;
  text-align: center;
}
.cita-almuerzo {
  font-size: 14px;
  font-weight: 700;
  color: #8a6d00;
  text-align: center;
  padding: 6px 0;
}

.tag-nuevo { background: var(--orange); color: var(--white); margin-left: 4px; }
.tag-pendiente { background: var(--gray-200); color: var(--gray-700); margin-left: 4px; }
.tag-confirmado { background: #fff3cd; color: #8a6d00; margin-left: 4px; }
.tag-ok { background: var(--good-wash); color: var(--good); margin-top: 4px; display: inline-block; }
.tag-bad { background: #fceceb; color: var(--danger); margin-top: 4px; display: inline-block; }
.tag-estado-atendido { background: var(--good-wash); color: var(--good); margin-top: 4px; display: inline-block; }
.tag-estado-atencion_sin_cita { background: var(--good-wash); color: var(--good); margin-top: 4px; display: inline-block; }
.tag-estado-no_asistio { background: #fceceb; color: var(--danger); margin-top: 4px; display: inline-block; }
.tag-estado-cancelado { background: var(--gray-200); color: var(--gray-700); margin-top: 4px; display: inline-block; }
.tag-estado-reprogramado { background: #fdf1e6; color: var(--orange-dark); margin-top: 4px; display: inline-block; }
.tag-estado-no_responde { background: #fceceb; color: var(--danger); margin-top: 4px; display: inline-block; }

.reporte-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.reporte-tile {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.reporte-tile-label { font-size: 12px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.04em; }
.reporte-tile-valor { font-size: 26px; font-weight: 700; margin-top: 6px; }
.reporte-tile.destacado { background: var(--orange); border-color: var(--orange); }
.reporte-tile.destacado .reporte-tile-label { color: rgba(255,255,255,0.85); }
.reporte-tile.destacado .reporte-tile-valor { color: var(--white); }
.reporte-tile.alerta .reporte-tile-valor { color: var(--danger); }

.fila-efectivo-ok { background: var(--good-wash); }

/* Barras horizontales (reportes) */
.barra-fila { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.barra-label { width: 130px; font-size: 13px; color: var(--gray-700); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-track { flex: 1; height: 14px; background: var(--gray-100); border-radius: 7px; overflow: hidden; }
.barra-fill { height: 100%; background: var(--orange); border-radius: 7px; }
.barra-valor { width: 90px; text-align: right; font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* Histórico mensual (barras verticales) */
.historico-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.historico-barra { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.historico-barra-valor { font-size: 10px; color: var(--gray-400); margin-bottom: 4px; white-space: nowrap; }
.historico-barra-rect { width: 100%; background: var(--orange); border-radius: 4px 4px 0 0; min-height: 2px; }
.historico-barra-mes { font-size: 11px; color: var(--gray-700); margin-top: 6px; }

/* Metas mensuales (anillos) */
.metas-wrap { display: flex; gap: 32px; flex-wrap: wrap; align-items: center; }
.meta-ring {
  width: 110px; height: 110px; border-radius: 50%;
  background: conic-gradient(var(--orange) calc(var(--pct, 0) * 1%), var(--gray-200) 0);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.meta-ring::before {
  content: ""; position: absolute; width: 80px; height: 80px; border-radius: 50%; background: var(--white);
}
.meta-ring-valor { position: relative; font-size: 20px; font-weight: 700; }
.meta-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.meta-box-label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.meta-box-detalle { font-size: 12px; color: var(--gray-400); }

.reporte-tablas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.reporte-tablas table.tabla { table-layout: fixed; }
.reporte-tablas table.tabla th:first-child,
.reporte-tablas table.tabla td:first-child { width: 50%; }
.reporte-tablas table.tabla th:not(:first-child),
.reporte-tablas table.tabla td:not(:first-child) { width: 25%; }

.sugerencias {
  position: relative;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-top: -1px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--white);
}
.sugerencias:empty { border: none; }
.sugerencia { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.sugerencia:hover { background: var(--gray-100); }

.productos-cita-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.producto-cita-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-100);
  border-radius: 6px;
  padding: 6px 8px;
}
.producto-cita-nombre { flex: 1; font-size: 13px; }
.producto-cita-cant {
  width: 50px; padding: 5px 6px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 12px;
}
.producto-cita-precio {
  width: 80px; padding: 5px 6px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 12px;
}

.cita-productos { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.cita-productos .tag { background: var(--gray-200); color: var(--gray-700); font-size: 11px; padding: 2px 8px; }

/* ---------- Celular ---------- */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: center;
    padding: 12px 16px;
  }
  .topbar nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin-top: 10px;
  }
  .topbar nav a { margin-left: 0; }
  .user-chip { margin-left: 0; }

  .container { padding: 16px 14px 40px; }

  .ficha-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .agenda-nav { justify-content: center; }

  .toolbar { justify-content: center; text-align: center; }
  .search { justify-content: center; }

  .grid-2 { grid-template-columns: 1fr; gap: 8px; }

  .reporte-tile { text-align: center; }

  .modal-box { padding: 16px; width: 94vw; }
  .modal-box h3 { font-size: 16px; margin-bottom: 2px; }
  .grid-2 label, .card label, .modal-box label { font-size: 11px; margin-top: 8px; margin-bottom: 3px; }
  .grid-2 input, .grid-2 select, .grid-2 textarea,
  .modal-box input, .modal-box select, .modal-box textarea { padding: 7px 8px; font-size: 13px; }
  .modal-actions { margin-top: 12px; gap: 8px; }
  .modal-actions .btn-primary, .modal-actions .btn-secondary, .modal-actions .btn-danger { padding: 8px 14px; font-size: 13px; }

  .card:has(> table.tabla) { padding: 0; overflow-x: auto; }
  .card:has(> table.tabla) > table.tabla { min-width: 560px; border: none; }

  .sidebar { padding: 10px; }
  .sidebar h3 { font-size: 11px; }
  .cat-list a { padding: 6px 8px; font-size: 12.5px; }
  .badge { font-size: 10px; padding: 1px 6px; }

  .search input { min-width: 0; width: 100%; font-size: 13px; padding: 7px 10px; }
  .search select, .filtro-check, .search button { font-size: 12.5px; padding: 7px 10px; }

  .tabla-wrap { overflow-x: hidden; }
  .tabla-wrap table.tabla { width: 100%; min-width: 0; table-layout: fixed; }
  .tabla-wrap .tabla th { padding: 5px 3px; font-size: 8px; white-space: normal; overflow-wrap: break-word; }
  .tabla-wrap .tabla td { padding: 5px 3px; font-size: 10px; overflow-wrap: break-word; }
  .tabla-wrap .tabla .tag { font-size: 9px; padding: 1px 5px; }
}

/* ---------- Bandeja de WhatsApp (estilo WhatsApp Web) ---------- */
:root {
  --wsp-verde-osc: #075e54;
  --wsp-verde: #128c7e;
  --wsp-verde-claro: #25d366;
  --wsp-fondo-chat: #e9edef;
  --wsp-burbuja-in: #ffffff;
  --wsp-burbuja-out: #d9fdd3;
}

.wsp-layout {
  display: flex;
  width: 100%;
  height: calc(100vh - 160px);
  height: calc(100dvh - 160px);
  min-height: 620px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.wsp-lista {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
}
.wsp-lista-header {
  background: var(--wsp-verde-osc);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  padding: 16px 18px;
}
.wsp-lista-items { flex: 1; overflow-y: auto; }

.wsp-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--gray-100);
}
.wsp-item:hover { background: var(--gray-100); }
.wsp-item.activo { background: #e9edef; }

.wsp-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--wsp-verde);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.wsp-item-info { flex: 1; min-width: 0; }
.wsp-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wsp-item-nombre { font-weight: 600; font-size: 14px; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsp-item-hora { font-size: 11px; color: var(--gray-400); flex-shrink: 0; }
.wsp-item-preview {
  font-size: 13px;
  color: var(--gray-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wsp-tag-humano {
  background: var(--orange);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.wsp-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--wsp-fondo-chat);
}

.wsp-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.wsp-volver { display: none; text-decoration: none; color: var(--gray-700); font-size: 20px; }
.wsp-chat-quien { flex: 1; min-width: 0; }
.wsp-chat-nombre { font-weight: 700; font-size: 15px; }
.wsp-chat-telefono { font-size: 12px; color: var(--gray-400); }
.wsp-modo-form { flex-shrink: 0; }
.wsp-modo-btn {
  border: 1px solid var(--gray-200);
  background: var(--white);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-700);
  white-space: nowrap;
}
.wsp-modo-btn:hover { background: var(--gray-100); }
.wsp-modo-btn.wsp-modo-humano { background: #fdece2; color: var(--orange-dark); border-color: #fdece2; }

.wsp-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 18px 5%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wsp-burbuja {
  max-width: 65%;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}
.wsp-burbuja.entrante {
  align-self: flex-start;
  background: var(--wsp-burbuja-in);
  border-top-left-radius: 0;
}
.wsp-burbuja.saliente {
  align-self: flex-end;
  background: var(--wsp-burbuja-out);
  border-top-right-radius: 0;
}
.wsp-burbuja-texto { white-space: pre-wrap; word-break: break-word; color: var(--gray-900); }
.wsp-burbuja-meta {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 3px;
  text-align: right;
}

.wsp-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}
.wsp-input-bar input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 14px;
}
.wsp-input-bar input:focus { outline: 2px solid var(--wsp-verde); }
.wsp-enviar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--wsp-verde-claro);
  color: var(--white);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.wsp-enviar-btn:hover { background: var(--wsp-verde); }

.wsp-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.wsp-vacio-icono { font-size: 48px; }

@media (max-width: 860px) {
  .container:has(.wsp-layout) { padding-left: 0; padding-right: 0; max-width: 100%; }
  .wsp-layout {
    width: 100%;
    margin-left: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    height: calc(100vh - 230px);
    height: calc(100dvh - 230px);
    min-height: 380px;
  }
  .wsp-lista { width: 100%; }
  .wsp-layout.wsp-layout-chat-activo .wsp-lista { display: none; }
  .wsp-layout:not(.wsp-layout-chat-activo) .wsp-chat { display: none; }
  .wsp-volver { display: inline-flex; }
  .wsp-item { padding: 14px 16px; }

  .wsp-chat-header { padding: 8px 10px; gap: 6px 8px; flex-wrap: wrap; }
  .wsp-chat-header .wsp-avatar { width: 32px; height: 32px; font-size: 13px; }
  .wsp-chat-nombre { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wsp-chat-telefono { font-size: 10px; }
  .wsp-modo-form { flex: 1 0 100%; order: 3; }
  .wsp-modo-btn { width: 100%; padding: 6px 8px; font-size: 11px; border-radius: 14px; white-space: normal; }
}

@media (max-width: 860px) {
  .container:has(.agenda-layout) { padding-left: 0; padding-right: 0; max-width: 100%; }
  .agenda-layout {
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .agenda-sidebar {
    display: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }
  .agenda-sidebar.open { display: block; }
  .agenda-principal { padding: 12px; }
  .agenda-toggle-sidebar { display: inline-flex; }
}
