:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #e2e6ec;
  --line-strong: #c9d0da;
  --text: #111826;
  --muted: #566073;
  --faint: #8a93a3;
  --primary: #0b62c4;
  --primary-soft: #e7f0fb;
  --on-primary: #ffffff;
  --danger: #c42b2b;
  --danger-soft: #fdecec;
  --ok: #157a3c;
  --ok-soft: #e5f4ea;
  --warn: #9a5800;
  --warn-soft: #fdf1df;
  --toast-action: #8cc4ff;
  --shadow-1: 0 1px 2px rgba(17, 24, 38, .05);
  --shadow-2: 0 10px 30px rgba(17, 24, 38, .18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1319;
    --surface: #161c24;
    --surface-2: #1e2631;
    --line: #283241;
    --line-strong: #3b4757;
    --text: #e8edf3;
    --muted: #a3aebd;
    --faint: #748092;
    --primary: #5ea5f6;
    --primary-soft: #1a2d46;
    --on-primary: #0a1421;
    --danger: #f27a7a;
    --danger-soft: #3b1d21;
    --ok: #5fcb8c;
    --ok-soft: #173327;
    --warn: #f0b45c;
    --warn-soft: #3a2b15;
    --toast-action: #0b62c4;
    --shadow-1: none;
    --shadow-2: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1319;
  --surface: #161c24;
  --surface-2: #1e2631;
  --line: #283241;
  --line-strong: #3b4757;
  --text: #e8edf3;
  --muted: #a3aebd;
  --faint: #748092;
  --primary: #5ea5f6;
  --primary-soft: #1a2d46;
  --on-primary: #0a1421;
  --danger: #f27a7a;
  --danger-soft: #3b1d21;
  --ok: #5fcb8c;
  --ok-soft: #173327;
  --warn: #f0b45c;
  --warn-soft: #3a2b15;
  --toast-action: #0b62c4;
  --shadow-1: none;
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.has-sheet { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, .title:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }
h1, h2, h3, h4 { line-height: 1.25; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.center { text-align: center; }

/* ---------- header ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar-row { display: flex; align-items: center; gap: 2px; padding: 8px 10px 6px; }
.title {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 10px;
  cursor: pointer;
}
.title:hover { background: var(--surface-2); }
.dept { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-text { font-size: 18px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-jump { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; }
@media (pointer: fine) { .date-jump { pointer-events: none; } }
.grow { flex: 1; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); }
.nav-arrow { width: 34px; }
.pill {
  flex: none;
  height: 34px;
  margin-left: 4px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.pill.is-today { color: var(--faint); border-color: var(--line); }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 8px 0 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
}
.tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs button.on { color: var(--primary); }
.tabs .i { width: 23px; height: 23px; }

.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; max-width: 720px; margin: 0 auto; padding: 0 8px 6px; }
.strip:empty, .filters:empty { display: none; }
.sday { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border-radius: 12px; }
.sday small { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.sday b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-size: 17px; font-weight: 600; }
.sday.today b { color: var(--primary); }
.sday.sel b { background: var(--primary); color: var(--on-primary); }
.sday i { width: 5px; height: 5px; border-radius: 50%; }
.sday i.has { background: var(--faint); }
.sday.sel i.has { background: var(--primary); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 12px 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.dot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* ---------- schedule ---------- */

.view { max-width: 720px; margin: 0 auto; padding: 12px 12px calc(150px + env(safe-area-inset-bottom)); }
.summary { margin: 2px 4px 10px; font-size: 14px; font-weight: 500; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }

.appt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  overflow: hidden;
  padding: 12px 14px 12px 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-1);
}
.appt::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.appt:hover { border-color: var(--line-strong); }
.appt-time, .sres-date { display: flex; flex-direction: column; flex: none; min-width: 46px; padding-left: 2px; font-variant-numeric: tabular-nums; }
.appt-time b { font-size: 16px; font-weight: 650; }
.appt-time small, .sres-date small { font-size: 13px; color: var(--faint); }
.sres-date { min-width: 92px; font-size: 14px; font-weight: 600; }
.appt-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.appt-name { font-size: 16.5px; font-weight: 600; overflow-wrap: anywhere; }
.appt-name small { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.appt-meta { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 13.5px; color: var(--muted); }
.appt-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.appt-meta .i { width: 14px; height: 14px; color: var(--faint); }
.cat .dot { width: 8px; height: 8px; }
.appt.st-done { opacity: .72; }
.st-cancelled .appt-name, .st-cancelled .mini-name, .mrow.st-cancelled { text-decoration: line-through; color: var(--faint); }

.badge {
  flex: none;
  align-self: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.st-scheduled { background: var(--primary-soft); color: var(--primary); }
.badge.st-arrived { background: var(--warn-soft); color: var(--warn); }
.badge.st-done { background: var(--ok-soft); color: var(--ok); }
.badge.st-cancelled { background: var(--danger-soft); color: var(--danger); }

.now { position: relative; height: 0; margin: 4px 0 4px 4px; border-top: 2px solid var(--danger); }
.now span {
  position: absolute;
  left: 0;
  top: -11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 16px; text-align: center; color: var(--muted); }
.empty p { margin: 0; font-size: 16px; }
.empty .big { width: 44px; height: 44px; stroke-width: 1.5; color: var(--faint); }

.week { display: flex; flex-direction: column; gap: 10px; }
.wday { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.wday-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.wday-head b { font-size: 16px; color: var(--text); }
.wday.today .wday-head, .wday.today .wday-head b { color: var(--primary); }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.wday-list { display: flex; flex-direction: column; padding: 0 6px 6px; }
.wday-list .none { display: none; }
.wday:has(.none) .wday-head { padding-block: 8px; }
.mini {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 8px 8px 16px;
  text-align: left;
  border-radius: 10px;
}
.mini::before { content: ""; position: absolute; left: 6px; top: 9px; bottom: 9px; width: 4px; border-radius: 2px; background: var(--c); }
.mini:hover { background: var(--surface-2); }
.mini b { min-width: 42px; font-size: 14px; font-variant-numeric: tabular-nums; }
.mini-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.mini small { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--faint); }

.month { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.mhead { display: grid; grid-template-columns: repeat(7, 1fr); padding: 8px 0 6px; border-bottom: 1px solid var(--line); text-align: center; font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mcell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 60px;
  padding: 5px 2px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.mcell:nth-child(7n) { border-right: 0; }
.mcell:nth-last-child(-n + 7) { border-bottom: 0; }
.mcell:hover { background: var(--surface-2); }
.mnum { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 14.5px; font-weight: 550; }
.mcell.out .mnum { color: var(--faint); }
.mcell.today .mnum { color: var(--primary); font-weight: 700; }
.mcell.sel .mnum { background: var(--primary); color: var(--on-primary); }
.mcount { padding: 0 7px; border-radius: 999px; background: var(--surface-2); font-size: 11.5px; font-weight: 700; color: var(--muted); }
.mlist { display: none; }
.month-day { margin-top: 18px; }
.month-day .empty { padding: 24px 16px; }

.group { margin: 22px 4px 8px; font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.month-day .group { margin-top: 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 14px;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-box input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: none; box-shadow: none !important; font-size: 17px; }
.results > .hint { padding: 28px 12px; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px 0 16px;
  border-radius: 16px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15.5px;
  font-weight: 650;
  box-shadow: var(--shadow-2);
}
.fab .i { width: 22px; height: 22px; stroke-width: 2.4; }

@keyframes in-l { from { opacity: .2; transform: translateX(26px); } }
@keyframes in-r { from { opacity: .2; transform: translateX(-26px); } }
.view.slide-l { animation: in-l .2s ease-out; }
.view.slide-r { animation: in-r .2s ease-out; }

/* ---------- sheets ---------- */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.sheet-wrap.open { pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: rgba(8, 12, 18, .45); opacity: 0; transition: opacity .2s; }
.sheet-wrap.open .backdrop { opacity: 1; }
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 20px - env(safe-area-inset-top));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-2);
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.instant .sheet, .sheet-wrap.instant .backdrop { transition: none; }
.sheet-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 16px 10px 4px 20px; }
.grip { position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-strong); }
.sheet-head h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 650; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px calc(20px + env(safe-area-inset-bottom)); }
.detail-sheet .sheet-head { padding-bottom: 0; }
.sheet-body > .field { margin-top: 18px; }
[data-view="search"] .nav-arrow { visibility: hidden; }

