:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --ink: #23282A;
  --ink-soft: #5B655F;
  --pine: #2F4F41;
  --pine-dark: #223A30;
  --clay: #B97A56;
  --line: #DDD8CC;
  --success: #3E7C59;
  --success-bg: #E7F1EB;
  --error: #B0483D;
  --error-bg: #FAEAE7;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* Top bar */
.topbar {
  background: var(--pine);
  color: #fff;
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.brand {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.main-nav {
  display: flex;
  gap: 20px;
  flex: 1;
}
.main-nav a {
  color: #E4E9E6;
  font-size: 0.92rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.main-nav a:hover { color: #fff; text-decoration: none; }
.main-nav a.active { color: #fff; border-bottom-color: var(--clay); }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  color: #CBD5CF;
}
.topbar-user a { color: #E4E9E6; }

/* Headings */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--pine-dark);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* Flash messages */
.flash-stack { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-info { background: #EAF1F6; color: #2F5D77; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-dark); }
.btn-secondary { background: #fff; color: var(--pine); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--pine); }
.btn-block { width: 100%; }
.btn-text {
  background: none;
  border: none;
  color: var(--pine);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0;
}
.btn-text-danger { color: var(--error); }
.btn-text:hover { text-decoration: underline; }
.inline-form { display: inline; }

/* Forms */
.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
input, select, textarea {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--pine);
  outline-offset: 1px;
  border-color: var(--pine);
}
textarea { resize: vertical; }
.form-actions { display: flex; align-items: center; gap: 18px; margin-top: 8px; }

.booking-form, .auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  max-width: 720px;
}

/* Auth */
.auth-wrap { display: flex; justify-content: center; padding-top: 40px; }
.auth-card { width: 340px; }
.auth-sub { color: var(--ink-soft); font-size: 0.9rem; margin: -2px 0 20px; }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.filter-bar label { font-size: 0.85rem; color: var(--ink-soft); }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: none; }
.msg-cell { white-space: normal; max-width: 240px; color: var(--ink-soft); }
.col-actions { display: flex; gap: 12px; white-space: nowrap; }

.empty-state {
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 40px;
  text-align: center;
}

.subtle { color: var(--ink-soft); font-size: 0.82rem; }
.hint { font-size: 0.8rem; color: var(--ink-soft); }
.assign-cell { white-space: normal; font-size: 0.85rem; }
.assign-cell > div { margin-bottom: 2px; }

/* Setup page */
.section-intro { color: var(--ink-soft); max-width: 640px; margin-bottom: 28px; }
.setup-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 22px;
}
.setup-section h2 { font-size: 1.05rem; margin: 0 0 2px; color: var(--pine-dark); }
.setup-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 14px 0; }
.setup-table th, .setup-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.inline-add-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.inline-add-form input, .inline-add-form select { padding: 7px 10px; }
.reorder-cell { display: flex; gap: 4px; white-space: nowrap; }
.reorder-cell button { font-size: 1rem; padding: 0 4px; }
.reorder-cell button:disabled { opacity: 0.25; cursor: default; }
.checkbox-row label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.checkbox-row input[type="checkbox"] { width: auto; }

/* Package treatment rows */
.section-heading { font-size: 1rem; color: var(--pine-dark); margin: 24px 0 4px; }
.treatment-row {
  display: grid;
  grid-template-columns: 24px 2fr 1fr 110px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}
.treatment-row-num { color: var(--ink-soft); font-size: 0.85rem; text-align: right; }

/* Schedule grid */
.schedule-wrap { overflow-x: auto; }
.schedule-table { font-size: 0.82rem; }
.schedule-table th, .schedule-table td { white-space: nowrap; text-align: center; padding: 6px 10px; }
.schedule-table .time-col { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.schedule-table td.free { background: transparent; }
.schedule-table td.occupied { border-radius: 4px; }
.schedule-table td.occupied-treatment { background: #E7F1EB; color: var(--pine-dark); }
.schedule-table td.occupied-food { background: #F5E9DE; color: #8A5731; }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px 20px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Therapists */
.level-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}
.level-low { background: #EEF0EC; color: var(--ink-soft); }
.level-medium { background: #EAF1F6; color: #2F5D77; }
.level-high { background: var(--success-bg); color: var(--pine-dark); }
.roster-table td, .roster-table th { text-align: center; }
.roster-table td:first-child, .roster-table th:first-child,
.roster-table td:nth-child(2), .roster-table th:nth-child(2),
.roster-table td:nth-child(3), .roster-table th:nth-child(3) { text-align: left; }
.roster-table input[type="radio"] { width: 18px; height: 18px; cursor: pointer; }

/* Therapists on the schedule: names in treatment cells and lunch cells
   share one purple, so staff read differently from customers (brown) and
   rooms (blue); non-treatment duties get their own ochre. */
.therapist-line { color: #5E4476; font-weight: 600; }
.staff-warning { color: var(--error); font-weight: 600; }
.schedule-table td.occupied-lunch { background: #EFE8F4; color: #5E4476; }
.schedule-table td.occupied-lunch .lunch-name { font-weight: 600; }
.schedule-table td.staff-duty-row { text-align: left; white-space: normal; padding: 8px 10px; }
.schedule-table tr.spacer-row td { border: none; height: 10px; padding: 0; }
.duty-chip, .lunch-chip {
  display: inline-block;
  margin: 2px 10px 2px 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
}
.duty-chip { background: #F4EDD6; color: #6B5518; }
.lunch-chip { background: #EFE8F4; color: #5E4476; }
.staff-summary { margin-top: 14px; }
.staff-summary p { margin: 6px 0; }
.staff-summary-label { display: inline-block; min-width: 60px; font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }
.staff-problems {
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.staff-problems ul { margin: 6px 0; padding-left: 20px; }
.staff-problems .subtle a { color: var(--error); text-decoration: underline; }
.therapist-line { margin-top: 3px; line-height: 1.5; }
.change-link {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--pine);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.change-link:hover { border-color: var(--pine); text-decoration: none; }

/* Inline-editable amounts on the Bookings list */
.money-input { display: inline-flex; align-items: center; gap: 2px; }
.pay-input {
  width: 88px;
  padding: 4px 6px;
  font-size: 0.9rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-color: transparent;
  background: transparent;
}
.pay-input:hover { border-color: var(--line); background: #fff; }
.pay-input:focus { background: #fff; }
.pay-input.pay-saving { color: var(--ink-soft); }
.pay-input.pay-saved { background: var(--success-bg); border-color: var(--success); }
.pay-input.pay-error { background: var(--error-bg); border-color: var(--error); }

/* Inline-editable Message on the Bookings list: reads as plain text until
   hovered/clicked, same width as before, grows downwards to fit. */
.msg-input {
  width: 100%;
  min-width: 160px;
  max-width: 240px;
  padding: 3px 6px;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--ink-soft);
  border-color: transparent;
  background: transparent;
  resize: none;
  overflow: hidden;
  display: block;
}
.msg-input:hover { border-color: var(--line); background: #fff; }
.msg-input:focus { background: #fff; color: var(--ink); }
.msg-input.pay-saved { background: var(--success-bg); border-color: var(--success); }
.msg-input.pay-error { background: var(--error-bg); border-color: var(--error); }
.pay-input.total-override { font-style: italic; color: var(--clay); }
/* Bookings list: Balance still equals the Total — no deposit or payment yet. */
.balance-cell.balance-unpaid { color: var(--clay); }

/* New booking: paste a website booking email to fill the form */
.paste-booking { margin-bottom: 16px; max-width: 720px; }
.paste-booking #paste-panel {
  margin-top: 10px; padding: 14px; background: var(--surface);
  border: 1px dashed var(--line); border-radius: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.paste-booking textarea { width: 100%; font-size: 0.85rem; }
.paste-booking #paste-result { margin-top: 4px; line-height: 1.5; }

/* Pop-up (e.g. "Regular customer" on New booking) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; }
.modal-card {
  background: #fff; max-width: 440px; margin: 14vh auto 0; padding: 1.4em 1.8em;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal-card h2 { margin: 0 0 8px; font-size: 1.15rem; color: var(--pine-dark); }

/* Room led by a Medium therapist because no High was available */
.staff-note { color: #8A5731; font-size: 0.78rem; font-weight: 600; }
.staff-medium {
  background: #F5E9DE; color: #8A5731; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; font-size: 0.9rem;
}
.staff-medium ul { margin: 6px 0 0; padding-left: 20px; }

/* Search bookings */
.search-form { max-width: 900px; }
.search-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 800px) { .search-grid { grid-template-columns: 1fr 1fr; } }
/* Top bar: let the links wrap onto a second line on narrower screens. */
.main-nav { flex-wrap: wrap; row-gap: 4px; }

/* Room for the Reports and Password links on one line */
.topbar-inner { gap: 22px; }
.main-nav { column-gap: 14px; }
