:root {
  color-scheme: light;
  --bg: #fff7fc;
  --panel: #fffefe;
  --ink: #2b2231;
  --muted: #746579;
  --line: #eadced;
  --brand: #9b6bd3;
  --brand-dark: #7546b7;
  --accent: #d96fa6;
  --soft: #f3eaff;
  --soft-pink: #ffeaf4;
  --warn: #fff1c9;
  --ok: #eaf7ee;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body[data-auth="signed-out"] .app-shell {
  display: none;
}

body[data-auth="signed-in"] .auth-gate {
  display: none;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #fff0f7 0%, #f4ecff 100%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 42px rgb(140 93 156 / 0.14);
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-card p {
  color: var(--muted);
}

.error-text {
  min-height: 20px;
  margin-bottom: 0;
  color: #9d2f22;
}

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

button,
select {
  cursor: pointer;
}

a.primary,
a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 24px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fff0f7 0%, #f4ecff 100%);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand h1 {
  margin-bottom: 8px;
}

.brand p:last-child {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.35;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.7rem;
}

h3 {
  margin-bottom: 0;
}

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

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius);
}

.tab.active {
  background: #fff8fd;
  border-color: #e3c7ee;
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 6px 18px rgb(155 107 211 / 0.12);
}

main {
  padding: 28px;
  min-width: 0;
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions select {
  min-width: 180px;
}

.sync-status {
  color: var(--muted);
  font-size: 0.88rem;
}

.dashboard-control,
.bookings-control {
  display: none;
}

body[data-view="dashboard"] .dashboard-control,
body[data-view="messages"] .dashboard-control,
body[data-view="bookings"] .bookings-control {
  display: inline-flex;
}

.primary,
.ghost,
.icon-btn,
.danger {
  border-radius: var(--radius);
  min-height: 40px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--panel);
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
  font-weight: 700;
}

.primary:hover {
  background: var(--brand-dark);
}

.ghost:hover,
.icon-btn:hover {
  border-color: var(--brand);
}

.danger {
  border-color: #c94b3a;
  background: #fff7f5;
  color: #9d2f22;
}

.danger:hover {
  background: #ffe9e4;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.metrics article,
.booking-card,
.provider-card,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgb(140 93 156 / 0.08);
}

.metrics article {
  padding: 16px;
}

.credit-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgb(140 93 156 / 0.08);
  padding: 16px;
  margin-bottom: 28px;
  display: grid;
  gap: 14px;
}

.credit-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.credit-list {
  display: grid;
  gap: 10px;
}

.credit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff8fd;
}

.credit-row span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.9rem;
}

.empty-inline {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 1.8rem;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: var(--radius);
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.booking-list {
  display: grid;
  gap: 12px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 24px rgb(140 93 156 / 0.08);
  margin-bottom: 24px;
}

.calendar-weekday {
  padding: 10px 8px;
  background: #fff0f8;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 112px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}

.calendar-day.bank-holiday {
  background: #fff4e3;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 6px;
}

.calendar-day span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.calendar-day.has-service {
  background: #fff8fd;
}

.calendar-day.has-service.bank-holiday {
  background: #fff1de;
}

.muted-day {
  background: #fcf7fb;
}

.calendar-event {
  width: 100%;
  min-height: 0;
  margin-bottom: 5px;
  padding: 5px 6px;
  border: 1px solid #e6d2ef;
  border-radius: 6px;
  background: var(--soft);
  color: var(--brand-dark);
  text-align: left;
  font-size: 0.78rem;
}

.day-note-button {
  min-height: 22px;
  width: 22px;
  padding: 0;
  border: 1px solid #e2c8ed;
  border-radius: 999px;
  background: #fff8fd;
  color: var(--brand-dark);
  font-weight: 700;
}

.holiday-label,
.day-note {
  display: block;
  width: 100%;
  margin-bottom: 5px;
  border-radius: 6px;
  padding: 4px 5px;
  text-align: left;
  font-size: 0.72rem;
}

.holiday-label {
  background: #ffe0ad;
  color: #794600;
}

.day-note {
  border: 1px solid #cddff8;
  background: #eaf3ff;
  color: #24527c;
}

.day-note.office {
  border-color: #c4d8f4;
  background: #e8f1ff;
}

.day-note.away {
  border-color: #f2c7d9;
  background: #ffe9f2;
  color: #8a3158;
}

.day-note.home {
  border-color: #bfe3d2;
  background: #e9f8f0;
  color: #2f6d4e;
}

.day-note.holidays {
  border-color: #eec7a0;
  background: #fff0dc;
  color: #865011;
}

.monthly-message-head,
.list-head {
  margin-top: 22px;
}

.message-panel {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.message-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.message-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr)) auto;
  gap: 10px;
  align-items: center;
}