/* ---------- forms ---------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.form + .form { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.form h4 { margin: 0; font-size: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-size: 14px; font-weight: 600; color: var(--muted); }
.field em { font-style: normal; font-weight: 400; color: var(--faint); }
input, select, textarea {
  width: 100%;
  min-width: 0;
  height: 48px;
  margin: 0;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
}
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; line-height: 46px; }
input::-webkit-date-and-time-value { text-align: left; }
textarea { height: auto; padding: 12px 14px; line-height: 1.45; resize: vertical; }
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.chips.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-input { display: flex; align-items: center; gap: 8px; margin-top: 2px; color: var(--muted); }
.inline-input input { width: 110px; }
.input-row { display: flex; gap: 8px; }
.input-row .btn { flex: none; }
.form-error { margin: 0; font-size: 14.5px; color: var(--danger); }
.form-error:empty { display: none; }
.form-actions {
  position: sticky;
  bottom: calc(-20px - env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  margin: 0 -20px calc(-20px - env(safe-area-inset-bottom));
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.form-actions .btn { flex: 1; }
.pw { position: relative; display: block; }
.pw input { padding-right: 84px; }
.pw .text-btn { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); }
.field .hint { font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .i { width: 18px; height: 18px; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 14.5px; font-weight: 600; color: var(--primary); }
.text-btn .i { width: 17px; height: 17px; }

.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 12px; }
.seg button { flex: 1; min-width: 0; height: 40px; padding: 0 6px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(17, 24, 38, .12); }
.seg.small { flex: none; }
.seg.small button { flex: none; height: 32px; padding: 0 10px; font-size: 13.5px; }
.status-seg button { flex: 1 1 auto; padding: 0 4px; font-size: 13.5px; text-overflow: clip; }
.status-seg button.on.st-scheduled { color: var(--primary); }
.status-seg button.on.st-arrived { color: var(--warn); }
.status-seg button.on.st-done { color: var(--ok); }
.status-seg button.on.st-cancelled { color: var(--danger); }

/* ---------- appointment details ---------- */

