/* ==========================================================================
   Time Wellness Centre — staff area
   ========================================================================== */
@font-face { font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-display: swap; font-weight: 100 900; src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2"); }

:root {
  --accent: #1f5c4e;
  --accent-dark: #174a3e;
  --accent-soft: #e8f0ed;
  --ink: #14201c;
  --ink-2: #35443f;
  --muted: #5d6b66;
  --line: #e1e6e3;
  --bg: #f4f5f3;
  --panel: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;
  --ok: #18794e;
  --ok-soft: #e6f4ec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(20 32 28 / .06), 0 6px 20px -10px rgb(20 32 28 / .15);
  --sidebar-w: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  /* Status colours (diary) */
  --st-booked: #3b6fb6; --st-confirmed: #1f5c4e; --st-arrived: #b7791f; --st-in_treatment: #7b4bb3;
  --st-completed: #5d6b66; --st-cancelled: #b42318; --st-dna: #7a1f1f; --st-pending: #b7791f; --st-accepted: #18794e; --st-declined: #b42318;
  --st-new: #3b6fb6; --st-read: #5d6b66; --st-closed: #5d6b66; --st-approved: #18794e;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--ink-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .6em; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 1.85rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 1em; }
code { font-size: .85em; background: #eef1ef; padding: .1em .35em; border-radius: 5px; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -60px; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 999; }
.skip-link:focus { top: 1rem; color: #fff; }
.muted { color: var(--muted); }
.hint { font-size: .85rem; color: var(--muted); margin: .3rem 0 0; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); font-weight: 600; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: 1.25rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: .5rem; justify-items: start; }

/* ------------------------------------------------------------- shell */
.admin-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: #14201c; color: #c6cfcb; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 1rem .75rem; }
.sidebar__brand { padding: .5rem .5rem 1.25rem; }
.sidebar__brand img { width: 128px; }
.sidebar__label { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #7f8c87; margin: 1.1rem .65rem .4rem; font-weight: 650; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li a { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border-radius: 8px; color: #d7dfdb; text-decoration: none; font-weight: 500; font-size: .93rem; }
.sidebar li a:hover { background: rgb(255 255 255 / .07); color: #fff; }
.sidebar li a[aria-current="page"] { background: rgb(255 255 255 / .12); color: #fff; box-shadow: inset 3px 0 0 #6fc3a8; }
.sidebar li a span:first-of-type { flex: 1; }
.sidebar__foot { margin-top: auto; padding: 1rem .65rem 0; border-top: 1px solid rgb(255 255 255 / .08); }
.sidebar__foot a { color: #aeb9b4; text-decoration: none; font-size: .88rem; display: flex; gap: .5rem; align-items: center; }
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: .75rem; padding: .65rem 1.5rem; background: rgb(255 255 255 / .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar__search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.topbar__search > .icon { position: absolute; left: .75rem; color: var(--muted); }
.topbar__search input { width: 100%; padding: .55rem .75rem .55rem 2.3rem; border: 1px solid var(--line); border-radius: 999px; background: #f6f7f6; font: inherit; }
.topbar__search input:focus { background: #fff; border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgb(31 92 78 / .15); }
.topbar__spacer { flex: 1; }
.quicksearch { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .35rem; z-index: 60; }
.quicksearch a { display: block; padding: .5rem .65rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.quicksearch a:hover, .quicksearch a:focus { background: var(--accent-soft); }
.quicksearch small { display: block; color: var(--muted); }
.sidebar-toggle { display: none; }
.usermenu { position: relative; margin-left: auto; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: .55rem; cursor: pointer; padding: .25rem .4rem; border-radius: 999px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: #f0f2f1; }
.usermenu__name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; color: var(--ink); font-size: .9rem; }
.usermenu__name small { font-weight: 400; color: var(--muted); font-size: .78rem; }
.usermenu__panel { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .4rem; min-width: 230px; z-index: 70; }
.usermenu__panel a, .usermenu__panel button { display: flex; width: 100%; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.usermenu__panel a:hover, .usermenu__panel button:hover { background: #f0f2f1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.admin-content { padding: 1.5rem; max-width: 1500px; width: 100%; }
.is-diary .admin-content { max-width: none; }

/* ------------------------------------------------------- components */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .15rem; }
.page-head p { margin: 0; }
.breadcrumb { font-size: .85rem; margin: 0 0 .25rem !important; }
.breadcrumb a { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 2px rgb(20 32 28 / .04); margin-bottom: 1.25rem; }
.card--narrow { max-width: 640px; }
.card--highlight { border-color: #e5c27a; background: #fffaf0; }
.card--danger { border-color: #f1c4bf; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card__head h2 { margin: 0; }
.card__head a { font-size: .88rem; text-decoration: none; display: inline-flex; gap: .3rem; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-2 > .card { margin-bottom: 1.25rem; }
.grid-2--wide-left { grid-template-columns: 1.4fr 1fr; gap: 1.25rem; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.dash-grid > .card { margin: 0; }
.dash-grid > .card:first-child { grid-column: 1 / -1; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.stat-card span { font-size: .82rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; }
.stat-card strong { font-family: var(--serif); font-weight: 500; font-size: 2rem; color: var(--ink); line-height: 1.2; }
.stat-card small { color: var(--muted); font-size: .8rem; }
.stat-card--link:hover { border-color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; background: #f7f8f7; border-radius: var(--radius-sm); margin: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list__item { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list__item:last-child { border-bottom: 0; }
.list__item a { text-decoration: none; color: inherit; flex: 1; }
.list__item strong { display: block; color: var(--ink); }
.list__item small { display: block; color: var(--muted); font-size: .85rem; }
.list--compact li { padding: .3rem 0; font-size: .85rem; border-bottom: 1px dashed var(--line); }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.quick-link { display: flex; gap: .5rem; align-items: center; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); font-weight: 600; }
.quick-link:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem; border-radius: 8px; border: 1px solid transparent; font: 600 .92rem/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); color: #fff; }
.btn--outline { background: #fff; color: var(--ink); border-color: #cdd5d1; }
.btn--outline:hover { border-color: var(--ink); color: var(--ink); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #8f1c13; color: #fff; }
.btn--danger-outline { background: #fff; color: var(--danger); border-color: #f0c2bc; }
.btn--danger-outline:hover { background: var(--danger-soft); }
.btn--sm { min-height: 34px; padding: .35rem .75rem; font-size: .85rem; }
.btn--lg { min-height: 48px; padding: .75rem 1.4rem; font-size: 1rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.icon-btn { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--ink); }
.seg { display: inline-flex; background: #eef1ef; border-radius: 9px; padding: 3px; gap: 2px; }
.seg__btn { border: 0; background: none; padding: .4rem .85rem; border-radius: 7px; font: 600 .85rem var(--font); color: var(--muted); cursor: pointer; }
.seg__btn[aria-pressed="true"], .seg__btn[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.seg--full { display: flex; margin-bottom: 1rem; }
.seg--full .seg__btn { flex: 1; }
.file-btn { position: relative; }

/* Badges & status */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 650; background: #eef1ef; color: var(--ink-2); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--count { background: #e06c3f; color: #fff; min-width: 1.4rem; justify-content: center; }
.status { --st: var(--muted); display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 650; color: var(--st); background: color-mix(in srgb, var(--st) 11%, #fff); white-space: nowrap; }
.status::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--st); }
.status--booked { --st: var(--st-booked); } .status--confirmed { --st: var(--st-confirmed); } .status--arrived { --st: var(--st-arrived); }
.status--in_treatment { --st: var(--st-in_treatment); } .status--completed { --st: var(--st-completed); } .status--cancelled { --st: var(--st-cancelled); }
.status--dna { --st: var(--st-dna); } .status--pending { --st: var(--st-pending); } .status--accepted { --st: var(--st-accepted); }
.status--declined { --st: var(--st-declined); } .status--new { --st: var(--st-new); } .status--read { --st: var(--st-read); } .status--closed { --st: var(--st-closed); }
.swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; background: var(--c, var(--accent)); margin-right: .45rem; vertical-align: -.05em; }
.swatch--lg { width: 1rem; height: 2.6rem; border-radius: 4px; }

/* Alerts & toasts */
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.alert p { margin: 0; }
.alert ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.alert .icon { margin-top: .15em; }
.alert--success { background: var(--ok-soft); color: var(--ok); }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--warning { background: var(--warn-soft); color: var(--warn); }
.alert--info { background: var(--accent-soft); color: var(--accent-dark); }
.toast-region { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 400; }
.toast { display: flex; gap: .55rem; align-items: center; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: 420px; transform: translateY(12px); opacity: 0; transition: all .25s; }
.toast.is-visible { transform: none; opacity: 1; }
.toast--success .icon { color: #7ee0b5; }
.toast--error { background: #7a1f1f; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: #fafbfa; }
.table--hover tbody tr:hover { background: #f8faf9; }
.table--compact th, .table--compact td { padding: .4rem .55rem; font-size: .84rem; }
.table tr.is-muted td { opacity: .55; }
.table tr.is-unread td { font-weight: 650; }
.table tr.is-warn td { background: #fff8ec; }
.table .actions { text-align: right; }
.audit-details { max-width: 420px; word-break: break-word; font-family: ui-monospace, monospace; font-size: .78rem; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1rem; }

/* Forms */
.form { display: grid; gap: 1rem; }
.form--inline { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.form--inline label { font-weight: 600; font-size: .88rem; }
.form--tight { display: flex; gap: .35rem; margin: .4rem 0; }
.field { display: grid; gap: .3rem; align-content: start; }
.field label, .label { font-weight: 600; font-size: .88rem; color: var(--ink); }
.field--wide { grid-column: 1 / -1; }
.field--short { max-width: 320px; }
.field--end { align-self: end; }
.grow { flex: 1; }
.req { color: var(--danger); }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea, .input {
  width: 100%; min-height: 40px; padding: .5rem .7rem; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d2ce; border-radius: 8px;
}
input[type=color] { width: 64px; height: 40px; padding: 2px; border: 1px solid #c9d2ce; border-radius: 8px; background: #fff; }
textarea { resize: vertical; min-height: 80px; }
textarea.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(31 92 78 / .15); }
.input--sm { min-height: 34px !important; padding: .3rem .55rem !important; width: auto !important; font-size: .88rem !important; }
.input--code { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; max-width: 240px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .83rem; font-weight: 600; margin: 0; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-size: .92rem; cursor: pointer; font-weight: 500; }
.check input { width: 18px; height: 18px; margin-top: .15em; accent-color: var(--accent); flex: none; }
.check--sm { font-size: .85rem; align-items: center; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; display: grid; gap: .75rem; }
.fieldset legend { font-weight: 700; color: var(--ink); padding: 0 .35rem; }
.form-actions { display: flex; gap: .6rem; padding-top: .5rem; }
.form-actions--sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 1.25rem 0 .75rem; z-index: 5; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters .field { min-width: 160px; }
.quick-ranges { display: flex; gap: .75rem; font-size: .85rem; padding-bottom: .55rem; }
.input-prefix { display: flex; }
.input-prefix span { padding: .5rem .6rem; background: #eef1ef; border: 1px solid #c9d2ce; border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); font-size: .88rem; }
.input-prefix input { border-radius: 0 8px 8px 0 !important; }
.danger-zone { margin-top: 1rem; display: flex; justify-content: flex-end; }
.strength { font-size: .82rem; font-weight: 600; min-height: 1.2em; }
.strength[data-score="0"], .strength[data-score="1"] { color: var(--danger); }
.strength[data-score="2"] { color: var(--warn); }
.strength[data-score="3"], .strength[data-score="4"], .strength[data-score="5"] { color: var(--ok); }
.html-editor { border: 1px solid #c9d2ce; border-radius: 8px; overflow: hidden; }
.html-editor textarea { border: 0 !important; border-radius: 0 !important; }
.html-editor__bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: #f3f5f4; border-bottom: 1px solid var(--line); }
.html-editor__bar button { border: 0; background: none; padding: .3rem .55rem; border-radius: 5px; cursor: pointer; font: 600 .82rem var(--font); color: var(--ink); display: inline-flex; gap: .25rem; align-items: center; }
.html-editor__bar button:hover { background: #fff; }
.image-field__row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.image-field__preview { width: 160px; height: 110px; border-radius: 8px; overflow: hidden; background: #eef1ef; display: grid; place-items: center; border: 1px solid var(--line); }
.image-field__preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field__controls { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; flex: 1; }
.image-field__controls .hint { flex-basis: 100%; }
.repeater-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: .6rem; align-items: start; padding: .75rem; background: #f8f9f8; border-radius: 8px; margin-bottom: .5rem; }
.repeater-row label { font-size: .8rem; font-weight: 600; display: grid; gap: .2rem; }
.repeater-row__tools { display: flex; gap: .3rem; padding-top: 1.2rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.perm-grid .card { margin: 0; }
.perm-code { font-size: .72rem; color: var(--muted); background: none; }
.hours-edit input[type=time] { max-width: 130px; }
.hours-edit tr.is-off th { color: var(--muted); }
.checks-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checks-list li { display: flex; gap: .4rem; align-items: center; }
.checks-list .ok .icon { color: var(--ok); } .checks-list .fail .icon { color: var(--danger); } .checks-list .off { color: var(--muted); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; color: var(--ink); word-break: break-word; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.codes code { font-size: 1rem; padding: .35rem .6rem; display: block; text-align: center; }
.setup-steps { display: grid; gap: 1.25rem; padding-left: 1.2rem; }
.qr { width: 220px; height: 220px; margin: .75rem 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.qr svg { width: 100%; height: 100%; }
.secret { font-size: 1rem; letter-spacing: .08em; }
.clinical-note__head { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; color: var(--muted); border-bottom: 1px dashed var(--line); padding-bottom: .5rem; margin-bottom: .75rem; }
.clinical-note__head strong { color: var(--ink); }
.clinical-note__body { white-space: normal; color: var(--ink); }
.version { border-left: 3px solid var(--line); padding-left: .75rem; margin: .75rem 0; font-size: .9rem; }
.edit-box, .cancel-box { margin-top: .75rem; }
.edit-box > summary, .cancel-box > summary { list-style: none; display: inline-flex; }
.edit-box > summary::-webkit-details-marker, .cancel-box > summary::-webkit-details-marker { display: none; }
.edit-box[open] > summary, .cancel-box[open] > summary { margin-bottom: .75rem; }
.cancel-box { display: grid; gap: .5rem; }
.history summary { cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--ink); padding: .4rem 0; }
.history ul { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.history li { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: .5rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); align-items: center; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; max-height: 70vh; overflow-y: auto; padding: .25rem; }
.media-grid--page { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: none; }
.media-item { border: 2px solid transparent; border-radius: 10px; background: #f3f5f4; padding: 4px; cursor: pointer; text-align: left; font: inherit; }
.media-item:hover, .media-item:focus { border-color: var(--accent); }
.media-item img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; width: 100%; }
.media-item span { display: block; font-size: .72rem; color: var(--muted); margin-top: .25rem; word-break: break-all; }
.media-card { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.media-card img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.media-card figcaption { padding: .6rem; display: grid; gap: .3rem; font-size: .8rem; }
.media-card code { word-break: break-all; font-size: .72rem; }
.bar { display: inline-block; width: 120px; height: 8px; background: #eef1ef; border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: .35rem; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.chart { display: flex; align-items: flex-end; gap: .35rem; height: 220px; padding-top: 1.25rem; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .2rem; }
.chart__bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.chart__val { font-size: .72rem; font-weight: 650; color: var(--ink); }
.chart__label { font-size: .7rem; color: var(--muted); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgb(15 22 20 / .5); display: grid; place-items: center; z-index: 500; padding: 1rem; }
.modal__box { background: #fff; border-radius: var(--radius); padding: 1.5rem; max-width: 460px; width: 100%; box-shadow: 0 30px 60px -20px rgb(0 0 0 / .4); }
.modal__box--wide { max-width: 900px; }
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal__head h2 { margin: 0; }
.idle-warning { position: fixed; inset: 0; background: rgb(15 22 20 / .55); display: grid; place-items: center; z-index: 600; padding: 1rem; }
.idle-warning[hidden] { display: none; }
.idle-warning__box { background: #fff; border-radius: var(--radius); padding: 1.5rem; max-width: 420px; }

/* ------------------------------------------------------------- diary */
.diary { display: flex; flex-direction: column; gap: .75rem; height: calc(100vh - 110px); min-height: 560px; }
.diary-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; align-items: center; }
.diary-toolbar__nav, .diary-toolbar__filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.diary-title { font-size: 1.35rem; margin: 0 .5rem; min-width: 14ch; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem .5rem; padding: 0; margin: 0; }
.legend li { margin: 0; }
.legend__block { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--muted); padding: .15rem .55rem; border-radius: 999px; background: repeating-linear-gradient(135deg, #e5e8e6 0 6px, #f2f4f3 6px 12px); }
.diary-scroll { flex: 1; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); position: relative; }
.diary-grid { --time-w: 58px; --col-w: minmax(170px, 1fr); min-width: calc(var(--time-w) + var(--cols, 1) * 170px); }
.dg-head { display: grid; grid-template-columns: var(--time-w) repeat(var(--cols, 1), var(--col-w)); position: sticky; top: 0; z-index: 6; background: #fff; border-bottom: 1px solid var(--line); }
.dg-corner { border-right: 1px solid var(--line); position: sticky; left: 0; background: #fff; z-index: 7; }
.dg-colhead { padding: .55rem .65rem; border-right: 1px solid var(--line); font-size: .86rem; display: flex; flex-direction: column; border-top: 3px solid var(--c, var(--accent)); }
.dg-colhead strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-colhead small { color: var(--muted); }
.dg-body { display: grid; grid-template-columns: var(--time-w) repeat(var(--cols, 1), var(--col-w)); position: relative; height: var(--grid-h); }
.dg-times { position: sticky; left: 0; z-index: 5; background: #fff; border-right: 1px solid var(--line); height: var(--grid-h); }
.dg-time { position: absolute; left: 0; right: 0; font-size: .72rem; color: var(--muted); text-align: right; padding-right: .5rem; transform: translateY(-.55em); font-variant-numeric: tabular-nums; }
.dg-time:first-child { transform: none; }
.dg-col {
  position: relative; border-right: 1px solid var(--line); height: var(--grid-h); cursor: copy;
  background-color: #eceeed;
  background-image: repeating-linear-gradient(135deg, rgb(0 0 0 / .025) 0 6px, transparent 6px 12px);
}
.dg-col::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image: linear-gradient(to bottom, #dfe4e1 1px, transparent 1px), linear-gradient(to bottom, #f0f2f1 1px, transparent 1px);
  background-size: 100% var(--hour-h), 100% var(--slot-h); }
.dg-col:not([data-editable]) { cursor: default; }
.dg-avail { position: absolute; left: 0; right: 0; background: #fff; z-index: 0; }
.dg-block { position: absolute; left: 3px; right: 3px; z-index: 2; border: 1px dashed #a9b3ae; border-radius: 6px; background: repeating-linear-gradient(135deg, #e4e7e5 0 6px, #eff1f0 6px 12px); color: var(--muted); font: 600 .74rem var(--font); text-align: left; padding: .2rem .4rem; overflow: hidden; cursor: pointer; }
.dg-block span { background: rgb(255 255 255 / .8); padding: 0 .25rem; border-radius: 3px; }
.dg-appt {
  --st: var(--st-booked);
  position: absolute; left: 3px; right: 3px; z-index: 3; text-align: left; border: 0; border-radius: 7px; padding: .25rem .45rem .25rem .6rem;
  background: color-mix(in srgb, var(--svc) 13%, #fff); color: var(--ink); font: 500 .76rem/1.3 var(--font); overflow: hidden; cursor: pointer;
  box-shadow: inset 4px 0 0 var(--svc), 0 1px 2px rgb(0 0 0 / .08); display: flex; flex-direction: column; gap: 1px;
  transition: box-shadow .15s, transform .15s;
}
.dg-appt:hover { box-shadow: inset 4px 0 0 var(--svc), 0 4px 14px -4px rgb(0 0 0 / .25); z-index: 4; }
.dg-appt.is-editable { cursor: grab; }
.dg-appt.is-dragging { cursor: grabbing; opacity: .85; box-shadow: inset 4px 0 0 var(--svc), 0 12px 24px -6px rgb(0 0 0 / .35); z-index: 10; touch-action: none; }
.dg-appt__name { font-weight: 700; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-appt__meta { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-appt__status { position: absolute; right: .35rem; top: .25rem; font-size: .66rem; font-weight: 700; color: var(--st); background: #fff; border-radius: 999px; padding: 0 .4rem; box-shadow: 0 0 0 1px color-mix(in srgb, var(--st) 30%, #fff); }
.dg-appt__resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.dg-appt__resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 3px; margin-left: -11px; border-radius: 2px; background: rgb(0 0 0 / .2); }
.dg-appt.status--booked { --st: var(--st-booked); } .dg-appt.status--confirmed { --st: var(--st-confirmed); }
.dg-appt.status--arrived { --st: var(--st-arrived); box-shadow: inset 4px 0 0 var(--svc), 0 0 0 2px var(--st-arrived); }
.dg-appt.status--in_treatment { --st: var(--st-in_treatment); box-shadow: inset 4px 0 0 var(--svc), 0 0 0 2px var(--st-in_treatment); }
.dg-appt.status--completed { --st: var(--st-completed); opacity: .7; }
.dg-appt.status--cancelled { --st: var(--st-cancelled); opacity: .55; text-decoration: line-through; background: #fff; }
.dg-appt.status--dna { --st: var(--st-dna); background: #fbeeee; }
.dg-appt:not(.status--booked):not(.status--confirmed) .dg-appt__resize { display: none; }
.dg-appt abbr { text-decoration: none; color: #3b6fb6; }
.dg-now { position: absolute; left: var(--time-w); right: 0; height: 2px; background: #e0533d; z-index: 8; pointer-events: none; }
.dg-now--col { right: auto; left: calc(var(--time-w) + var(--col-start, 0) * ((100% - var(--time-w)) / var(--cols, 1))); width: calc((100% - var(--time-w)) / var(--cols, 1)); }
.dg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e0533d; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 300; }
.drawer__backdrop { position: absolute; inset: 0; background: rgb(15 22 20 / .35); opacity: 0; transition: opacity .25s; }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: #fff; box-shadow: -20px 0 40px -20px rgb(0 0 0 / .35); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .3s cubic-bezier(.16, 1, .3, 1); outline: none; }
.drawer.is-open .drawer__backdrop { opacity: 1; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0; font-size: 1.2rem; }
.drawer__body { padding: 1.25rem; overflow-y: auto; flex: 1; display: grid; gap: 1rem; align-content: start; }
.drawer__actions { display: flex; gap: .5rem; position: sticky; bottom: -1.25rem; background: #fff; padding: .75rem 0; border-top: 1px solid var(--line); }
body.drawer-open { overflow: hidden; }
.appt-head { display: flex; gap: .85rem; align-items: flex-start; }
.appt-head > div { flex: 1; }
.appt-head p { margin: 0; }
.appt-head__svc { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.appt-head__when { color: var(--ink); }
.status-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.note-box { background: #fffaf0; border: 1px solid #f0dfb8; border-radius: 8px; padding: .65rem .85rem; font-size: .9rem; }
.note-box p { margin: .25rem 0 0; }
.patient-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: .75rem; }
.patient-card__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.patient-card__head h3 { margin: 0; font-size: 1.1rem; }
.pp-alert { background: var(--warn-soft); color: var(--warn); padding: .45rem .65rem; border-radius: 8px; font-weight: 600; font-size: .88rem; margin: .35rem 0 0; display: flex; gap: .4rem; align-items: center; }
.clinical { border-top: 1px solid var(--line); padding-top: .75rem; display: grid; gap: .6rem; }
.clinical h4 { margin: 0; }
.clinical-note { margin: 0; }
.clinical .clinical-note { border-left: 3px solid var(--accent); padding: .25rem .75rem; font-size: .88rem; }
.clinical .clinical-note p { margin: .25rem 0 0; }
.patient-picker { position: relative; }
.pp-results { display: grid; gap: .25rem; margin-top: .35rem; max-height: 260px; overflow-y: auto; }
.pp-option { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .5rem .7rem; cursor: pointer; font: inherit; }
.pp-option:hover, .pp-option:focus { border-color: var(--accent); background: var(--accent-soft); }
.pp-option strong, .pp-selected strong { display: block; color: var(--ink); }
.pp-option small, .pp-selected small { color: var(--muted); }
.pp-selected { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 8px; padding: .65rem .8rem; }
.pp-new { margin-top: .75rem; padding: .85rem; background: #f6f8f7; border-radius: 8px; display: grid; gap: .6rem; }
.form-errors:empty { display: none; }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1rem; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-page { text-align: center; padding: 4rem 1rem; }
.error-page .code { font-family: var(--serif); font-size: 5rem; color: var(--accent); opacity: .2; margin: 0; line-height: 1; }
.error-page .btn-row { justify-content: center; }
.lead { font-size: 1.1rem; color: var(--muted); }

/* ------------------------------------------------- auth & install */
.auth-body { background: radial-gradient(1200px 600px at 80% -10%, #dbe8e3, transparent), var(--bg); min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth { width: 100%; max-width: 420px; }
.auth__card { background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 30px 60px -30px rgb(20 32 28 / .35); border: 1px solid var(--line); }
.auth__card h1 { font-size: 1.5rem; margin-bottom: .75rem; }
.auth__logo { width: 140px; margin-bottom: 1.5rem; }
.auth__foot { text-align: center; font-size: .82rem; color: var(--muted); margin-top: 1rem; display: flex; gap: .35rem; justify-content: center; align-items: center; }
.install { width: 100%; max-width: 820px; padding: 2rem 0; }
.install__logo { width: 200px; margin: 0 auto 1.5rem; }
.install .card { padding: 2rem; }
.install fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.25rem; }
.install legend { font-weight: 700; color: var(--ink); padding: 0 .35rem; }
.install label { display: grid; gap: .3rem; font-weight: 600; font-size: .88rem; color: var(--ink); margin-bottom: .75rem; }
.checks { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .3rem; font-size: .9rem; }
.checks li { display: flex; gap: .5rem; align-items: baseline; }
.checks li span { width: 1.2rem; font-weight: 800; }
.checks .ok span { color: var(--ok); } .checks .fail span, .checks .fail { color: var(--danger); } .checks .warn span { color: var(--warn); }
.keys { background: #14201c; color: #d8f3e8; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

/* ------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .dash-grid, .grid-2, .grid-2--wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 200; transform: translateX(-100%); transition: transform .25s; }
  body.sidebar-open .sidebar { transform: none; box-shadow: 20px 0 40px rgb(0 0 0 / .3); }
  .sidebar-toggle { display: inline-grid; }
  .usermenu__name { display: none; }
  .topbar { padding: .6rem .75rem; }
  .topbar .btn span { display: none; }
  .admin-content { padding: 1rem; }
  .repeater-row { grid-template-columns: 1fr; }
  .diary { height: calc(100vh - 90px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .btn, .tabs, .toast-region { display: none !important; }
  .admin-shell { display: block; }
  body { background: #fff; }
}