.message-preview {
  margin-bottom: 12px;
  min-height: 128px;
}

.booking-card {
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.booking-card.archived {
  opacity: 0.72;
}

.booking-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.booking-title strong {
  font-size: 1.05rem;
}

.meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.94rem;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--soft);
  color: var(--brand-dark);
}

.pill.booked {
  background: var(--warn);
  color: #7d5513;
}

.pill.complete,
.pill.paid {
  background: var(--ok);
  color: #216232;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.provider-card {
  padding: 16px;
}

.provider-card h3 {
  margin-bottom: 4px;
}

.provider-card p {
  color: var(--muted);
  margin-bottom: 14px;
}

.provider-card .actions {
  justify-content: flex-start;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fff0f8;
  color: var(--muted);
  font-size: 0.85rem;
}

dialog {
  width: min(620px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(37 33 29 / 0.35);
}

form {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.view-dialog {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.booking-details {
  margin: 0;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
}

.booking-details dt {
  color: var(--muted);
}

.booking-details dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pet-picks {
  display: flex;
  gap: 16px;
}

.pet-picks label {
  display: flex;
  align-items: center;
  color: var(--ink);
}

.pet-picks input {
  width: auto;
  min-height: auto;
}

.form-hint,
.dialog-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

menu {
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.empty {
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
    min-height: 0;
  }

  .sidebar {
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 18px;
  }

  .brand {
    display: block;
  }

  .brand h1 {
    font-size: 1.45rem;
  }

  .brand p:last-child {
    display: none;
  }

  .tabs {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    align-items: center;
  }

  .tab {
    text-align: center;
    min-height: 44px;
    padding: 9px 6px;
    font-size: 0.95rem;
  }

  main {
    padding: 18px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .booking-card,
  .topbar,
  .section-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .booking-card {
    display: block;
  }

  .credit-row {
    display: grid;
    align-items: stretch;
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: visible;
  }

  .calendar-weekday,
  .calendar-day {
    min-width: 0;
    min-height: 72px;
    padding: 5px;
  }

  .calendar-weekday {
    display: block;
    padding: 7px 2px;
    font-size: 0.68rem;
  }

  .calendar-event {
    padding: 3px 4px;
    font-size: 0.68rem;
  }

  .holiday-label,
  .day-note {
    font-size: 0.62rem;
    padding: 3px;
  }

  .message-controls {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 12px;
  }
}

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

  .tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .tab {
    font-size: 0.8rem;
    padding: 8px 3px;
  }

  .calendar-day {
    min-height: 58px;
  }

  .calendar-day span {
    font-size: 0.72rem;
    margin-bottom: 3px;
  }

  .day-note-button {
    min-height: 18px;
    width: 18px;
    font-size: 0.7rem;
  }

  .calendar-event {
    font-size: 0;
    min-height: 8px;
    padding: 0;
  }

  .holiday-label,
  .day-note {
    font-size: 0;
    min-height: 7px;
    padding: 0;
  }

  .booking-details {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