.d-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--c) 15%, var(--surface));
}
.tag .dot { width: 8px; height: 8px; }
.d-name { margin: 10px 0 2px; font-size: 24px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.facts { display: flex; flex-direction: column; margin: 8px 0 16px; }
.fact { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 11px 0; text-align: left; font-size: 15.5px; border-bottom: 1px solid var(--line); }
.fact .i { margin-top: 1px; color: var(--faint); }
.fact small { margin-left: 4px; color: var(--muted); font-size: 13.5px; }
@media (hover: hover) { .fact.link:hover span { text-decoration: underline; } }
.fact.notes span { white-space: pre-wrap; overflow-wrap: anywhere; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.d-actions .btn { flex: 1 1 auto; }
.d-history h4 { margin: 20px 0 8px; font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.hist { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.hist b { font-weight: 600; color: var(--text); }
.hist time { margin-left: 4px; white-space: nowrap; color: var(--faint); }

/* ---------- menu, people, settings ---------- */

.me-card { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; min-width: 0; }
.me-card > span:last-child { min-width: 0; }
.me-card b { display: block; font-size: 17px; }
.me-card small { display: block; font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}
.menu { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.menu-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 8px 2px; text-align: left; border-bottom: 1px solid var(--line); cursor: pointer; }
.menu-row > span { flex: 1; min-width: 0; font-weight: 550; }
.menu-row small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.menu-row > .i { color: var(--muted); }
.menu-row .chev { width: 18px; color: var(--faint); }
.menu-row.danger, .menu-row.danger > .i { color: var(--danger); }
.menu-row.static { cursor: default; }
.install-hint { margin-top: 12px; }
.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background .15s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus { box-shadow: 0 0 0 3px var(--primary-soft); }

.people { display: flex; flex-direction: column; margin: 14px 0 0; padding: 0; list-style: none; }
.person { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 2px; text-align: left; border-bottom: 1px solid var(--line); }
.person .avatar { width: 40px; height: 40px; font-size: 14px; }
.p-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.p-main b small { font-weight: 400; color: var(--muted); }
.p-main > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.p-main > small.p-status { color: var(--faint); }
.person.s-disabled { opacity: .55; }
.role-tag { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.role-tag.r-admin { background: var(--primary-soft); color: var(--primary); }
.role-tag.r-editor { background: var(--ok-soft); color: var(--ok); }
.role-card { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; }
.role-card + .role-card { margin-top: 8px; }
.role-card input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  padding: 0;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none !important;
}
.role-card input:checked { border: 6px solid var(--primary); }
.role-card b { display: block; }
.role-card small { font-size: 13.5px; color: var(--muted); }
.role-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.linkbox { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.linkbox h4 { margin: 0; font-size: 16px; }
.linkbox input { font-size: 14px; }
.link-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.link-actions .btn { flex: 1 1 auto; }
.cat-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; padding: 0; list-style: none; }
.cat-list li { display: flex; align-items: center; gap: 8px; }
.doc-list input { flex: 1; }
.doc-count { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.new-doctor { margin-top: 6px; }
.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; }
.check-row input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); }
.check-row span { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.check-row small { font-weight: 400; font-size: 13px; color: var(--muted); }
.swatch { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.cat-list li.palette { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.swatch.small { width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; }

/* ---------- sign in ---------- */

.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top)) 16px 24px; }
.auth-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 400px; padding: 28px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-1); }
.auth-logo { align-self: center; border-radius: 14px; }
.auth h1 { margin: 0; text-align: center; font-size: 22px; }
.loading { min-height: 100dvh; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(142px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { font-weight: 700; color: var(--toast-action); white-space: nowrap; }

/* ---------- access requests, test copy ---------- */

.center-btn { align-self: center; }
.tabs button { position: relative; }
.tabs button.has-dot::after { content: ""; position: absolute; top: 6px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.menu-row small.new { color: var(--danger); font-weight: 600; }
.people-head { padding: 14px 2px 4px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.role-tag.r-pending { background: var(--warn-soft); color: var(--warn); }
@media (min-width: 900px) { .tabs button.has-dot::after { top: 4px; left: 24px; } }
.test-bar { display: block; padding: 6px 16px; text-align: center; font-size: 13px; font-weight: 600; color: var(--warn); background: var(--warn-soft); text-decoration: none; }

/* ---------- dictation costs (owners) ---------- */

.u-big { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 16px; background: var(--surface-2); }
.u-big small { font-size: 13px; font-weight: 600; color: var(--muted); }
.u-big b { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.u-big span { font-size: 14px; color: var(--muted); }
.u-head { margin: 20px 0 4px; font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.u-list { margin: 0; padding: 0; list-style: none; }
.u-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.u-row > span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.u-row small { font-size: 13px; color: var(--muted); }
.u-cost { font-variant-numeric: tabular-nums; }
.u-note { margin-top: 16px; font-size: 13px; }

/* ---------- dictation ---------- */

.voice { display: flex; flex-direction: column; gap: 6px; margin-bottom: 2px; }
.voice-row { display: flex; gap: 8px; }
.voice-btn { flex: 1; min-width: 0; justify-content: flex-start; min-height: 52px; background: var(--primary-soft); border-color: transparent; color: var(--primary); transition: box-shadow .1s; }
.voice-btn:hover { background: var(--primary-soft); filter: brightness(.98); }
.voice-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.voice-btn .i { width: 20px; height: 20px; }
.voice-lang { flex: none; min-height: 52px; min-width: 56px; padding: 0 10px; font-size: 14px; color: var(--muted); }
.voice-said, .voice-msg { margin: 0; font-size: 14px; color: var(--muted); }
.voice-said { color: var(--text); font-style: italic; }
.voice-said:empty, .voice-msg:empty, .mic-msg:empty { display: none; }
.with-mic { position: relative; display: block; }
.with-mic textarea { padding-right: 50px; }
.mic-btn { position: absolute; right: 4px; bottom: 6px; color: var(--primary); transition: box-shadow .1s; }
[data-state="listening"].voice-btn, [data-state="listening"].mic-btn {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: 0 0 0 calc(var(--lvl, 0) * 7px) var(--danger-soft);
}
[data-state="starting"] .i, [data-state="working"] .i { animation: pulse 1s ease-in-out infinite; }
.i.solid { fill: currentColor; }
@keyframes pulse { 50% { opacity: .3; } }
/* What dictation filled in, until it's changed by hand. */
.field.filled :is(input, select, textarea), .field.filled .chip.on { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.setting-row { border-top: 1px solid var(--line); cursor: pointer; }

/* ---------- computers ---------- */

@media (min-width: 640px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { max-height: min(88vh, 920px); border-radius: 20px; opacity: 0; transform: translateY(14px) scale(.985); transition: transform .2s, opacity .2s; }
  .sheet-wrap.open .sheet { opacity: 1; transform: none; }
  .grip { display: none; }
  .sheet-head { padding-top: 14px; }
  .form-actions { bottom: -20px; margin-bottom: -20px; padding-bottom: 16px; border-radius: 0 0 20px 20px; }
  .sheet-body { padding-bottom: 20px; }
}

@media (min-width: 900px) {
  .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; padding-inline: max(16px, calc((100vw - 1200px) / 2)); }
  .bar-row { padding: 10px 0 8px; }
  .tabs { position: static; gap: 4px; padding: 0; background: none; border: 0; }
  .tabs button { flex: none; flex-direction: row; gap: 8px; padding: 8px 12px; border-radius: 10px; font-size: 14.5px; color: var(--muted); }
  .tabs button:hover { background: var(--surface-2); }
  .tabs button.on { background: var(--primary-soft); color: var(--primary); }
  .tabs .i { width: 19px; height: 19px; }
  .strip, .filters { grid-column: 1 / -1; }
  .strip { width: 100%; }
  .filters { padding: 0 0 10px; }
  .view { max-width: 1200px; padding: 16px 16px 120px; }
  [data-view="day"] .view, [data-view="search"] .view { max-width: 760px; }
  .fab { right: 28px; bottom: 28px; }
  #toast { bottom: 32px; }
  .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
  .wday { min-height: 160px; }
  .wday-list .none { display: block; padding: 2px 8px; color: var(--faint); }
  .mini { flex-direction: column; gap: 0; padding: 6px 8px 6px 15px; }
  .mini-name { width: 100%; }
  .mini small { max-width: 100%; }
  .mcell { align-items: stretch; min-height: 116px; padding: 6px; }
  .mnum { align-self: flex-start; }
  .mcount { display: none; }
  .mlist { display: flex; flex-direction: column; gap: 2px; }
  .mrow {
    overflow: hidden;
    padding: 1px 6px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    border-radius: 6px;
    background: var(--surface-2);
    background: color-mix(in srgb, var(--c) 16%, transparent);
  }
  .mrow b { font-weight: 600; font-variant-numeric: tabular-nums; }
  .mmore { padding-left: 6px; text-align: left; font-size: 12px; color: var(--muted); }
  .month-day { max-width: 760px; }
}

@media (max-width: 899px) {
  .wide-only { display: none; }
}

@media (max-width: 360px) {
  .nav-arrow { display: none; }
  .title-text { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .tabs, .fab, .filters, .strip, .nav-arrow, [data-act], #toast, #sheets, .now { display: none !important; }
  body { background: #fff; color: #000; }
  .bar { position: static; border: 0; }
  .view { max-width: none; padding: 0; }
  .appt, .wday, .month { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  .appt.st-done { opacity: 1; }
}
