/* Studio Lila: customer pages and back office. Mobile first (usable from 320 px), 44 px targets,
   tokens on :root with a dark set, visible focus, reduced motion = still. No inline styles (strict CSP). */
:root {
  --bg: #f7f4ef; --surface: #ffffff; --ink: #1c1a24; --muted: #545066;
  --brand: #6b2f6b; --brand-ink: #ffffff; --accent: #8a4b08; --accent-soft: #fbeedd;
  --line: #d8d2c8; --ok: #1d6b3a; --err: #a4231b; --focus: #8a4b08; --danger: #a4231b;
  --radius: 14px; --gutter: 16px;
  --field: #857f91; /* edges of inputs and choices: 3.9:1 on white, 3.5:1 on the page (WCAG 1.4.11 needs 3) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15131b; --surface: #1f1c28; --ink: #f1eef6; --muted: #b7b0c6;
    --brand: #d6a1d6; --brand-ink: #1b1220; --accent: #f0b35a; --accent-soft: #3a2a14;
    --line: #3a3548; --ok: #6fd08f; --err: #ff8a80; --focus: #f0b35a; --danger: #ff8a80; --field: #7c7690;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15131b; --surface: #1f1c28; --ink: #f1eef6; --muted: #b7b0c6;
  --brand: #d6a1d6; --brand-ink: #1b1220; --accent: #f0b35a; --accent-soft: #3a2a14;
  --line: #3a3548; --ok: #6fd08f; --err: #ff8a80; --focus: #f0b35a; --danger: #ff8a80; --field: #7c7690;
  color-scheme: dark;
}

* { box-sizing: border-box; }
p, ul, ol, dl { margin: 0 0 16px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-wrap: anywhere; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
[tabindex="-1"]:focus-visible { outline: 3px solid var(--focus); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--ink); padding: 12px 16px; z-index: 9; border: 2px solid var(--focus); }
.skip:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }

.demo-bar { margin: 0; padding: 8px var(--gutter); background: var(--accent-soft); color: var(--ink); font-size: 16px; text-align: center; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px var(--gutter); max-width: 1040px; margin: 0 auto; }
.brand { display: flex; gap: 12px; align-items: center; font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; min-height: 44px; }
.logo-bg { fill: var(--brand); }
.logo-key { stroke: var(--accent-soft); stroke-width: 3; fill: none; stroke-linecap: round; }
.tools { display: flex; gap: 8px; }
.chip { min-width: 44px; min-height: 44px; padding: 0 8px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }

main { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter) 24px; }
section { padding: 8px 0; }
.hero { padding: 20px 0 8px; }
h1 { font-size: clamp(28px, 7vw, 46px); line-height: 1.12; margin: 8px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: clamp(22px, 5vw, 28px); line-height: 1.2; margin: 0 0 12px; }
h3 { margin: 20px 0 8px; font-size: 19px; }
.lead { font-size: 19px; color: var(--muted); max-width: 42em; }
.hint { color: var(--muted); font-size: 16px; margin: 8px 0 0; max-width: 68ch; }
.prose { max-width: 46em; }
.prose h2 { margin-top: 24px; font-size: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--brand); background: var(--surface); color: var(--brand); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.linkbtn { background: none; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font: inherit; font-size: 15px; padding: 8px 12px; min-height: 44px; cursor: pointer; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px var(--gutter); margin: 16px 0; }
.panel.narrow { max-width: 460px; margin: 24px auto; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
fieldset.inner { margin: 16px 0 0; }
legend { font-weight: 700; font-size: 18px; margin-bottom: 8px; padding: 0; }
fieldset.inner > legend { font-size: 16px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea { width: 100%; min-height: 48px; padding: 12px 12px; border: 1px solid var(--field); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; max-width: 100%; }
/* one height for every single-line field, so a date, a select and a text field standing side by side share a centre line */
input, select { height: 48px; padding-top: 8px; padding-bottom: 8px; }
textarea { min-height: 96px; resize: vertical; }
details.fold > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex: none; border: 2px solid var(--brand); border-radius: 999px; color: var(--brand); font-weight: 700; font-size: 20px; line-height: 1; }
details.fold[open] > summary::before { content: "\2212"; }
details.fold > summary h2 { margin: 0; }
details.fold[open] > summary { margin-bottom: 8px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border: 2px solid var(--err); }
.field-err { color: var(--err); font-weight: 600; font-size: 15px; margin: 4px 0 0; }
.field-err::before { content: "! "; }
label.check { display: flex; align-items: flex-start; gap: 12px; font-weight: 400; margin-top: 16px; min-height: 44px; }
label.check input { width: 24px; min-height: 24px; height: 24px; flex: none; margin: 2px 0 0; padding: 0; accent-color: var(--brand); }

/* native radio buttons styled as choices (arrow keys move between them) */
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.wide-opts { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.opt { overflow-wrap: normal; word-break: normal; } /* names and services wrap between words, never inside one */
.hero .hint { margin: 0 0 16px; max-width: none; }
p:has(> button[hidden]:only-child) { display: none; } /* a paragraph that only holds a hidden button leaves no gap */
.opt { display: flex; align-items: center; gap: 8px; margin: 0; min-height: 48px; padding: 8px 12px; border: 1px solid var(--field); border-radius: 10px; background: var(--bg); font-weight: 600; cursor: pointer; line-height: 1.3; }
.opt input { width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; flex: none; accent-color: var(--brand); }
.opt small { font-weight: 400; color: var(--muted); }
.opt:has(input:checked) { border: 2px solid var(--brand); background: var(--surface); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt:has(input[aria-invalid="true"]) { border-color: var(--err); }
.opts-inline { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.opts-inline label.check { margin-top: 4px; }

.msg { min-height: 1.5em; font-weight: 600; margin: 12px 0 0; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 2px; }

.foot { max-width: 1040px; margin: 0 auto; padding: 24px var(--gutter) 40px; color: var(--muted); font-size: 16px; }
.foot p { margin: 0 0 8px; }
.made { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.made a { min-height: 44px; display: inline-flex; align-items: center; }
.sig { font-style: italic; }

/* chat */
.log { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.log li { padding: 12px 12px; border-radius: 12px; max-width: min(92%, 62ch); line-height: 1.5; }
.log .say-bot { background: var(--bg); border: 1px solid var(--line); }
.log .say-user { background: var(--brand); color: var(--brand-ink); justify-self: end; }
.log .say-sys { color: var(--muted); font-size: 14px; justify-self: center; }
.chatbox .log { max-height: 60vh; overflow-y: auto; }
.sayrow { display: flex; gap: 8px; align-items: stretch; }
.sayrow input { flex: 1; min-width: 0; }
.sayrow .btn { flex: none; }
.tries { color: var(--muted); font-size: 15px; }
.tries p { margin: 8px 0; }
.try-row { display: flex; flex-wrap: wrap; gap: 8px; }
.three, .two { display: grid; grid-template-columns: 1fr; gap: 0 12px; align-items: end; }
/* a tick box standing beside fields sits on the fields' line, not on their labels' line */
.three > label.check, .two > label.check { min-height: 48px; align-items: center; margin: 12px 0 0; }
.three > label.check input, .two > label.check input { margin: 0; }

/* back office: the menu is one line that scrolls sideways on phones and tablets, and a side column from 1024 px */
.adm-nav { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter); display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.adm-nav ul { list-style: none; margin: 0; padding: 4px 0; display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.adm-nav li { flex: none; }
.adm-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.adm-nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.adm-nav .logout { margin-left: auto; flex: none; }
.adm-nav .linkbtn { white-space: nowrap; min-width: 96px; } /* as wide as the two chips above it, so the right-hand column has one left and one right edge */
@media (min-width: 1024px) {
  body.admin:not(.auth) { display: grid; grid-template-columns: 264px minmax(0, 1fr); align-items: start; max-width: 1280px; margin: 0 auto; }
  body.admin:not(.auth) > .top { grid-column: 1 / -1; max-width: none; width: 100%; margin: 0; }
  body.admin:not(.auth) > .adm-nav { grid-column: 1; flex-direction: column; align-items: stretch; max-width: none; margin: 0; padding: 0 8px 24px var(--gutter); border-bottom: 0; overflow: visible; position: sticky; top: 0; }
  body.admin:not(.auth) > .adm-nav ul { flex-direction: column; gap: 4px; flex: none; overflow: visible; padding: 0; }
  body.admin:not(.auth) > .adm-nav a { display: flex; white-space: normal; padding: 8px 12px; }
  body.admin:not(.auth) > .adm-nav .logout { margin: 16px 0 0; }
  body.admin:not(.auth) > .adm-nav .linkbtn { width: 100%; text-align: left; }
  body.admin:not(.auth) > main { grid-column: 2; max-width: 960px; width: 100%; margin: 0; padding: 0 var(--gutter) 48px 24px; }
  body.admin:not(.auth) > main > h1 { margin-top: 0; }
}
.kpis { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px var(--gutter); margin: 0 0 12px; }
.card p { margin: 4px 0; }
.kpi h2.kpi-label { color: var(--muted); font-weight: 600; font-size: 16px; margin: 0; }
.kpi-val { font-size: clamp(30px, 7vw, 40px); font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0 !important; }
.kpi-sub { color: var(--muted); font-size: 15px; }
.note-card { font-weight: 600; }
.list { display: grid; gap: 0; }
.card-title { font-weight: 600; }
.bk, .ho, .st-block, [class*="msg-"] { border-left: 6px solid var(--line); }
.st-booked { border-left-color: var(--brand); } .st-came { border-left-color: var(--ok); } .st-no_show { border-left-color: var(--err); }
.st-cancelled { border-left-color: var(--muted); opacity: .85; } .st-block { border-left-style: dashed; border-left-color: var(--muted); }
.ho-open { border-left-color: var(--accent); } .ho-done { border-left-color: var(--ok); }
.msg-due { border-left-color: var(--accent); } .msg-planned { border-left-color: var(--brand); }
.q { font-weight: 600; }
.cb-req { background: var(--accent-soft); border-radius: 8px; padding: 12px 16px; }
.chip-st { display: inline-block; font-size: 14px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.msgbody { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; }
.facts-list { display: grid; grid-template-columns: 1fr; gap: 2px 12px; margin: 0; }
.facts-list dt { font-weight: 700; color: var(--muted); margin-top: 8px; }
.facts-list dd { margin: 0; }
.hist { padding-left: 20px; font-size: 15px; }
.hist li { margin: 4px 0; }
.filters { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.seg legend { width: 100%; }
.seg label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 999px; margin: 0; background: var(--surface); }
.seg label:has(input:checked) { border: 2px solid var(--brand); }
.seg input { width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; accent-color: var(--brand); }
.row-set { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 0 0 12px; }
.row-set > legend { padding: 0 8px; font-size: 16px; }
/* export rows: the name in one column, CSV and JSON each in their own, so the buttons line up down the list */
.dl-list { list-style: none; padding: 0; display: grid; gap: 12px; max-width: 520px; }
.dl-list li { display: grid; grid-template-columns: minmax(0, 1fr) 96px 96px; align-items: center; gap: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.rep { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
table.rep caption { text-align: left; font-weight: 700; padding: 8px; }
table.rep th, table.rep td { text-align: left; padding: 8px; border-top: 1px solid var(--line); vertical-align: top; }

@media (min-width: 720px) {
  .panel { padding: 24px 28px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .three { grid-template-columns: repeat(3, 1fr); }
  .two { grid-template-columns: repeat(2, 1fr); }
  /* each filter is label / field / hint on three shared rows, so a long label or a hint never pushes one field off the line */
  .filters { grid-template-columns: repeat(3, 1fr); align-items: start; }
  .filters > .field { display: grid; grid-template-rows: subgrid; grid-row: span 3; }
  .filters > .field > label { align-self: end; }
  .filters .btn-row, .filters .seg { grid-column: 1 / -1; }
  .facts-list { grid-template-columns: max-content 1fr; }
  .facts-list dt { margin-top: 0; }
}
