:root {
  --teal: #39bea1;
  --teal-dark: #1f9c86;
  --teal-soft: #dff7f2;
  --ink: #25302f;
  --muted: #687674;
  --line: #dce8e6;
  --bg: #f5faf9;
  --card: #ffffff;
  --slot: #f0f3f2;
  --danger: #b94a48;
  --warning: #fff3d9;
  --shadow: 0 16px 35px rgba(28, 85, 75, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #eef8f6 0%, var(--bg) 45%, #fff 100%);
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  position: static;
  backdrop-filter: blur(10px);
}

h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.7rem; }
h2 { font-size: clamp(1.7rem, 3vw, 2.6rem); margin-bottom: 10px; }
h3 { font-size: 1.25rem; margin-bottom: 0; }
h4 { margin-bottom: 10px; }

main { padding: 26px; max-width: 1440px; margin: 0 auto; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
}
.subcopy { color: var(--muted); max-width: 760px; line-height: 1.55; }
.fineprint { color: var(--muted); font-size: 0.82rem; margin: 8px 0 0; }

.mode-switch {
  display: flex;
  background: var(--teal-soft);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid #c9eee7;
}
.mode-switch button {
  border: 0;
  background: transparent;
  padding: 10px 15px;
  border-radius: 999px;
  color: var(--teal-dark);
  font-weight: 700;
}
.mode-switch button.active {
  color: white;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(57, 190, 161, 0.28);
}

