:root {
  --bg: #ececec;
  --text: #111;
  --muted: #656565;
  --line: #d8d8d8;
  --brand: #5e49ef;
  --dark: #06070b;
  --card: #fff;
  --appt: #9edbf7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.auth-pending .app {
  visibility: hidden;
}

.app {
  display: block;
  min-height: 100vh;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(94, 73, 239, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(238, 238, 238, 0.98));
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(420px, 92vw);
  padding: 28px;
  border: 1px solid #d8d8d8;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(18, 18, 18, 0.12);
  display: grid;
  gap: 14px;
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-error {
  color: #b42318;
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f5f5f5;
}

.top-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.top-nav .pill.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill,
.icon-btn,
.seg,
.add-btn,
.primary,
.ghost,
.danger {
  border-radius: 999px;
  border: 1px solid #c9c9c9;
  background: #f2f2f2;
  font: inherit;
}

.pill,
.add-btn,
.icon-btn {
  padding: 8px 16px;
}

.select-pill {
  appearance: none;
  padding-right: 26px;
}

.select-pill.compact {
  width: 110px;
}

.segmented {
  display: flex;
  border: 1px solid #c9c9c9;
  border-radius: 999px;
  overflow: hidden;
}

.seg {
  border: 0;
  background: #f2f2f2;
  padding: 8px 14px;
}

.seg + .seg {
  border-left: 1px solid #c9c9c9;
}

.seg-date {
  min-width: 150px;
  font-weight: 700;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
}

.add-wrap {
  position: relative;
}

.add-btn {
  background: #101113;
  color: #fff;
  border-color: #101113;
  font-weight: 700;
}

.add-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 250px;
  background: #fff;
  border: 1px solid #d6d6d6;
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  padding: 8px;
  display: grid;
  gap: 4px;
  z-index: 30;
}

.add-menu button {
  border: 0;
  text-align: left;
  padding: 11px;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.add-menu button:hover {
  background: #f0f0f0;
}

.hidden {
  display: none;
}

.member-strip {
  border-bottom: 1px solid var(--line);
  background: #f6f6f6;
  display: flex;
  justify-content: center;
  padding: 16px;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #9ddbf6;
  border: 3px solid #4faff2;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.member-strip p {
  margin: 0;
  font-weight: 700;
}

.calendar-wrap {
  overflow: auto;
  background: #ededed;
  position: relative;
}

.calendar {
  min-width: 820px;
  border-top: 1px solid #ddd;
}

.cal-head,
.cal-row {
  display: grid;
  grid-template-columns: 70px repeat(var(--cols), minmax(170px, 1fr));
}

.cal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #efefef;
  border-bottom: 1px solid #ddd;
}

.cal-head .slot,
.cal-head .day-head {
  padding: 8px;
  font-weight: 700;
  color: #222;
}

.day-head {
  text-align: center;
}

.time-slot {
  height: 18px;
  border-right: 1px solid #d6d6d6;
  border-bottom: 1px solid #e2e2e2;
  padding: 0 8px;
  font-weight: 700;
}

.day-cell {
  position: relative;
  border-bottom: 1px solid #e2e2e2;
  border-right: 1px solid #d6d6d6;
  height: 56px;
}

.hatch {
  background-image: repeating-linear-gradient(45deg, #f3f3f3 0, #f3f3f3 6px, #ededed 6px, #ededed 12px);
}

.day-column {
  position: relative;
  height: 728px;
  border-right: 1px solid #d6d6d6;
  background: #ededed;
}

.day-column .grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #dfdfdf;
}

.day-column .grid-line.hour-line {
  background: #c7ccd3;
}

.appt {
  position: absolute;
  left: 3px;
  right: 3px;
  background: var(--appt);
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
}

.appt strong {
  display: block;
}

.appt.unavailable {
  background: #dfdfdf;
  border: 1px dashed #9f9f9f;
}

