/* ==========================================================
   Relaxation Lounge — shared styles (client + admin)
   White, colourful, card-based UI
   ========================================================== */

:root {
  --bg: #f3f6f2;
  --card: #ffffff;
  --text: #22302b;
  --muted: #66746e;
  --line: #e6ebe5;
  --soft: #f0f4ef;

  --violet: #3f7a6b;   /* primary (sage) — name kept for compatibility */
  --pink: #d0809a;
  --sky: #5b9bc0;
  --teal: #5fa38c;
  --amber: #e0a458;
  --green: #4caf7d;
  --red: #d9675a;
  --indigo: #8e7cc3;
  --orange: #e08a5e;
  --gray: #9aa7a1;

  --grad: linear-gradient(135deg, #3f7a6b 0%, #5fa38c 100%);
  --grad-sky: linear-gradient(135deg, #5b9bc0 0%, #86b9d4 100%);
  --grad-teal: linear-gradient(135deg, #5fa38c 0%, #8cc0a8 100%);
  --grad-amber: linear-gradient(135deg, #d99a55 0%, #e8b97a 100%);
  --grad-pink: linear-gradient(135deg, #c7798f 0%, #e3a08e 100%);
  --grad-lav: linear-gradient(135deg, #8e7cc3 0%, #b3a5dc 100%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(34, 48, 43, .04), 0 8px 24px rgba(34, 48, 43, .06);
  --shadow-lg: 0 20px 50px rgba(34, 48, 43, .18);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar-h: 0px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--violet); text-decoration: none; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.w100 { width: 100%; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 10px 18px;
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
  color: var(--text); background: var(--soft);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(63, 122, 107, .28); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(63, 122, 107, .35); }
.btn-success { background: var(--grad-teal); color: #fff; box-shadow: 0 6px 18px rgba(95, 163, 140, .25); }
.btn-danger { background: #f9e3df; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-soft { background: #eceaf6; color: var(--violet); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--soft); color: var(--text); }
.btn-wa { background: #e3f2e8; color: #15803d; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 14px 26px; font-size: 16px; border-radius: 14px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .6); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.loading::after, .btn-soft.loading::after, .btn.loading:not(.btn-primary):not(.btn-success)::after {
  border-color: rgba(63, 122, 107, .25); border-top-color: var(--violet);
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 16px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font: 500 14px var(--font); color: var(--text); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: #b5d3c7; box-shadow: 0 0 0 4px rgba(63, 122, 107, .1); }
.input.lg { font-size: 18px; padding: 12px 14px; }
.input.invalid { border-color: #fca5a5; }
textarea.input { resize: vertical; min-height: 70px; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.input-group .input { padding-left: 30px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.hint { font-size: 12px; color: var(--muted); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: #e5e7eb; position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: left .2s; }
.switch input:checked + .track { background: var(--violet); }
.switch input:checked + .track::after { left: 21px; }

/* Segmented / chip selectors */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px;
  font: 600 13px var(--font); color: var(--muted); cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg-btn:hover { border-color: #b5d3c7; color: var(--text); }
.seg-btn.active { border-color: var(--violet); background: #eef5f1; color: var(--violet); box-shadow: 0 0 0 3px rgba(63, 122, 107, .08); }
.seg-btn:disabled { opacity: .4; cursor: not-allowed; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; background: #fff;
  transition: all .15s; text-align: left; font-family: var(--font); color: var(--text); position: relative;
}
.choice:hover { border-color: color-mix(in srgb, var(--c, var(--violet)) 50%, white); transform: translateY(-1px); }
.choice.active { border-color: var(--c, var(--violet)); background: color-mix(in srgb, var(--c, var(--violet)) 7%, white); box-shadow: 0 6px 16px color-mix(in srgb, var(--c, var(--violet)) 20%, transparent); }
.choice.active::after { content: '✓'; position: absolute; top: 8px; right: 10px; width: 20px; height: 20px; border-radius: 50%; background: var(--c, var(--violet)); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.choice:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.choice .c-ic { font-size: 22px; }
.choice .c-title { font-weight: 700; margin-top: 4px; }
.choice .c-sub { font-size: 12px; color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid rgba(236, 238, 244, .7); min-width: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h3 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card-title .ic { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.cards { display: grid; gap: 18px; }

/* Colour helpers */
.bg-violet { background: #eceaf6; } .bg-pink { background: #f8e9ed; } .bg-sky { background: #e6f0f6; }
.bg-teal { background: #e2f0ea; } .bg-amber { background: #f9eedc; } .bg-green { background: #e3f2e8; }
.bg-red { background: #f9e3df; } .bg-indigo { background: #e8eaf6; } .bg-orange { background: #f9e9df; } .bg-gray { background: #f1f5f9; }

/* ---------- Badges / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted);
}
.chip-violet { background: #eceaf6; color: #6a5aa8; } .chip-pink { background: #f8e9ed; color: #a5506a; }
.chip-sky { background: #e6f0f6; color: #0369a1; } .chip-teal { background: #e2f0ea; color: #0f766e; }
.chip-amber { background: #f9eedc; color: #b45309; } .chip-green { background: #e3f2e8; color: #15803d; }
.chip-red { background: #f9e3df; color: #b91c1c; } .chip-gray { background: #f1f5f9; color: #64748b; }
.chip-indigo { background: #e8eaf6; color: #4338ca; } .chip-orange { background: #f9e9df; color: #c2410c; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }

/* Progress */
.progress { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--grad); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: #f8faf8; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: #f7faf8; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .e-ic { font-size: 40px; margin-bottom: 8px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.list-item.clickable:hover { background: #f7faf8; }
.time-pill { font-weight: 700; font-size: 13px; min-width: 72px; color: var(--text); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; background: #fff; border-radius: 14px; padding: 12px 16px;
  box-shadow: var(--shadow-lg); max-width: 360px; font-weight: 500; border-left: 4px solid var(--green);
  animation: toastIn .25s ease;
}
.toast-error { border-left-color: var(--red); }
.toast-info { border-left-color: var(--sky); }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(34, 48, 43, .45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 1000;
  overflow-y: auto; animation: fadeIn .18s ease;
}
.modal-overlay.out { opacity: 0; transition: opacity .18s; }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: popIn .2s ease; margin: auto 0; }
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Month calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head strong { font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow div { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border: 0; background: transparent; border-radius: 12px; cursor: pointer;
  font: 600 13px var(--font); color: var(--text); position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 2px; transition: background .12s;
}
.cal-cell:hover:not(:disabled) { background: #eef5f1; }
.cal-cell.empty { cursor: default; }
.cal-cell.today .cal-num { color: var(--violet); }
.cal-cell.today::before { content: ''; position: absolute; inset: 3px; border: 1.5px dashed #b5d3c7; border-radius: 10px; }
.cal-cell.selected { background: var(--grad) !important; color: #fff; box-shadow: 0 6px 14px rgba(63, 122, 107, .3); }
.cal-cell.selected .cal-num { color: #fff; }
.cal-cell.selected::before { display: none; }
.cal-cell:disabled { color: #cbd5e1; cursor: not-allowed; }
.cal-dots { display: flex; gap: 2px; height: 6px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.cal-count { position: absolute; top: 3px; right: 5px; font-size: 9px; color: var(--muted); font-weight: 700; }
.cal-cell.selected .cal-count { color: rgba(255, 255, 255, .85); }
.d-fixed { background: var(--violet); } .d-dyn { background: var(--teal); } .d-pend { background: var(--amber); }
.cal-cell.selected .cal-dots i { background: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Slot pills ---------- */
.slot-groups { display: flex; flex-direction: column; gap: 14px; }
.slot-group h5 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.slot {
  border: 1.5px solid #d5e9df; background: #f2f8f4; color: #15803d; border-radius: 10px; padding: 8px 4px;
  font: 600 13px var(--font); cursor: pointer; transition: all .12s; text-align: center;
}
.slot:hover:not(:disabled) { border-color: var(--green); transform: translateY(-1px); }
.slot.active { background: var(--grad-teal); color: #fff; border-color: transparent; box-shadow: 0 6px 14px rgba(95, 163, 140, .3); }
.slot:disabled, .slot.taken { background: #f8fafc; border-color: #eef2f7; color: #cbd5e1; cursor: not-allowed; text-decoration: line-through; }
.slot.past { opacity: .6; }

/* Stepper */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--violet); font-weight: 700; }
.stepper button:hover { background: #eef5f1; }
.stepper button:disabled { color: #cbd5e1; cursor: default; background: transparent; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 30px; overflow: hidden; }
.bar-col:first-child .bar-tip, .bar-col:nth-child(2) .bar-tip { left: 0; transform: translate(0, -100%); }
.bar-col:last-child .bar-tip, .bar-col:nth-last-child(2) .bar-tip { left: auto; right: 0; transform: translate(0, -100%); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; position: relative; }
.bar { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: var(--grad); min-height: 3px; transition: height .5s ease; position: relative; }
.bar-col:hover .bar { filter: brightness(1.08); }
.bar-col .bar-tip { position: absolute; top: -4px; left: 50%; transform: translate(-50%, -100%); background: var(--text); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; }
.bar-col:hover .bar-tip { opacity: 1; }
.bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar-col.is-today .bar-label { color: var(--violet); font-weight: 700; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend b { margin-left: auto; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row .hbar-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; gap: 8px; }
.hbar-track { height: 10px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 99px; }

/* ==========================================================
   ADMIN
   ========================================================== */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 50;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 20px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 13px; background: var(--grad); color: #fff; font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(63, 122, 107, .3); flex-shrink: 0;
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; color: var(--muted);
  font-weight: 600; transition: all .15s;
}
.nav-item:hover { background: var(--soft); color: var(--text); }
.nav-item.active { background: #eef5f1; color: var(--violet); }
.nav-ic { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--pink); color: #fff; font-size: 11px; border-radius: 99px; padding: 1px 7px; font-weight: 700; }
.nav-badge:empty { display: none; }
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.conn { font-size: 12px; color: var(--muted); padding: 6px 8px; background: var(--soft); border-radius: 10px; text-align: center; font-weight: 600; }
.conn.on { background: #e3f2e8; color: #15803d; }

.side-backdrop { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 28px; background: rgba(246, 247, 251, .85);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 40; border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 22px; }
.page-hint { font-size: 13px; color: var(--muted); }
.help-card { background: #fff; border: 1.5px dashed #b5d3c7; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.help-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.help-steps > div { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.help-steps b { display: block; color: var(--text); font-size: 14px; }
.help-steps .n { width: 28px; height: 28px; border-radius: 50%; background: #eceaf6; color: var(--violet); font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-title { display: flex; align-items: center; gap: 10px; }
.step-title .n { width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.choice .c-hint { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; line-height: 1.35; }
.top-actions { display: flex; gap: 8px; }
.menu-btn { display: none; }
.view { padding: 8px 28px 40px; }
.demo-banner {
  margin: 0 28px 12px; padding: 10px 16px; border-radius: 12px; background: linear-gradient(90deg, #f9eedc, #f8e9ed);
  font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi {
  border-radius: var(--radius); padding: 18px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow);
  min-height: 118px; display: flex; flex-direction: column; justify-content: space-between; cursor: default;
}
.kpi.clickable { cursor: pointer; }
.kpi::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .14); right: -30px; top: -40px; }
.kpi::before { content: ''; position: absolute; width: 80px; height: 80px; border-radius: 50%; background: rgba(255, 255, 255, .1); right: 30px; bottom: -40px; }
.kpi .k-label { font-size: 13px; opacity: .9; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.kpi .k-value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.kpi .k-sub { font-size: 12px; opacity: .85; }
.kpi.k1 { background: var(--grad); } .kpi.k2 { background: var(--grad-sky); } .kpi.k3 { background: var(--grad-amber); }
.kpi.k4 { background: var(--grad-lav); } .kpi.k5 { background: var(--grad-pink); }
.kpi.light { background: #fff; color: var(--text); border: 1px solid var(--line); }
.kpi.light::after, .kpi.light::before { background: color-mix(in srgb, var(--c, var(--violet)) 9%, transparent); }
.kpi.light .k-value { color: var(--c, var(--violet)); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.dash-grid > * { min-width: 0; }
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

/* Calendar page */
.cal-layout { display: grid; grid-template-columns: 330px 1fr; gap: 18px; align-items: start; }
.cal-layout > * { min-width: 0; }
.sched-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sched-head h3 { font-size: 17px; flex: 1; min-width: 160px; }
.sched-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 14px; position: relative; }
.sched { display: grid; position: relative; min-width: max-content; }
.sched-corner, .sched-chair { position: sticky; top: 0; background: #fff; z-index: 4; border-bottom: 1px solid var(--line); }
.sched-corner { left: 0; z-index: 5; }
.sched-chair { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-weight: 700; font-size: 13px; border-left: 1px solid var(--line); }
.sched-chair small { color: var(--muted); font-weight: 500; }
.sched-time { position: sticky; left: 0; background: #fff; z-index: 3; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 8px 0 0; text-align: right; border-right: 1px solid var(--line); }
.sched-cell { border-left: 1px solid var(--line); border-bottom: 1px dashed #f0f1f6; cursor: pointer; transition: background .1s; }
.sched-cell:hover { background: #eef5f1; }
.sched-cell:hover::after { content: '+'; display: flex; align-items: center; justify-content: center; height: 100%; color: #8cc0a8; font-weight: 700; font-size: 18px; }
.sched-cell.past { background: repeating-linear-gradient(135deg, #fafafa, #fafafa 6px, #f5f5f7 6px, #f5f5f7 12px); }
.sched-bk {
  margin: 2px 4px; border-radius: 10px; padding: 5px 8px; font-size: 12px; overflow: hidden; cursor: pointer; z-index: 2;
  background: color-mix(in srgb, var(--c) 14%, white); border-left: 4px solid var(--c); color: var(--text);
  transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; min-height: 0;
}
.sched-bk:hover { transform: scale(1.02); box-shadow: 0 6px 16px rgba(0, 0, 0, .1); }
.sched-bk strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.sched-bk small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.sched-bk.fixed { background-image: repeating-linear-gradient(135deg, transparent, transparent 7px, rgba(63, 122, 107, .07) 7px, rgba(63, 122, 107, .07) 14px); }
.sched-bk.st-pending { border-left-style: dashed; outline: 1.5px dashed var(--amber); outline-offset: -1.5px; }
.sched-bk.st-completed { opacity: .7; }
.sched-bk.st-no-show { opacity: .45; text-decoration: line-through; }
.now-line { position: absolute; left: 64px; right: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }

/* Filters bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input { width: auto; min-width: 220px; }
.tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font: 600 13px var(--font); color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 4px 10px rgba(63, 122, 107, .25); }
.tab .count { font-size: 11px; background: rgba(0, 0, 0, .07); border-radius: 99px; padding: 0 6px; }
.tab.active .count { background: rgba(255, 255, 255, .25); }

/* Billing */
.bill-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.bill-summary { position: sticky; top: 84px; }
.receipt {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line);
}
.receipt-head { background: var(--grad); color: #fff; padding: 20px; position: relative; overflow: hidden; }
.receipt-head::after { content: ''; position: absolute; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .12); right: -40px; top: -60px; }
.receipt-head h3 { font-size: 18px; }
.receipt-body { padding: 18px 20px; }
.r-line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; }
.r-line.total { border-top: 2px dashed var(--line); margin-top: 8px; padding-top: 12px; font-size: 18px; font-weight: 800; }
.r-line.total span:last-child { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cust-hint { padding: 12px 14px; border-radius: 12px; background: var(--soft); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cust-hint.new { background: #eef6f1; }
.cust-hint.repeat { background: #eef5f1; }
.chair-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; transition: all .15s; }
.chair-row.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, white); }
.chair-row.off { opacity: .45; }
.chair-ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: color-mix(in srgb, var(--c) 15%, white); flex-shrink: 0; }
.pkg-pick { border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; background: #fff; display: flex; gap: 12px; align-items: center; font-family: var(--font); text-align: left; width: 100%; }
.pkg-pick.active { border-color: var(--violet); background: #eef5f1; }

/* Package / plan / voucher cards */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pkg-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column; }
.pkg-card .pc-head { padding: 16px 18px; color: #fff; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #d0809a)); position: relative; overflow: hidden; }
.pkg-card .pc-head::after { content: ''; position: absolute; width: 110px; height: 110px; border-radius: 50%; background: rgba(255, 255, 255, .15); right: -30px; top: -40px; }
.pkg-card .pc-head h4 { font-size: 17px; }
.pkg-card .pc-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.pkg-card .pc-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.big-num { font-size: 30px; font-weight: 800; line-height: 1; }
.voucher-code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .08em; font-size: 16px; background: rgba(255, 255, 255, .22); padding: 3px 10px; border-radius: 8px; display: inline-block; }

/* Profile */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.stat-tile { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.stat-tile b { display: block; font-size: 18px; }
.stat-tile span { font-size: 12px; color: var(--muted); }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.info-grid .label { display: block; margin-bottom: 2px; }
.bk-hero { border-radius: 14px; padding: 16px; margin-bottom: 16px; background: color-mix(in srgb, var(--c) 12%, white); border-left: 5px solid var(--c); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden; }
.login-card { background: #fff; border-radius: 24px; box-shadow: var(--shadow-lg); padding: 36px 32px; width: 100%; max-width: 380px; text-align: center; position: relative; z-index: 1; }
.login-card .logo { margin: 0 auto 16px; width: 60px; height: 60px; font-size: 26px; border-radius: 18px; }
.pin-input { text-align: center; font-size: 26px !important; letter-spacing: .5em; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; z-index: 0; }

.loading-screen { min-height: 100vh; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: var(--muted); }
.ring { --p: 50; width: 70px; height: 70px; border-radius: 50%; background: conic-gradient(var(--c, var(--violet)) calc(var(--p) * 1%), #eef0f6 0); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ring > div { width: 54px; height: 54px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ring b { font-size: 17px; }
.ring small { font-size: 9px; color: var(--muted); }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #eceaf6; border-top-color: var(--violet); animation: spin .8s linear infinite; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .dash-grid, .bill-layout { grid-template-columns: 1fr; }
  .bill-summary { position: static; }
  .cal-layout { grid-template-columns: 1fr; }
  .dash-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .side-backdrop { position: fixed; inset: 0; background: rgba(34, 48, 43, .35); z-index: 45; display: none; }
  .side-backdrop.show { display: block; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 18px; }
  .top-actions .btn-ghost, .top-actions .btn-soft { display: none; }
  .view { padding: 8px 16px 40px; }
  .demo-banner { margin: 0 16px 12px; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .help-steps { grid-template-columns: 1fr; }
  .page-hint { display: none; }
  .dash-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .info-grid { grid-template-columns: 1fr; }
  .kpi .k-value { font-size: 24px; }
  .filters .input { min-width: 0; width: 100%; }
  .modal-overlay { padding: 12px 8px; }
}

/* ---------- Phone-only helpers ---------- */
.show-m { display: none !important; }
.a-tabbar, .m-savebar { display: none; }
.agenda { display: none; }

@media (max-width: 900px) {
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .menu-btn { display: none; }
  .a-tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .a-tabbar a, .a-tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none;
    font: 700 11px var(--font); color: var(--muted); border-radius: 12px; cursor: pointer;
  }
  .a-tabbar svg { width: 22px; height: 22px; }
  .a-tabbar .active { color: var(--violet); }
  .a-tabbar .bill { color: #fff; background: var(--grad); margin: 0 4px; box-shadow: 0 6px 16px rgba(63, 122, 107, .35); }
  .a-tabbar .bill.active { color: #fff; }
  .a-tabbar .nav-badge { position: absolute; top: 0; right: 18%; margin: 0; font-style: normal; }
  #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); left: 12px; right: 12px; }
  .toast { max-width: none; }
  .topbar .top-actions .btn-primary { display: none; }
  .top-actions .btn-ghost { display: inline-flex; }

  /* calendar: month → day → summary */
  .cal-side { display: contents; }
  .cal-month { order: 1; }
  .cal-day { order: 2; }
  .cal-stats { order: 3; }
  #dView.show-m { display: inline-flex !important; }
  .cal-day.view-list .sched-wrap, .cal-day.view-list .sched-legend { display: none; }
  .cal-day.view-list .agenda { display: flex; }
}

@media (max-width: 700px) {
  .hide-m { display: none !important; }
  .show-m { display: inline-flex !important; }
  div.show-m { display: block !important; }
  .view { padding: 4px 14px 30px; }
  .topbar { padding: 10px 14px; }
  .demo-banner { margin: 0 14px 10px; padding: 8px 12px; font-size: 12px; }
  .demo-banner .btn { padding: 3px 8px; }
  .card { padding: 16px; border-radius: 18px; }
  .page-head { margin-bottom: 14px; }
  .page-head h2 { font-size: 20px; }
  .page-head .row .btn { flex: 1; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { min-height: 92px; padding: 14px; border-radius: 16px; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi .k-label { font-size: 12px; }
  .kpi .k-value { font-size: 22px; }
  .kpi .k-sub { font-size: 11px; }
  .help-card { padding: 14px; }

  .filters { gap: 8px; }
  .filters > .btn { flex: 1; }
  .filters .grow { display: none; }
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* tables become stacked cards */
  .table.rtable thead { display: none; }
  .table.rtable, .table.rtable tbody { display: block; }
  .table.rtable tr { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .table.rtable td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 1px 0; border: 0; text-align: right; font-size: 13px; }
  .table.rtable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex-shrink: 0; }
  .table.rtable td.m-head { order: -1; display: block; text-align: left; padding-bottom: 6px; }
  .table.rtable td.m-head::before, .table.rtable td.m-actions::before { display: none; }
  .table.rtable td.m-actions { justify-content: flex-end; padding-top: 6px; }
  .table.rtable td.m-actions:empty { display: none; }
  .table.rtable td > span.small { display: inline; }
  .table.rtable td:not(.m-head):not(.m-actions) { justify-content: flex-start; }
  .table.rtable td:not(.m-head):not(.m-actions)::before { margin-right: auto; }
  .list-item { gap: 10px; }
  .list-item .time-pill { min-width: 58px; font-size: 12px; }
  .list-item .chip { font-size: 11px; padding: 2px 8px; }
  .list-item b { font-size: 14px; }
  .list-item .small { font-size: 12px; }
  .page-head .row .btn { white-space: nowrap; padding: 10px 12px; }

  /* billing */
  .choice-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .choice { padding: 10px; border-radius: 12px; }
  .choice .c-ic { font-size: 18px; }
  .choice .c-title { font-size: 13px; }
  .choice .c-hint { font-size: 11px; }
  .choice.active::after { width: 18px; height: 18px; top: 6px; right: 6px; font-size: 11px; }
  #fTypes .choice:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .chair-row { padding: 8px 10px; gap: 10px; }
  .chair-ic { width: 36px; height: 36px; font-size: 18px; }
  .input.lg { font-size: 16px; padding: 11px 12px; }
  .bill-summary #fSave { display: none; }
  .m-savebar {
    display: flex; align-items: center; gap: 12px; position: fixed; left: 10px; right: 10px; z-index: 55;
    bottom: calc(76px + env(safe-area-inset-bottom)); background: #fff; border-radius: 18px; padding: 10px 10px 10px 18px;
    box-shadow: 0 12px 30px rgba(34, 48, 43, .2); border: 1px solid var(--line);
  }
  .m-savebar small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
  .m-savebar b { font-size: 20px; }
  .m-savebar .btn { padding: 12px 22px; }
  .bill-layout { padding-bottom: 80px; }

  /* calendar */
  .sched-head { gap: 6px; }
  .sched-head h3 { order: -1; flex-basis: 100%; font-size: 16px; }
  .sched-head .btn-primary { margin-left: auto; }
  .cal-cell { border-radius: 10px; font-size: 12px; }
  .cal-count { display: none; }

  /* settings / misc */
  .row.wrap > .btn, .row.wrap > label.btn { white-space: normal; text-align: center; max-width: 100%; }
  .dash-grid[style] { grid-template-columns: 1fr !important; }
  .stat-tiles { gap: 8px; }
  .profile-head h2 { font-size: 20px; }
  .tile-grid { grid-template-columns: 1fr; }

  /* modals become bottom sheets */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.lg, .modal.sm { max-width: none; border-radius: 22px 22px 0 0; max-height: 92vh; display: flex; flex-direction: column; animation: sheetIn .25s ease; margin: 0; }
  .modal-head { padding: 14px 18px; position: relative; }
  .modal-head::before { content: ''; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 2px; background: #d9dfd9; }
  .modal-body { padding: 16px 18px; overflow-y: auto; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .modal-foot .grow { display: none; }
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; }
}
