/*
 * Ultra Asistente · hoja de estilos de los paneles y del widget.
 * El orden de las reglas es parte del diseño (las últimas anulan a las primeras):
 * no reordenar. Variable de marca: --brand (color principal de cada negocio).
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px system-ui;
  background: #f3f5f8;
  color: #29394b;
}

aside {
  position: fixed;
  width: 240px;
  height: 100dvh;
  background: white;
  border-right: 1px solid #dee5ed;
  padding: 25px;
  overflow: auto;
}

aside img {
  width: 180px;
  margin-bottom: 22px;
}

nav {
  margin-top: 20px;
}

nav button {
  display: block;
  text-align: left;
  width: 100%;
  padding: 12px;
  border: 0;
  background: none;
  color: #697b90;
  border-radius: 9px;
  cursor: pointer;
  margin: 3px 0;
}

nav button.active {
  background: #526b86;
  color: white;
}

main {
  margin-left: 240px;
  padding: 25px 35px;
  min-width: 0;
}

header,.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

header {
  padding-bottom: 22px;
}

small,.muted {
  color: #8190a2;
}

h1 {
  font-size: 30px;
  letter-spacing: -1px;
  margin: 22px 0 8px;
}

h2 {
  font-size: 20px;
}

p {
  line-height: 1.7;
}

button,input,select,textarea {
  font: inherit;
  min-height: 43px;
}

input,select,textarea {
  padding: 11px;
  border: 1px solid #d5dfea;
  background: white;
  border-radius: 8px;
  color: #34485e;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  background: #e8edf4;
  color: #48627e;
}

button.primary {
  background: #526b86;
  color: white;
}

button.danger {
  background: #fff0ef;
  color: #b42318;
}

button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.card {
  padding: 23px;
  border: 1px solid #dee5ed;
  background: white;
  border-radius: 13px;
  margin-top: 20px;
  min-width: 0;
}

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

.grid .card {
  margin-top: 16px;
}

.number {
  font-size: 30px;
  margin: 12px 0;
}

.notice {
  padding: 12px 16px;
  border-radius: 9px;
  border: 1px solid #cfddf9;
  font-size: 12px;
}

.info {
  background: #eff6ff;
  color: #2454a4;
}

.success {
  background: #ecfdf3;
  color: #166534;
}

.warning {
  background: #fff8db;
  color: #854d0e;
}

.error {
  background: #fff1f0;
  color: #b42318;
}

.pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 18px;
  font-size: 11px;
  white-space: nowrap;
}

.scroll {
  overflow: auto;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 620px;
  text-align: left;
}

td,th {
  padding: 15px 10px;
  border-bottom: 1px solid #edf1f5;
}

th {
  font-size: 11px;
  color: #8190a2;
  text-transform: uppercase;
}

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

.search {
  width: min(100%,300px);
}

label {
  display: block;
  margin: 15px 0 6px;
}

label input:not([type=checkbox]),label select,label textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
}

dialog {
  border: 0;
  border-radius: 16px;
  padding: 27px;
  width: 520px;
  max-width: calc(100% - 24px);
  max-height: 90dvh;
  overflow: auto;
}

dialog::backdrop {
  background: #263b5066;
}

#feedback:not(:empty) {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: calc(100% - 40px);
  padding: 14px 20px;
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #bce6ca;
  border-radius: 9px;
  z-index: 9;
}

.empty {
  padding: 30px;
  text-align: center;
  color: #8190a2;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.role-link {
  display: inline-block;
  color: #526b86;
  text-decoration: none;
  padding: 8px;
}

#selectors {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

textarea {
  min-height: 100px;
}

.permission {
  border-top: 1px solid #e5eaf0;
  padding: 14px 0;
}

.permission b {
  display: block;
  margin-bottom: 6px;
}

@media(max-width:850px) {
  aside {
    position: static;
    width: 100%;
    height: auto;
    padding: 15px;
  }
  aside img {
    width: 145px;
    margin: 0;
  }
  #context {
    margin: 10px 0;
  }
  nav {
    display: flex;
    overflow: auto;
    margin-top: 10px;
    gap: 5px;
  }
  nav button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }
  main {
    margin: 0;
    padding: 18px;
  }
  .grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
  input,select,textarea {
    font-size: 16px;
  }
  .card {
    padding: 16px;
  }
  h1 {
    font-size: 26px;
  }
  header {
    align-items: flex-start;
  }
  #selectors {
    width: 100%;
  }
  #selectors select {
    width: 100%;
  }
}

nav button.active,button.primary {
  background: var(--brand,#526b86);
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.plan-card {
  padding: 30px;
}

.plan-card h2 {
  font-size: 36px;
  margin-bottom: 12px;
}

.plan-price {
  font-size: 28px;
  font-weight: 750;
  margin-top: 25px;
  border-top: 1px solid #d8dfeb;
  padding-top: 22px;
}

.plan-price small {
  font-size: 13px;
  font-weight: 400;
}

.plan-card ul {
  padding: 0;
  list-style: none;
}

.plan-card li {
  padding: 10px 0;
  line-height: 1.6;
}

.max-plan {
  background: linear-gradient(130deg,#191c23,#333a4a);
  color: white;
  border-color: #7d8ba8;
}

.max-plan p,.max-plan small {
  color: #cbd2e2;
}

@media(max-width:650px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
  .plan-card {
    padding: 22px;
  }
}

.inline-editor {
  margin-top: 22px;
  background: white;
  border: 1px solid #dee5ed;
  border-radius: 14px;
  padding: 28px;
  max-width: 950px;
}

.inline-editor[hidden] {
  display: none!important;
}

.inline-editor input:not([type=checkbox]):not([type=color]),.inline-editor select,.inline-editor textarea {
  width: 100%;
}

.inline-editor h3 {
  margin-top: 30px;
  border-top: 1px solid #e2e7ee;
  padding-top: 22px;
}

.inline-editor label {
  max-width: 720px;
}

.inline-editor button {
  margin-right: 8px;
}

.inline-editor form>.actions {
  position: sticky;
  bottom: 0;
  background: white;
  padding: 16px 0;
  border-top: 1px solid #e2e7ee;
}

.inline-editor:focus {
  outline: none;
}

@media(max-width:650px) {
  .inline-editor {
    padding: 18px;
  }
  .inline-editor form>.actions {
    bottom: 0;
  }
}

.panel-back-top {
  margin-bottom: 22px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e2e7ee;
}

.panel-back-top button {
  font-weight: 600;
}

.inline-editor [hidden] {
  display: none!important;
}

/* Distribución del área de trabajo por tamaño de pantalla. */
main {
  width: calc(100% - 240px);
  max-width: none;
}

