/* Thandeka Installs — one stylesheet, no framework, no build step.
   Order: tokens → base → layout → components → admin → utilities.
   Everything is sized from the spacing scale so the whole site keeps one rhythm. */

/* ---------- Tokens ---------- */
:root {
  --brand: #7a2e5c;
  --brand-dark: #5c2045;
  --brand-tint: #f7eef3;
  --brand-tint-2: #efdfe8;
  --ink: #1d1d1f;
  --muted: #5f5560;
  --line: #e4d6de;
  --line-strong: #b9a5b0;
  --bg: #ffffff;
  --ok-bg: #e3f4e8; --ok-ink: #17552e;
  --warn-bg: #fdecc8; --warn-ink: #7a4a00;
  --bad-bg: #fdeaea; --bad-ink: #a4161a;

  /* 4px scale: every margin, padding and gap comes from here */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 12px; --radius-sm: 8px; --radius-pill: 999px;
  --tap: 48px;
  --shadow-sm: 0 1px 2px rgba(45, 20, 35, 0.06);
  --shadow: 0 2px 10px rgba(45, 20, 35, 0.08);
  --ring: 0 0 0 3px rgba(122, 46, 92, 0.25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.55 var(--font);
  display: flex; flex-direction: column; min-height: 100vh;
}
h1, h2, h3 { color: var(--brand); line-height: 1.25; margin: 0 0 var(--s3); text-wrap: balance; }
h1 { font-size: 1.65rem; margin-top: var(--s2); }
h2 { font-size: 1.2rem; margin-top: var(--s5); }
h3 { font-size: 1.05rem; margin-top: var(--s4); color: var(--ink); }
p { margin: 0 0 var(--s3); }
ul, ol { margin: 0 0 var(--s3); padding-left: var(--s5); }
li { margin: var(--s1) 0; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
img { max-width: 100%; height: auto; }
code { font-family: ui-monospace, "DejaVu Sans Mono", monospace; font-size: 0.9em; background: var(--brand-tint); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .button, input, select, textarea, .card { transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
}

/* ---------- Layout ---------- */
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: var(--s4); top: var(--s2); z-index: 20; background: #fff; padding: var(--s2) var(--s3); border-radius: var(--radius-sm); }
.site-header {
  background: var(--brand); color: #fff; padding: var(--s3) var(--s4);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s5);
}
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: 0.2px; }
/* The public header's own nav; the admin nav has its own rules further down. */
.site-header nav:not(.admin-nav) { display: flex; gap: var(--s4); }
.site-header nav:not(.admin-nav) a { color: #fff; text-decoration: none; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.site-header nav:not(.admin-nav) a:hover, .brand:hover { color: #f3d7e6; }
.container { width: 100%; max-width: 900px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s6); flex: 1; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.9rem; padding: var(--s5) var(--s4); border-top: 1px solid var(--line); }
section + section { margin-top: var(--s6); }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5); border: 2px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; font: 600 1rem/1 var(--font); text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.button:hover { background: var(--brand-dark); color: #fff; }
.button:active { transform: translateY(1px); }
.button.secondary { background: #fff; color: var(--brand); border-color: var(--brand); box-shadow: none; }
.button.secondary:hover { background: var(--brand-tint); color: var(--brand-dark); }
.button.danger { background: var(--bad-ink); }
.button.danger:hover { background: #7d0f12; }
.button[disabled], .button[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.small-btn { min-height: 40px; padding: 0 var(--s3); font-size: 0.9rem; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; min-height: 40px; }
.link-button:hover { color: var(--brand-dark); }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: stretch; }
.actions > .button, .actions > form > .button { flex: 1 1 9rem; }
.actions > form { display: flex; flex: 1 1 9rem; }
@media (min-width: 560px) { .actions > .button, .actions > form, .actions > form > .button { flex: 0 0 auto; } }
.actions .button { margin-top: 0; }
.inline { display: inline; }

/* ---------- Panels and cards ---------- */
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--s4); margin: var(--s4) 0; box-shadow: var(--shadow-sm);
}
.panel > h2:first-of-type, .panel > h3:first-of-type, .panel > *:first-child { margin-top: 0; }
.narrow { max-width: 420px; }
.hero { background: var(--brand-tint); border-radius: var(--radius); padding: var(--s5); margin-bottom: var(--s6); }
.hero h1 { margin-top: 0; font-size: 1.9rem; }
.hero p { font-size: 1.05rem; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s4); }
.card {
  display: flex; flex-direction: column; gap: var(--s1); margin: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card h3 { margin: var(--s2) 0 0; color: var(--ink); font-size: 1.05rem; }
.card p { margin: 0; }
.card p + .button, .card .button { margin-top: auto; }
.card > * { min-width: 0; }
.card-link { color: inherit; text-decoration: none; }
.card-link:hover h3 { color: var(--brand); text-decoration: underline; }
.card img, .gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--brand-tint); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); margin: var(--s3) 0 var(--s4); }
.description { margin: var(--s4) 0; }
.description p:last-child { margin-bottom: 0; }
.meta { color: var(--muted); margin: var(--s1) 0 var(--s3); }

