:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --line: #d9e0e8;
  --line-soft: #edf1f5;
  --text: #17212b;
  --muted: #667085;
  --blue: #75d6f4;
  --blue-dark: #116f9d;
  --green: #b8ff2c;
  --green-dark: #263600;
  --danger: #b42318;
  --row-h: 48px;
  --time-w: 72px;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.scheduler {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
}

.toolbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.icon-btn,
.today-btn,
.duration-control select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  border-radius: 10px;
}

.icon-btn {
  width: 38px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.today-btn {
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn:hover,
.today-btn:hover {
  background: #f3f6f9;
}

.week-title {
  margin-left: 8px;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duration-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.duration-control select {
  padding: 0 32px 0 10px;
  cursor: pointer;
  font-weight: 700;
}

.message {
  margin: 12px 18px 0;
  padding: 11px 13px;
  border: 1px solid #f2c6c2;
  background: #fff5f4;
  color: var(--danger);
  border-radius: 10px;
  font-size: 13px;
}

.calendar-shell {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
  background: var(--surface);
}

.calendar-grid {
  min-width: 920px;
  display: grid;
  grid-template-columns: var(--time-w) repeat(5, minmax(160px, 1fr));
  align-content: start;
}

.grid-corner,
.day-head {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 66px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.grid-corner {
  left: 0;
  z-index: 18;
  border-right: 1px solid var(--line);
}

.day-head {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.day-name {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.day-number {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  margin-top: 3px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 20px;
}

.day-head.today .day-number {
  background: #1769e0;
  color: white;
}

.time-label {
  position: sticky;
  left: 0;
  z-index: 10;
  height: var(--row-h);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 7px 10px 0 4px;
  color: var(--muted);
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
}

.slot {
  height: var(--row-h);
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--muted);
  position: relative;
  text-align: left;
  padding: 6px;
  cursor: pointer;
  transition: background .14s ease, box-shadow .14s ease;
}

.slot.free:hover,
.slot.free:focus-visible {
  outline: none;
  background: #f5ffe6;
  box-shadow: inset 0 0 0 2px #9fe21b;
  color: var(--green-dark);
}

.slot.free::after {
  content: "Livre";
  opacity: 0;
  font-size: 11px;
  font-weight: 800;
}

.slot.free:hover::after,
.slot.free:focus-visible::after {
  opacity: 1;
}

.slot.busy {
  background: color-mix(in srgb, var(--blue) 82%, white);
  color: #075985;
  cursor: default;
  font-size: 11px;
  font-weight: 800;
}

.slot.unavailable {
  background: #f7f8fa;
  color: #b2b9c3;
  cursor: default;
}

.slot.past {
  background: #fafafa;
  color: #c0c5cd;
  cursor: default;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.82);
  color: var(--muted);
  font-size: 14px;
  backdrop-filter: blur(2px);
}

.fallback {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: white;
}

.fallback iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.booking-modal {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  overflow: visible;
}

.booking-modal::backdrop {
  background: rgba(10, 15, 22, .58);
  backdrop-filter: blur(4px);
}

.booking-card {
  position: relative;
  padding: 26px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}

.close-btn {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #f2f4f7;
  color: #344054;
  font-size: 25px;
  cursor: pointer;
}

.modal-kicker {
  margin: 0 0 6px;
  color: #5f8300;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.booking-card h2 {
  margin: 0;
  font-size: 24px;
}

.slot-summary {
  margin: 6px 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

.booking-card label {
  display: block;
  margin-top: 14px;
}

.booking-card label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #475467;
}

.booking-card input,
.booking-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  background: white;
  color: var(--text);
}

.booking-card input:focus,
.booking-card textarea:focus {
  border-color: #8bbd16;
  box-shadow: 0 0 0 3px rgba(184,255,44,.18);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.secondary-btn,
.primary-btn {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: white;
  color: #344054;
}

.primary-btn {
  border: 1px solid #92cb16;
  background: var(--green);
  color: #182200;
}

.primary-btn:disabled {
  opacity: .55;
  cursor: wait;
}

.hp {
  position: absolute !important;
  left: -99999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 15px;
  border-radius: 12px;
  background: #17212b;
  color: white;
  box-shadow: 0 14px 40px rgba(0,0,0,.25);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 720px) {
  :root {
    --time-w: 58px;
    --row-h: 44px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .toolbar-nav {
    width: 100%;
  }

  .week-title {
    font-size: 15px;
  }

  .duration-control {
    width: 100%;
    justify-content: flex-end;
  }

  .calendar-grid {
    min-width: 820px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .booking-card {
    padding: 22px 18px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .secondary-btn,
  .primary-btn {
    width: 100%;
  }
}
