:root {
  --brand: #0d9488;
  --brand-dark: #115e59;
  --summary-accent: light-dark(#1e40af, #93c5fd);
  --bg: light-dark(#ffffff, #18181b);
  --fg: light-dark(#18181b, #fafafa);
  --muted: light-dark(#71717a, #a1a1aa);
  --elevated: light-dark(#f4f4f5, #27272a);
  --ring: light-dark(#e4e4e7, #3f3f46);
  --danger: #dc2626;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.header {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  border-bottom: 1px solid var(--ring);
  background: var(--bg);
}

.header-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.btn-header-back {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--brand);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.btn-header-back:hover {
  background: var(--elevated);
}

.btn-header-back.hidden {
  visibility: hidden;
  pointer-events: none;
}

.title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.main {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/*
 * Day / hour / service lists: keep step chrome (tz, month picker, day label)
 * fixed and scroll only the list. Avoids double scroll (main + panel).
 */
.main:has(.scroll-panel) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.main:has(> .scroll-panel) > .scroll-panel {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.footer {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ring);
  background: var(--bg);
}

.footer.hidden { display: none; }

.btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-ghost {
  background: var(--elevated);
  color: var(--fg);
}

.hidden { display: none !important; }

.state {
  text-align: center;
  padding: 2rem 0.5rem;
}

.state p { color: var(--muted); margin: 0.5rem 0 0; }

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto;
  border: 3px solid var(--ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.grid {
  display: grid;
  gap: 0.5rem;
}

.scroll-panel {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.scroll-panel-x {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.scroll-panel-x::-webkit-scrollbar,
.scroll-panel::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}

.scroll-panel-x::-webkit-scrollbar-thumb,
.scroll-panel::-webkit-scrollbar-thumb {
  background: var(--ring);
  border-radius: 4px;
}

.time-step {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.time-step > .tz-note-top,
.time-step > .day-filter-header,
.time-step > .day-selected-label {
  flex-shrink: 0;
}

.time-step > .scroll-panel {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.tz-note-top {
  margin: 0;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  background: var(--elevated);
  border-radius: 8px;
}

.day-chip {
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 0.6rem 0.5rem;
  min-height: 3.35rem;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color 120ms, background 120ms;
}

.day-chip-weekday {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: capitalize;
}

.day-chip-date {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}

.day-filter-header,
.stay-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.day-grid.day-grid--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 7rem;
  padding: 1rem 0.5rem;
}

.day-month-empty {
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.45;
}

.period-picker-row {
  display: flex;
  flex: 1;
  align-items: stretch;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}

.period-dropdown-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.period-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  border: 1px solid var(--ring);
  border-radius: 10px;
  background: var(--elevated);
  color: var(--fg);
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.55rem 0.65rem;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}

.period-trigger-label-month {
  text-transform: capitalize;
}

.period-trigger:hover {
  border-color: var(--brand);
}

.period-trigger[aria-expanded="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.period-chevron {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: var(--muted);
  line-height: 1;
}

.period-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 11rem;
  overflow-y: auto;
  border: 1px solid var(--ring);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 6px 18px light-dark(rgb(0 0 0 / 10%), rgb(0 0 0 / 35%));
  padding: 0.25rem;
}

.period-option {
  display: block;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  text-transform: capitalize;
}

.period-option:hover {
  background: color-mix(in srgb, var(--brand) 10%, var(--bg));
}

.period-option.selected {
  background: var(--brand);
  color: light-dark(#ffffff, var(--fg));
  font-weight: 700;
}

.period-option.selected:hover {
  background: var(--brand);
  color: light-dark(#ffffff, var(--fg));
}

.day-selected-label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: capitalize;
}

.hour-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card {
  text-align: left;
  width: 100%;
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.card:hover:not(.disabled),
.card.selected,
.day-chip:hover,
.day-chip.selected {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--bg));
}

.card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-any { border-style: dashed; }

.chip {
  border: 1px solid var(--ring);
  background: var(--elevated);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 4.25rem;
  text-align: center;
}

.chip:hover:not(:disabled) {
  border-color: var(--brand);
}

.chip.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.location-step {
  text-align: left;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.loc-when {
  margin: 0 0 1rem;
  padding: 0.75rem;
  background: var(--elevated);
  border-radius: 10px;
}

.loc-site {
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.loc-row {
  margin: 0.35rem 0;
  color: var(--fg);
}

.loc-k {
  display: inline-block;
  min-width: 5rem;
  font-weight: 600;
  color: var(--muted);
}

.date-range {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.date-range-modern .date-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 360px) {
  .date-range-modern .date-field-row { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.field input {
  border: 1px solid var(--ring);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--fg);
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
}

.range-hint {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
  min-height: 1.25rem;
}

.confirm-list {
  text-align: left;
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  font-size: 0.9375rem;
}

.confirm-brand {
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.badge-full { color: var(--danger); }

.empty-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.error { color: var(--danger); }

.card-title { font-weight: 600; font-size: 0.9375rem; }
.card-meta { font-size: 0.8125rem; color: var(--muted); margin-top: 0.25rem; }

.summary-card {
  border: 1px solid var(--ring);
  border-radius: 16px;
  padding: 1.25rem 1rem;
  background: var(--elevated);
}

.summary-brand {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-lines {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.summary-line {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.summary-line-when {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--summary-accent);
  padding-top: 0.5rem;
  margin-top: 0.15rem;
  border-top: 1px dashed var(--ring);
}

.summary-line-meta {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
}

.success-step,
.conflict-step {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.success-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 0.5rem;
}

.success-card-head {
  text-align: center;
}

.success-card .summary-card {
  text-align: left;
}

.success-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.success-card-actions .btn {
  width: 100%;
}

.success-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 15%, var(--bg));
  color: var(--brand);
  font-size: 2rem;
  line-height: 4rem;
  font-weight: 700;
  animation: success-pop 0.45s ease-out;
}

@keyframes success-pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.success-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.success-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.conflict-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--danger) 12%, var(--bg));
  color: var(--danger);
  font-size: 1.5rem;
  line-height: 3rem;
  font-weight: 700;
}

.conflict-title {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
}

.conflict-body {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.conflict-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.range-picker {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.range-phase-label {
  margin: 0;
  font-weight: 600;
  font-size: 0.875rem;
}

.range-selected {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.range-day-strip {
  flex-wrap: wrap;
  overflow-x: visible;
  max-height: min(40vh, 280px);
  overflow-y: auto;
}

.stay-calendar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cal-nav {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ring);
  background: var(--elevated);
  color: var(--fg);
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  font-size: 1.125rem;
  line-height: 1;
  transition: border-color 120ms, background 120ms;
}

.cal-nav-icon {
  display: block;
  transform: translateY(-0.5px);
}

.cal-nav:hover {
  border-color: var(--brand);
}

.stay-cal-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.stay-field {
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  min-height: 4.5rem;
}

.stay-field.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.stay-field-k {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stay-field-v {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 2.4rem;
  justify-content: center;
}

.stay-field-l1 {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--muted);
  text-transform: capitalize;
}

.stay-field-l2 {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
}

.stay-field.filled .stay-field-l2 {
  color: var(--summary-accent);
}

.stay-field-empty {
  opacity: 0.45;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.cal-pad {
  aspect-ratio: 1;
}

.cal-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.cal-day:hover {
  background: var(--elevated);
}

.cal-day.in-range {
  background: color-mix(in srgb, var(--brand) 12%, var(--bg));
  border-radius: 0;
}

.cal-day.range-start,
.cal-day.range-end,
.cal-day.selected {
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
}

.cal-day.range-start.in-range {
  border-radius: 8px 0 0 8px;
}

.cal-day.range-end.in-range {
  border-radius: 0 8px 8px 0;
}

/* Mis citas (view=my) */
.my-bookings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.my-booking-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--ring);
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.my-booking-card:hover {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--ring));
}

.my-booking-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent);
}

.my-booking-when {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--summary-accent, var(--brand-dark, var(--brand)));
}

.my-booking-service {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

.my-booking-meta {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.35;
}

.my-detail,
.my-cancel-confirm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.my-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-danger {
  color: var(--danger, #dc2626);
  border-color: color-mix(in srgb, var(--danger, #dc2626) 35%, var(--ring));
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger, #dc2626) 8%, var(--bg));
}

.my-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1rem 1rem;
  gap: 0.75rem;
}

.my-empty-icon {
  font-size: 2.5rem;
  line-height: 1;
  opacity: 0.55;
}

.my-empty-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.my-empty-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
  max-width: 18rem;
}

.my-cancel-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
}

.my-cancel-body {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}