/* ---------- Status colours ---------- */
.badge { display: inline-block; font-size: 0.82rem; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--brand-tint-2); color: var(--brand-dark); }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.success, .error-box, .notice, .preview-banner { border-radius: var(--radius); padding: var(--s3) var(--s4); margin: 0 0 var(--s4); }
.success { background: var(--ok-bg); color: var(--ok-ink); }
.error-box { background: var(--bad-bg); color: var(--bad-ink); font-weight: 600; }
.error-box ul { font-weight: 400; }
.notice { background: var(--brand-tint); }
.notice h2 { margin-top: 0; }
.preview-banner { background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.error { color: var(--bad-ink); font-weight: 600; margin: var(--s1) 0 0; }
.status { font-size: 1.05rem; }

/* ---------- Forms: every control styled the same way ---------- */
label { display: block; font-weight: 600; margin: var(--s4) 0 var(--s1); }
input, select, textarea {
  width: 100%; min-width: 0; max-width: 100%; min-height: var(--tap);
  padding: var(--s2) var(--s3); font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line-strong); border-radius: var(--radius-sm); appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[aria-invalid="true"] { border-color: var(--bad-ink); }
input::placeholder, textarea::placeholder { color: #8b8090; }
/* Native date and time pickers keep their behaviour; only the frame is ours. */
input[type="date"], input[type="time"] { min-height: var(--tap); }
::-webkit-calendar-picker-indicator { opacity: 0.65; cursor: pointer; }
select {
  padding-right: var(--s6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%237a2e5c'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s3) center; background-size: 20px;
}
input[type="file"] { padding: var(--s2); border-style: dashed; cursor: pointer; }
input[type="file"]::file-selector-button {
  min-height: 36px; margin-right: var(--s3); padding: 0 var(--s4); cursor: pointer;
  border: 2px solid var(--brand); border-radius: var(--radius-sm); background: #fff; color: var(--brand); font: 600 0.95rem var(--font);
}
input[type="file"]:hover::file-selector-button { background: var(--brand-tint); }

/* Tick boxes and radios: drawn by us, still real controls for the keyboard and screen readers. */
input[type="checkbox"], input[type="radio"] {
  width: 24px; height: 24px; min-height: 24px; flex: 0 0 auto; margin: 0; padding: 0;
  border: 2px solid var(--line-strong); background: #fff; cursor: pointer; display: grid; place-content: center;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::after, input[type="radio"]::after { content: ""; transform: scale(0); transition: transform .1s ease-in-out; }
input[type="checkbox"]::after { width: 12px; height: 7px; border: 3px solid #fff; border-top: 0; border-right: 0; rotate: -45deg; margin-top: -3px; }
input[type="radio"]::after { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--brand); border-color: var(--brand); }
input[type="checkbox"]:checked::after, input[type="radio"]:checked::after { transform: scale(1); }
.check { display: flex; align-items: center; gap: var(--s3); font-weight: 600; min-height: var(--tap); margin: var(--s2) 0; cursor: pointer; }
.check.small { font-weight: 400; font-size: 0.92rem; }
fieldset { border: 0; padding: 0; margin: var(--s4) 0 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: var(--s2); }
form .button { margin-top: var(--s4); }
form .actions .button { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 var(--s4); }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { margin-top: var(--s4); min-height: 65px; }

/* Times to choose from: big, obvious targets */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: var(--s2); }
.slot {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); margin: 0; padding: 0 var(--s2); cursor: pointer; font-weight: 600;
  border: 2px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff;
}
.slot:hover { border-color: var(--brand); background: var(--brand-tint); }
.slot:has(input:checked) { border-color: var(--brand); background: var(--brand); color: #fff; }
.slot:has(input:checked) input { border-color: #fff; background: #fff; }
.slot:has(input:checked) input::after { background: var(--brand); }
.slot:focus-within { box-shadow: var(--ring); }

/* ---------- Facts list ---------- */
.facts { display: grid; grid-template-columns: minmax(6rem, max-content) 1fr; align-items: baseline; gap: var(--s2) var(--s4); margin: 0 0 var(--s4); }
.facts dt { font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- The main action on a service or product page ---------- */
.action-top, .action-sticky { display: flex; align-items: center; justify-content: space-between; gap: var(--s3) var(--s4); }
.action-top { flex-wrap: wrap; background: var(--brand-tint); border-radius: var(--radius); padding: var(--s4); margin: var(--s3) 0 var(--s5); }
.action-sticky {
  flex-wrap: nowrap; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 12px rgba(45, 20, 35, 0.12);
  padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom, 0px));
}
.action-price { margin: 0; font-size: 1.25rem; min-width: 0; }
.action-sticky .action-price { font-size: 1rem; line-height: 1.25; }
.action-sticky .action-price .small { display: block; font-size: 0.8rem; }
.action-top .button, .action-sticky .button { margin-top: 0; }
.action-sticky .button { flex: 0 0 auto; }
body:has(.action-sticky) .site-footer { padding-bottom: 96px; }
@media (min-width: 700px) {
  .action-sticky { display: none; }
  body:has(.action-sticky) .site-footer { padding-bottom: var(--s5); }
}

/* ---------- Admin ---------- */
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s3); width: 100%; margin-top: var(--s1); }
.admin-nav a, .admin-nav .link-button {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 0.95rem; white-space: nowrap; line-height: 1;
  min-height: 36px; display: flex; align-items: center; margin: 0; padding: 0 var(--s2); border-radius: var(--radius-sm);
}
.admin-nav a:hover, .admin-nav .link-button:hover { color: #fff; background: rgba(255, 255, 255, 0.14); }
.admin-nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.18); }
@media (min-width: 760px) { .admin-nav { width: auto; margin-top: 0; justify-content: flex-end; } }