.app-section { display: none; }
.app-section.active { display: block; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.hero-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;
}
.hero-panel::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--teal-soft);
  right: -80px;
  top: -70px;
  z-index: 0;
}
.hero-panel > * { position: relative; z-index: 1; }
.quick-card {
  min-width: 245px;
  background: #f7fcfb;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
}
.quick-card label { display: block; font-weight: 800; margin-bottom: 8px; }
select, input[type="date"], input[type="time"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

.grid { display: grid; gap: 22px; }
.two-col { grid-template-columns: minmax(0, 1fr) 360px; }
.admin-grid { grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr); }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.panel-head.compact { margin-bottom: 12px; }
.date-controls { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: 0;
  background: var(--teal);
  color: white;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 1.8rem;
  line-height: 1;
}
.primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  font-weight: 800;
}
.primary-btn { background: var(--teal); color: white; }
.secondary-btn { background: var(--teal-soft); color: var(--teal-dark); }
.danger-btn { background: #fbe5e4; color: var(--danger); }

.calendar {
  display: grid;
  grid-template-columns: 78px repeat(3, minmax(180px, 1fr));
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: auto;
  max-height: 700px;
  background: white;
}
.time-head, .room-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: white;
  border-bottom: 2px solid var(--teal);
  padding: 14px 12px;
  font-weight: 900;
  text-align: center;
}
.time-label {
  min-height: 54px;
  padding: 7px 10px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid white;
  background: white;
  text-align: right;
}
.slot {
  position: relative;
  min-height: 54px;
  border-left: 1px solid white;
  border-bottom: 1px solid white;
  background: repeating-linear-gradient(180deg, var(--slot), var(--slot) 26px, #e9eeee 27px);
}
.slot.available:hover {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  background: #e8faf6;
}
.booking-block {
  position: absolute;
  inset: 4px 7px;
  border-radius: 9px;
  background: var(--teal);
  color: white;
  padding: 9px 10px;
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(31, 156, 134, 0.24);
  z-index: 1;
  font-weight: 700;
}
.booking-block.cancelled {
  background: #8d9c99;
  opacity: 0.78;
  text-decoration: line-through;
}
.booking-block small { display: block; font-weight: 600; opacity: 0.95; }
.booking-block .room-cost { margin-top: 5px; opacity: 0.9; }
.booking-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.booking-actions button { padding: 6px 9px; font-size: 0.8rem; }

.booking-list { display: grid; gap: 12px; }
.booking-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: #fbfefd;
}
.booking-card strong { display: block; margin-bottom: 5px; }
.booking-card p { margin: 0 0 5px; color: var(--muted); }
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.status-pill.cancelled { background: #eee; color: #68706e; }
.status-pill.late { background: var(--warning); color: #8a5d08; }
.rate-box, .admin-tools {
  margin-top: 20px;
  background: var(--teal-soft);
  border: 1px solid #c9eee7;
  border-radius: 18px;
  padding: 15px;
}
.rate-box p { margin-bottom: 5px; color: var(--ink); }

.totals-card span, .totals-card small { display: block; color: var(--muted); }
.totals-card strong { display: block; font-size: 2rem; margin: 6px 0; color: var(--teal-dark); }
.report-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.report-controls label { font-weight: 800; color: var(--ink); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f4faf8; font-size: 0.86rem; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.admin-tools ul { margin-bottom: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }

.modal {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(520px, calc(100vw - 28px));
  box-shadow: 0 28px 60px rgba(20, 45, 41, 0.26);
}
.modal::backdrop { background: rgba(24, 45, 42, 0.45); }
.modal form { padding: 24px; position: relative; }
.close-btn {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: #eef5f3;
  font-size: 1.35rem;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.form-grid label { font-weight: 800; }
.price-preview {
  padding: 14px;
  background: var(--teal-soft);
  border-radius: 14px;
  font-weight: 900;
  color: var(--teal-dark);
}
.error-text { color: var(--danger); min-height: 22px; margin: 10px 0 0; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

@media (max-width: 1050px) {
  .two-col, .admin-grid { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: 70px repeat(3, minmax(170px, 1fr)); }
}
@media (max-width: 720px) {
  .topbar, .hero-panel, .panel-head { flex-direction: column; align-items: stretch; }
  main { padding: 14px; }
  .mode-switch { width: 100%; }
  .mode-switch button { flex: 1; }
  .report-controls, .form-grid { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: 62px repeat(3, 165px); }
}


.calendar-note { margin: 10px 2px 0; }
.mini-divider { height: 1px; background: var(--line); margin: 18px 0; }
.mini-head h3 { font-size: 1.05rem; }
.compact-list .booking-card { padding: 10px 11px; }
.compact-list .booking-card p { font-size: 0.86rem; }
.inline-tool { margin-top: 8px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 14px 35px rgba(20, 45, 41, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  z-index: 20;
  font-weight: 800;
  max-width: calc(100vw - 28px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.booking-block div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-block small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 720px) {
  .panel { padding: 18px; border-radius: 22px; }
  .calendar {
    grid-template-columns: 56px repeat(3, minmax(86px, 1fr));
    overflow-x: hidden;
    max-height: 620px;
  }
  .time-head, .room-head {
    padding: 10px 5px;
    font-size: 0.82rem;
    line-height: 1.15;
  }
  .time-label {
    min-height: 48px;
    padding: 6px 5px;
    font-size: 0.8rem;
  }
  .slot { min-height: 48px; }
  .booking-block {
    inset: 3px;
    padding: 7px 6px;
    border-radius: 8px;
    font-size: 0.74rem;
    line-height: 1.12;
  }
  .booking-block small { font-size: 0.68rem; }
  .date-controls { width: 100%; }
  .date-controls input { flex: 1; min-width: 0; }
}

@media (max-width: 390px) {
  .calendar { grid-template-columns: 50px repeat(3, minmax(74px, 1fr)); }
  .room-head { font-size: 0.74rem; }
  .booking-block { font-size: 0.68rem; }
  .booking-block small { font-size: 0.62rem; }
}


/* v3 mobile refinements */
@media (max-width: 720px) {
  .topbar {
    position: static;
    padding: 16px 14px;
  }

  main {
    padding: 12px 0;
  }

  .panel {
    margin-left: 10px;
    margin-right: 10px;
  }

  .hero-panel,
  .side-panel,
  .admin-grid > .panel:not(.calendar-panel) {
    margin-left: 14px;
    margin-right: 14px;
  }

  .calendar-panel {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .calendar-panel .panel-head,
  .calendar-panel .calendar-note {
    padding-left: 14px;
    padding-right: 14px;
  }

  .calendar {
    width: 100%;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    grid-template-columns: 48px repeat(3, minmax(0, 1fr));
  }

  .admin-calendar {
    grid-template-columns: 48px repeat(3, minmax(0, 1fr));
    max-height: 560px;
  }

  .admin-hero .quick-card,
  .quick-card {
    min-width: 0;
    width: 100%;
  }

  .table-wrap {
    overflow-x: auto;
  }

  th, td {
    padding: 9px 8px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .admin-tools ul {
    padding-left: 17px;
  }
}

@media (max-width: 390px) {
  .calendar,
  .admin-calendar {
    grid-template-columns: 44px repeat(3, minmax(0, 1fr));
  }

  .time-head, .room-head {
    padding-left: 3px;
    padding-right: 3px;
  }
}

/* v4 mobile containment + minimal calendar borders */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.grid,
.panel,
.calendar,
.table-wrap,
.admin-grid,
.two-col {
  min-width: 0;
}

#adminApp,
#clientApp {
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 720px) {
  main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .admin-grid,
  .two-col {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  #adminApp .panel,
  #clientApp .panel {
    max-width: 100%;
  }

  #adminApp .hero-panel,
  #adminApp .admin-grid > .panel:not(.calendar-panel),
  #clientApp .hero-panel,
  #clientApp .side-panel {
    width: calc(100% - 20px);
    margin-left: 10px;
    margin-right: 10px;
  }

  .calendar-panel,
  .admin-calendar-panel,
  .client-calendar-panel {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
  }

  .calendar {
    width: 100%;
    max-width: 100%;
    border: 1px solid #d8e8e5;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    overflow-x: hidden;
  }

  .admin-calendar,
  #adminCalendar {
    width: 100%;
    max-width: 100%;
    grid-template-columns: 44px repeat(3, minmax(0, 1fr));
  }

  #adminApp .panel-head,
  #adminApp .calendar-note,
  #clientApp .calendar-panel .panel-head,
  #clientApp .calendar-panel .calendar-note {
    padding-left: 12px;
    padding-right: 12px;
  }

  .report-controls {
    width: 100%;
    max-width: 100%;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 520px;
  }

  .admin-tools,
  .rate-box {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 390px) {
  .admin-calendar,
  #adminCalendar,
  .calendar {
    grid-template-columns: 42px repeat(3, minmax(0, 1fr));
  }

  #adminApp .booking-block {
    font-size: 0.62rem;
    padding: 6px 4px;
  }

  #adminApp .booking-block small {
    font-size: 0.58rem;
  }
}