.status-pendiente { background: #9edbf7; }
.status-confirmada { background: #9edbf7; }
.status-completada { background: #bde8cc; }
.status-cancelada { background: #f3c8c8; }

.day-off {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(45deg, #f3f3f3 0, #f3f3f3 7px, #ececec 7px, #ececec 14px);
  color: #707070;
  font-weight: 700;
  display: grid;
  place-items: center;
  z-index: 2;
  pointer-events: none;
}

.closed-slot {
  position: absolute;
  left: 0;
  right: 0;
  background-image: repeating-linear-gradient(45deg, #f2f2f2 0, #f2f2f2 7px, #ececec 7px, #ececec 14px);
  z-index: 1;
  pointer-events: none;
}

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #e3093e;
  z-index: 12;
}

.now-label {
  position: absolute;
  left: -9px;
  top: -13px;
  font-size: 12px;
  color: #e3093e;
  background: #fff;
  border: 2px solid #e3093e;
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 700;
}

.editor-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  background: #ededed;
  border-top: 1px solid #d6d6d6;
}

.card {
  background: var(--card);
  border: 1px solid #d9d9d9;
  border-radius: 14px;
  padding: 12px;
}

.card h3 {
  margin: 0 0 12px;
}

.stack {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid #d2d2d2;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.primary,
.ghost,
.danger {
  cursor: pointer;
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
}

.primary {
  background: #111;
  color: #fff;
}

.ghost {
  background: #f4f4f4;
}

.danger {
  background: #bd2833;
  color: #fff;
  border-color: #bd2833;
}

.entity-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow: auto;
}

.entity-list li {
  border: 1px solid #dedede;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.item-main {
  font-size: 12px;
}

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

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  display: grid;
  place-items: center;
  z-index: 120;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(1020px, 96vw);
  max-height: 92vh;
  background: #f0f0f0;
  border: 1px solid #d3d3d3;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  overflow: auto;
}

.action-panel {
  width: min(420px, 94vw);
  background: #fff;
  border: 1px solid #d3d3d3;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.action-panel h3 {
  margin: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px 0;
}

.close-x {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.modal-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.schedule-table {
  border: 1px solid #d6d6d6;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: 100px minmax(220px, 1fr) minmax(220px, 1fr) 80px;
  gap: 6px;
  align-items: center;
  min-width: 700px;
}

#panel-horario .stack {
  overflow-x: auto;
  padding-bottom: 4px;
}

.schedule-head {
  font-size: 12px;
  font-weight: 700;
  color: #555;
}

.schedule-day {
  font-size: 12px;
  font-weight: 700;
}

.schedule-range {
  display: grid;
  grid-template-columns: 1fr 12px 1fr;
  align-items: center;
  gap: 5px;
}

.schedule-range input {
  min-width: 0;
  padding: 6px 8px;
}

.schedule-range span {
  text-align: center;
  font-size: 12px;
  color: #666;
}

.schedule-closed {
  display: grid;
  place-items: center;
}

.quick-menu {
  position: absolute;
  z-index: 40;
  min-width: 210px;
  background: #fff;
  border: 1px solid #d6d6d6;
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.14);
  padding: 6px;
  display: grid;
  gap: 4px;
}

.quick-menu.hidden {
  display: none;
}

.quick-close {
  justify-self: end;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.quick-close:hover {
  background: #f1f1f1;
}

.quick-menu button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 10px;
  font: inherit;
  cursor: pointer;
}

.quick-menu button:hover {
  background: #f1f1f1;
}

.service-catalog {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.service-type-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.type-chip {
  border: 1px solid #d4d7dc;
  background: #f4f5f7;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
}

.type-chip.active {
  background: #111;
  color: #fff;
  border-color: #111;
}

.service-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.catalog-card {
  border: 1px solid #e0e3e8;
  border-radius: 12px;
  background: #fafafa;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.catalog-card h4 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.catalog-card p {
  margin: 0;
  font-size: 14px;
  color: #222;
}

.catalog-card small {
  color: #5d6773;
  font-size: 12px;
}

.catalog-actions {
  margin-top: 4px;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1300px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 980px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }

  .schedule-table {
    grid-template-columns: 1fr;
  }

  .schedule-head {
    display: none;
  }
}