.tiles { list-style: none; padding: 0; margin: 0 0 var(--s5); display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.tiles a {
  display: block; padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--brand-tint);
  color: var(--ink); text-decoration: none; border: 1px solid transparent;
}
.tiles a:hover { border-color: var(--brand); background: var(--brand-tint-2); }
.tiles strong { display: block; font-size: 1.8rem; line-height: 1.1; color: var(--brand); margin-bottom: var(--s1); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.count { display: inline-block; min-width: 26px; text-align: center; background: var(--brand); color: #fff; border-radius: var(--radius-pill); font-size: 0.9rem; padding: 2px var(--s2); vertical-align: middle; }

.plain { list-style: none; padding: 0; margin: 0; }
.queue, .unpaid, .results { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.queue .panel, .unpaid .panel, .results .panel { margin: 0; }
.queue p, .unpaid p, .results p, .agenda p { margin: 0 0 var(--s1); overflow-wrap: anywhere; }
.queue p:last-of-type, .unpaid p:last-of-type, .results p:last-of-type, .agenda p:last-of-type { margin-bottom: 0; }
.queue .badge, .unpaid .badge, .results .badge { margin: var(--s1) 0; }
.queue .actions, .unpaid .actions { margin-top: var(--s3); }
.queue-head { font-size: 1.05rem; }
.unpaid .overdue { border-left: 5px solid #d98a00; background: #fffaf2; }
.unpaid .check { margin-top: 0; }
.agenda { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.agenda .panel { margin: 0; }
.agenda .time { color: var(--brand); font-size: 1.05rem; display: inline-block; min-width: 10.5ch; }
.week > li { border-bottom: 1px solid var(--line); padding: var(--s2) 0; }
.week > li:last-child { border-bottom: 0; }
.week p { margin: 0; }
.indent { padding-left: var(--s4); }
.filters, .filters-form { margin-bottom: var(--s4); }
.filters a[aria-current="page"] { font-weight: 700; text-decoration: none; }
.sticky-actions { position: sticky; top: 0; z-index: 2; background: #fff; padding: var(--s2) 0; border-bottom: 1px solid var(--line); margin-bottom: var(--s3); }
.timeline { padding-left: var(--s5); }
.timeline li, .activity > li { margin: var(--s1) 0; }
.activity { list-style: none; padding: 0; }
.activity > li { border-bottom: 1px solid var(--line); padding: var(--s2) 0; }
.activity p { margin: 2px 0; overflow-wrap: anywhere; }
.day { border-bottom: 1px solid var(--line); padding: var(--s2) 0 var(--s3); margin: 0; }
.day legend { font-size: 1.05rem; color: var(--brand); }
.photos { display: grid; gap: var(--s3); }
.photos li { display: grid; grid-template-columns: 96px 1fr; gap: var(--s3); align-items: start; border-bottom: 1px solid var(--line); padding-bottom: var(--s3); margin: 0; }
.photos img { width: 96px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.photo-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s2); }
.photo-actions .button { margin-top: 0; }
details.panel summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }

.hub { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4); }
.hub .panel { margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.hub h2 { margin: 0; font-size: 1.15rem; }
.hub h2 a { text-decoration: none; }
.hub h2 a:hover { text-decoration: underline; }
.hub p { margin: 0; }
.hub .button { margin-top: auto; align-self: flex-start; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin-bottom: var(--s4); }
th, td { border: 1px solid var(--line); padding: var(--s2) var(--s3); text-align: left; vertical-align: top; }
th { background: var(--brand-tint); color: var(--brand-dark); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.back { margin: 0 0 var(--s3); }
.back a { font-weight: 600; text-decoration: none; }
.back a:hover { text-decoration: underline; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s4); margin: var(--s5) 0 0; }

/* Show/hide button inside a password field. The wrapper is added by /js/reveal-password.js. */
.reveal { position: relative; display: block; }
.reveal input { padding-right: var(--s7); }
.reveal-toggle {
  position: absolute; top: 0; right: 0; width: var(--s7); height: 100%;
  display: grid; place-content: center; padding: 0; cursor: pointer;
  border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm);
}
.reveal-toggle svg { width: 22px; height: 22px; fill: currentColor; }
.reveal-toggle:hover { color: var(--brand); }
.reveal-toggle:focus-visible { outline: none; box-shadow: var(--ring); color: var(--brand); }
.reveal-toggle[aria-pressed="true"] { color: var(--brand); }