.inline-editor {
  width: 100%;
  max-width: none;
}

.company-section {
  padding: 0 0 22px;
}

.company-fields {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px 24px;
  align-items: start;
}

.company-fields>label {
  width: 100%;
  max-width: none;
  margin: 12px 0;
}

.company-fields>.notice {
  grid-column: 1/-1;
}

.company-fields textarea {
  min-height: 110px;
}

.company-fields>img {
  align-self: center;
}

.company-section h3 {
  margin-top: 14px;
}

.company-section #brandPreview {
  max-width: 760px;
}

.inline-editor form>.actions {
  width: 100%;
}

.panel-back-top {
  display: flex;
  justify-content: flex-start;
}

#widgetPreviewFrame {
  max-width: 100%;
}

.scroll {
  width: 100%;
}

header small {
  display: block;
  margin-bottom: 6px;
}

@media(min-width:1600px) {
  .company-fields {
    grid-template-columns: repeat(4,minmax(0,1fr));
  }
}

@media(min-width:851px) and (max-width:1150px) {
  aside {
    width: 210px;
    padding: 18px;
  }
  main {
    margin-left: 210px;
    width: calc(100% - 210px);
    padding: 22px;
  }
  .company-fields {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}

@media(max-width:850px) {
  main {
    width: 100%;
    margin-left: 0;
  }
  .company-fields {
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 6px 18px;
  }
  .inline-editor {
    width: 100%;
    max-width: none;
  }
  .inline-editor form>.actions {
    flex-wrap: wrap;
  }
  .notice {
    overflow-wrap: anywhere;
  }
  .actions button {
    min-height: 44px;
  }
  .panel-back-top {
    margin-bottom: 16px;
  }
}

@media(max-width:580px) {
  .company-fields {
    grid-template-columns: minmax(0,1fr);
    gap: 0;
  }
  .inline-editor {
    padding: 16px;
  }
  main {
    padding: 14px;
  }
  .company-section {
    padding-bottom: 12px;
  }
  .inline-editor form>.actions>button {
    flex: 1 1 100%;
  }
  .row {
    align-items: flex-start;
  }
  h1 {
    overflow-wrap: anywhere;
  }
  .card {
    padding: 15px;
  }
  table {
    min-width: 560px;
  }
}

.company-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid #dce3ed;
  padding: 12px 0 18px;
  margin-bottom: 20px;
}

