:root {
  --ink: #191713;
  --muted: #766f63;
  --line: #d9d0bf;
  --soft: #eee7d8;
  --paper: #fbf7ed;
  --panel: #fffbf2;
  --accent: #b48a45;
  --accent-dark: #8f682f;
  --charcoal: #24211d;
  --shadow: 0 18px 54px rgba(36, 33, 29, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(180, 138, 69, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(180, 138, 69, 0.08) 1px, transparent 1px),
    var(--soft);
  background-size: 34px 34px;
  font-family:
    "Helvetica Neue", Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border-radius: 0;
}

[hidden] {
  display: none !important;
}

.booking-shell {
  width: min(1212px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
}

.calendar-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  color: var(--paper);
  background: var(--charcoal);
  border-bottom: 1px solid #3a332a;
}

.eyebrow,
.step-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font: 500 clamp(1.65rem, 2vw, 2.3rem)/1.05 Georgia, "Times New Roman", serif;
}

h2 {
  margin: 0;
  font: 500 1.65rem/1.15 Georgia, "Times New Roman", serif;
}

.week-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 280px;
}

#weekLabel {
  min-width: 190px;
  margin: 0;
  text-align: center;
  font-weight: 750;
}

.icon-button,
.close-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(180, 138, 69, 0.56);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.icon-button:hover {
  background: rgba(180, 138, 69, 0.16);
}

.calendar-wrap {
  overflow: auto;
  max-height: min(760px, calc(100vh - 130px));
  overscroll-behavior: contain;
  background: var(--panel);
  scrollbar-color: var(--accent) #f5eddd;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 72px repeat(7, minmax(104px, 1fr));
  min-width: 880px;
  user-select: none;
}

.day-picker {
  display: none;
}

.corner,
.day-header,
.time-label,
.slot {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.corner,
.day-header {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 58px;
  background: #f5eddd;
}

.corner {
  left: 0;
  z-index: 4;
}

.day-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.day-header strong {
  font-size: 0.86rem;
  text-transform: uppercase;
}

.day-header span {
  color: var(--muted);
  font-size: 0.78rem;
}

.time-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-height: 44px;
  padding: 10px 8px;
  background: #f5eddd;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.slot {
  position: relative;
  min-height: 44px;
  background: var(--panel);
  cursor: pointer;
  touch-action: pan-y;
}

.slot:hover {
  background: #fff5df;
}

.slot.is-selected {
  background: rgba(180, 138, 69, 0.2);
  outline: 2px solid rgba(180, 138, 69, 0.46);
  outline-offset: -2px;
}

.slot.is-unavailable,
.slot.is-past {
  cursor: not-allowed;
  background: #ebe4d6;
}

.slot.is-split-held {
  background: rgba(73, 66, 58, 0.12);
}

.booking-pill {
  position: absolute;
  inset: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  color: #fff;
  background: var(--charcoal);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.booking-pill.split {
  background: var(--accent-dark);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 23, 19, 0.7);
}

.booking-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--accent);
  box-shadow: 0 24px 80px rgba(15, 14, 12, 0.38);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  color: var(--paper);
  background: var(--charcoal);
}

.close-button {
  flex: 0 0 auto;
  border-color: rgba(251, 247, 237, 0.3);
}

.slot-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: #f5eddd;
  border-bottom: 1px solid var(--line);
}

.slot-summary span {
  color: var(--muted);
  text-align: right;
}

.modal-step {
  padding: 24px;
}

.type-options,
.customer-form {
  display: grid;
  gap: 12px;
}

.time-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.time-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.time-editor select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fffaf0;
  color: var(--ink);
}

.time-editor select:focus {
  outline: 2px solid rgba(180, 138, 69, 0.35);
  border-color: var(--accent);
}

.availability-message {
  margin: -6px 0 14px;
  color: #8b3428;
  font-size: 0.84rem;
  line-height: 1.4;
}

.type-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fffaf0;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.type-option:hover {
  border-color: var(--accent);
  background: #fff5df;
}

.type-option.is-selected {
  border-color: var(--accent-dark);
  background: #fff1d2;
  box-shadow: inset 4px 0 0 var(--accent-dark);
}

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

.type-option span {
  display: grid;
  gap: 4px;
}

.type-option strong {
  font-size: 1rem;
}

.type-option small {
  color: var(--muted);
  line-height: 1.35;
}

.type-option b {
  flex: 0 0 auto;
  color: var(--accent-dark);
}