.company-tabs button {
  flex: 1 1 200px;
  text-align: center;
  min-height: 48px;
  background: #eef2f7;
  color: #53677f;
  font-weight: 600;
}

.company-tabs button.selected {
  background: #526b86;
  color: #fff;
}

.company-section[hidden] {
  display: none!important;
}

.company-section {
  animation: section-appear .18s ease;
}

@keyframes section-appear {
  from {
    opacity: .4;
  }
  to {
    opacity: 1;
  }
}

@media(max-width:600px) {
  .company-tabs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .company-tabs button {
    text-align: left;
    width: 100%;
  }
}

@media(prefers-reduced-motion:reduce) {
  .company-section {
    animation: none;
  }
}

body[data-role="owner"] {
  background: var(--owner-background,#f3f5f8);
  color: var(--owner-text,#29394b);
}

body[data-role="owner"] aside {
  background: var(--owner-sidebar,#fff);
}

body[data-role="owner"] nav button:not(.active) {
  color: var(--owner-text,#697b90);
}

.orange {
  background: #fff0df;
  color: #9a3e08;
  border: 1px solid #fdba74;
}

.color-hex-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.color-hex-row input[type="color"] {
  width: 56px!important;
  min-width: 56px;
  height: 44px;
  padding: 4px;
  margin: 0;
}

.color-hex-row input.hex-value {
  flex: 1;
  min-width: 0;
  margin: 0!important;
  font-family: ui-monospace,monospace;
  text-transform: uppercase;
  width: 140px;
  max-width: 220px;
}

.payment-summary {
  background: #f1f5fb;
  border: 1px solid #d3deeb;
  border-radius: 13px;
  padding: 24px;
  margin: 24px 0;
}

.payment-summary h3 {
  margin-top: 0!important;
  border: 0!important;
  padding-top: 0!important;
}

.payment-summary>.row {
  padding: 10px 0;
  gap: 10px;
}

.payment-total {
  border-top: 1px solid #cbd8e9;
  margin-top: 16px;
  padding-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.payment-total strong {
  font-size: 30px;
  color: #294563;
}

.payment-summary p {
  margin-bottom: 0;
}

@media(max-width:580px) {
  .payment-summary {
    padding: 17px;
  }
  .payment-total {
    display: block;
  }
  .payment-total strong {
    display: block;
    font-size: 26px;
    margin-top: 10px;
  }
}

.business-panel-link {
  display: inline-flex;
  align-items: center;
  min-height: 43px;
  border: 1px solid #d5dfea;
  border-radius: 8px;
  padding: 10px 14px;
  background: #eff4fa;
  font-weight: 600;
  white-space: nowrap;
}

.record-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
  align-items: center;
}

.record-actions button,.record-actions a {
  flex-shrink: 0;
}

.scroll table td {
  vertical-align: middle;
}

.contract-business-name {
  font-size: 32px;
  letter-spacing: -.7px;
  margin: 8px 0 22px;
  overflow-wrap: anywhere;
}

.contract-row {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid #e5eaf1;
}

.contract-field>span {
  display: block;
  font-size: 12px;
  color: #7b899c;
  margin-bottom: 9px;
}

.contract-field>div {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.contract-dates {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 24px;
  padding: 24px 0;
}

.contract-charges {
  background: #f3f6fb;
  border: 1px solid #dee6f1;
  border-radius: 12px;
  padding: 22px;
  margin-top: 8px;
}

.contract-charges h3 {
  margin-top: 0!important;
  padding-top: 0!important;
  border: 0!important;
}

.charge-line,.charge-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.charge-total {
  border-top: 1px solid #cdd8e6;
  margin-top: 10px;
  padding-top: 20px;
  font-weight: 600;
}

.charge-total strong {
  font-size: 29px;
  color: #2d4764;
}

@media(max-width:650px) {
  .contract-row {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .contract-dates {
    grid-template-columns: 1fr;
  }
  .contract-business-name {
    font-size: 27px;
  }
  .contract-charges {
    padding: 17px;
  }
  .charge-total {
    display: block;
  }
  .charge-total strong {
    display: block;
    margin-top: 10px;
    font-size: 25px;
  }
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.professional-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.professional-avatar {
  width: 48px!important;
  height: 48px!important;
  min-width: 48px;
  max-width: 48px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  display: inline-block;
  flex-shrink: 0;
  background: #e6edf5;
}

.avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #526b86;
  font-size: 20px;
}

#professionalPhotoPreview {
  width: 72px!important;
  height: 72px!important;
  min-width: 72px;
  max-width: 72px;
}

#professionalPhotoPreview[hidden] {
  display: none!important;
}

.personal-avatar-button {
  padding: 0;
  background: transparent;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.personal-avatar-button:hover {
  outline: 2px solid #8497b0;
  outline-offset: 3px;
}

#ownPhotoPreview {
  margin: 24px 0;
}

#ownPhotoPreview .professional-avatar {
  width: 80px!important;
  height: 80px!important;
  min-width: 80px;
  max-width: 80px;
}

/* Logos circulares de negocios, independientes de la foto personal. */
body:not([data-role="owner"]) aside img {
  width: 100px!important;
  height: 100px!important;
  max-width: 100px!important;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

#companyLogoPreview,#logoPreview {
  width: 100px!important;
  height: 100px!important;
  max-width: 100px!important;
  max-height: 100px!important;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
}

.image-cropper {
  width: 100%;
  grid-column: 1/-1;
}

.crop-stage {
  position: relative;
  width: min(100%,360px);
  aspect-ratio: 1;
  margin: 20px auto;
  overflow: hidden;
  border-radius: 12px;
  background: repeating-conic-gradient(#e2e6ed 0% 25%,#fff 0% 50%) 50% / 18px 18px;
}

.crop-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

.crop-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle closest-side,transparent 99%,#17243499 100%);
}

.crop-position {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.image-cropper input[type="range"] {
  width: 100%;
  padding: 0;
}

.image-cropper>.actions {
  position: static!important;
  display: flex;
  flex-wrap: wrap;
}

.image-cropper canvas:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: -3px;
}

@media(max-width:580px) {
  .crop-position {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* Agenda con vistas, bloqueos y selector de servicios (se añade al final: no altera reglas anteriores). */
.agenda-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
}

.agenda-tabs button.selected {
  background: var(--brand, #526b86);
  color: #fff;
}

.agenda-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 8px;
}

.cal-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(96px, 1fr));
  gap: 6px;
}

.cal-day {
  border: 1px solid #dee5ed;
  border-radius: 10px;
  background: white;
  padding: 8px;
  min-height: 120px;
  min-width: 0;
}

.cal-day.today {
  border-color: var(--brand, #526b86);
  box-shadow: 0 0 0 1px var(--brand, #526b86);
}

.cal-day.drop {
  background: #eff6ff;
}

.cal-day.outside {
  background: #f7f9fb;
  color: #8190a2;
}

.cal-day > b {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: capitalize;
}

.cal-head {
  font-size: 11px;
  text-transform: uppercase;
  color: #8190a2;
  padding: 4px;
}

.cal-chip {
  display: block;
  width: 100%;
  min-height: 0;
  text-align: left;
  padding: 6px 8px;
  margin: 0 0 5px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid transparent;
}

.cal-chip small {
  display: block;
  color: inherit;
  opacity: 0.8;
}

.cal-chip[draggable="true"] {
  cursor: grab;
}

.cal-ok {
  background: #ecfdf3;
  color: #166534;
}

.cal-warn {
  background: #fff8db;
  color: #854d0e;
}

.cal-off {
  background: #fff1f0;
  color: #b42318;
  text-decoration: line-through;
}

.cal-info {
  background: #eff6ff;
  color: #2454a4;
}

.cal-block {
  background: #eef1f5;
  color: #53677f;
  border: 1px dashed #b7c3d1;
}

.service-picker {
  grid-column: 1 / -1;
  border: 1px solid #d5dfea;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 12px 0;
}

.service-picker label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 16px 6px 0;
}

.service-picker small {
  display: block;
}

/* Métricas SaaS, cobranza y modo soporte */
.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center;
  gap: 12px;
}

.bar-track {
  height: 12px;
  border-radius: 6px;
  background: var(--line, #dee5ed);
  overflow: hidden;
}

.bar-track span {
  display: block;
  height: 100%;
  background: var(--brand, #526b86);
}

.support-mode #view button:not([data-detail]):not(.agenda-tabs button):not(.agenda-nav button) {
  opacity: 0.45;
  pointer-events: none;
}

/* Invitaciones de acceso (enlace para compartir) */
.invite-box input.invite-link { width: min(100%, 34rem); font-size: 0.85rem; }

/* Horario semanal por profesional */
.weekly { grid-column: 1 / -1; }
.weekly-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.35rem 0; }
.weekly-day { display: flex; align-items: center; gap: 0.4rem; min-width: 5rem; margin: 0; }
.weekly-row input[type=time] { width: auto; }