.customer-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.recurrence-editor {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.package-date-editor {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #fffaf0;
}

.package-date-editor p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.package-date-editor > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.package-date-editor label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.package-date-editor input {
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 9px;
  background: #fff;
  color: var(--ink);
}

.recurrence-editor select {
  min-height: 44px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fffaf0;
  color: var(--ink);
}

.customer-form input,
.customer-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 11px 12px;
  background: #fffaf0;
  color: var(--ink);
}

.customer-form input:focus,
.customer-form textarea:focus {
  outline: 2px solid rgba(180, 138, 69, 0.35);
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--charcoal);
  background: var(--charcoal);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  border-color: #aaa59d;
  background: #aaa59d;
}

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.review-list > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.review-list span {
  color: var(--muted);
}

.review-list strong {
  max-width: 65%;
  text-align: right;
  overflow-wrap: anywhere;
}

.review-list .review-total {
  padding-top: 18px;
  font-size: 1.15rem;
}

.deal-code-panel {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f5eddd;
}

.deal-code-panel > label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.deal-code-panel > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.deal-code-panel input {
  min-width: 0;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  text-transform: uppercase;
}

.deal-code-panel button {
  min-width: 84px;
  border: 1px solid var(--charcoal);
  padding: 10px 14px;
  background: var(--charcoal);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.deal-code-panel button:disabled {
  cursor: wait;
  opacity: 0.65;
}

#dealStatus {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

#dealStatus.is-success {
  color: #496246;
}

#dealStatus.is-error {
  color: #8b3428;
}

@media (max-width: 700px) {
  body {
    min-height: 100dvh;
    background: var(--panel);
  }

  .booking-shell {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .calendar-panel {
    border: 0;
    box-shadow: none;
  }

  .topbar {
    display: grid;
    gap: 14px;
    padding: 18px 16px 16px;
  }

  .week-controls {
    justify-content: space-between;
    min-width: 0;
    width: 100%;
  }

  #weekLabel {
    min-width: 0;
    font-size: 0.9rem;
  }

  .day-picker {
    display: grid;
    grid-template-columns: repeat(7, calc(100% / 7));
    gap: 0;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    background: #f5eddd;
    border-bottom: 1px solid var(--line);
  }

  .day-picker-button {
    display: grid;
    place-items: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
    min-height: 66px;
    padding: 9px 0;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
  }

  .day-picker-button span {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .day-picker-button strong {
    font-size: 1rem;
  }

  .day-picker-button.is-today strong {
    color: var(--accent-dark);
  }

  .day-picker-button.is-active {
    border-bottom-color: var(--accent-dark);
    background: rgba(180, 138, 69, 0.12);
    color: var(--ink);
  }

  .calendar-wrap {
    height: calc(100dvh - 174px);
    min-height: 520px;
    max-height: none;
  }

  .calendar-grid.is-day-view {
    grid-template-columns: 76px minmax(0, 1fr);
    width: 100%;
    min-width: 0;
  }

  .calendar-grid.is-day-view .corner,
  .calendar-grid.is-day-view .day-header {
    min-height: 54px;
  }

  .calendar-grid.is-day-view .slot,
  .calendar-grid.is-day-view .time-label {
    min-height: 52px;
  }

  .calendar-grid.is-day-view .time-label {
    padding: 17px 8px 8px;
  }

  .booking-pill {
    inset: 5px 8px;
    font-size: 0.76rem;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 0;
    background: var(--panel);
  }

  .booking-modal {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    box-shadow: none;
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 18px 16px;
  }

  .modal-step {
    padding: 20px 16px 28px;
  }

  .slot-summary {
    padding: 14px 16px;
  }

  .time-editor {
    gap: 10px;
  }

  .time-editor select,
  .customer-form input,
  .customer-form textarea,
  .package-date-editor input,
  .recurrence-editor select,
  .deal-code-panel input {
    font-size: 16px;
  }

  .type-option {
    min-height: 78px;
    gap: 12px;
    padding: 14px;
  }

  .type-option b {
    font-size: 0.9rem;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 8px;
    margin-top: 16px;
  }

  .modal-actions button {
    width: 100%;
  }

  .review-list > div {
    gap: 12px;
  }

  .review-list strong {
    max-width: 62%;
  }

  .package-date-editor > div {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  h1 {
    font-size: 1.55rem;
  }

  .type-option {
    align-items: flex-start;
    flex-direction: column;
  }

  .type-option b {
    padding-top: 2px;
  }

  .deal-code-panel > div {
    grid-template-columns: 1fr;
  }

  .deal-code-panel button {
    width: 100%;
  }
}
