/* Valli Klinika — design tokens + components (CONTRACT §10). Light only for v1.
   Visual world: the clinic's own site — white ground, cool pale grey panels, near-black ink, one deep teal action colour.
   Read docs/UI-KIT.md for class names. Never hard-code colours in views: use these tokens. */

:root {
  --bg: #ffffff;
  --panel: #f2f6f7;
  --panel-2: #e9f0f2;
  --line: #dde5e8;
  --line-2: #c9d5da;
  --ink: #11181e;
  --text: #2b353d;
  --muted: #59666f;
  --placeholder: #6b7880;
  --faint: #8a979f;

  --brand: #0b6d7b;
  --brand-d: #08535e;
  --brand-soft: #e2f1f3;
  --brand-ring: rgba(11, 109, 123, .24);

  --tg: #17759f;
  --tg-soft: #e3f0f6;
  --ig: #c13584;
  --ig-soft: #f9e8f1;
  --ok: #178a5b;
  --ok-soft: #e3f4ec;
  --warn: #b5651d;
  --warn-soft: #fbefe3;
  --err: #b3261e;
  --err-soft: #fbe9e7;
  --info: #1f6fd1;
  --info-soft: #e7f0fb;
  --violet: #6b4fd8;
  --violet-soft: #efebfc;

  --st-hold: #0b6d7b;
  --st-planned: #5b6b75;
  --st-confirmed: #0b6d7b;
  --st-arrived: #1f6fd1;
  --st-inchair: #6b4fd8;
  --st-done: #178a5b;
  --st-noshow: #b5651d;
  --st-cancelled: #8a979f;

  --r-s: 8px;
  --r: 12px;
  --r-l: 16px;
  --shadow-1: 0 1px 2px rgba(17, 24, 30, .06), 0 2px 8px rgba(17, 24, 30, .06);
  --shadow-2: 0 8px 28px rgba(17, 24, 30, .14);
  --shadow-3: 0 16px 48px rgba(17, 24, 30, .18);

  --font: "Onest", "Segoe UI", system-ui, sans-serif;
  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-18: 18px; --fs-22: 22px; --fs-28: 28px;

  --ease: cubic-bezier(.23, 1, .32, 1);
  --t-fast: 150ms;
  --t: 200ms;

  --top-h: 56px;
  --side-w: 232px;
  --rail-w: 68px;
  --tab-h: 60px;
  --gutter: 28px;

  --z-side: 20; --z-top: 30; --z-tab: 30; --z-drawer: 60; --z-menu: 70; --z-dialog: 80; --z-toast: 90;

  color-scheme: light;
}

/* ───────────── base ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-14)/1.45 var(--font);
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--brand);
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; text-wrap: balance; }
h1 { font-size: var(--fs-22); line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: var(--fs-16); line-height: 1.3; }
h3 { font-size: var(--fs-14); line-height: 1.35; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.ic { flex: none; }
::selection { background: var(--brand-soft); color: var(--ink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }
.num, .tnum, time { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ink { color: var(--ink); }
.small { font-size: var(--fs-13); }
.xs { font-size: var(--fs-12); }
.strong { font-weight: 600; color: var(--ink); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
.row-flex { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 6px; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* ───────────── app shell ───────────── */
.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas: "top top" "side main";
  height: 100dvh;
  overflow: hidden;
}
.top {
  grid-area: top;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: var(--z-top);
  min-width: 0;
}
.brandmark { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); text-decoration: none; width: calc(var(--side-w) - 30px); flex: none; }
.brandmark:hover { text-decoration: none; }
.brandmark img { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; object-fit: cover; }
.brandmark b { font-weight: 600; font-size: 15px; letter-spacing: -.005em; }
.brandmark span { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.top-search { position: relative; flex: 1 1 auto; max-width: 440px; min-width: 0; }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.demo-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.usermenu-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 4px; border: 1px solid transparent; border-radius: 999px; background: none; cursor: pointer; color: var(--ink); }
.usermenu-btn:hover { background: var(--panel); }
.usermenu-btn .who { text-align: left; line-height: 1.15; }
.usermenu-btn .who b { display: block; font-weight: 500; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-btn .who span { font-size: 11.5px; color: var(--muted); }

.side {
  grid-area: side;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 10px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: var(--z-side);
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 10px;
  border-radius: var(--r-s);
  color: var(--text); font-weight: 500;
  text-decoration: none; cursor: pointer;
  border: 1px solid transparent; background: none; width: 100%; text-align: left;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.nav-item .ic { color: var(--muted); }
.nav-item[aria-current="page"] { background: var(--bg); color: var(--ink); border-color: var(--line); box-shadow: 0 1px 2px rgba(17, 24, 30, .05); }
.nav-item[aria-current="page"] .ic { color: var(--brand); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.side-foot { margin-top: auto; padding-top: 8px; }
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--panel-2); color: var(--text);
}
.count.hot { background: var(--brand); color: #fff; }
.count.alert { background: var(--err); color: #fff; }
.count:empty { display: none; }

.main { grid-area: main; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; position: relative; }
.view.view-fill { overflow: hidden; display: flex; flex-direction: column; }
.view-enter { animation: view-in var(--t) var(--ease); }
@keyframes view-in { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tabbar { display: none; }
.phone-only { display: none !important; }

/* bare layout (login, public sim) */
.bare { min-height: 100dvh; background: var(--panel); }
.bare > .view { overflow: visible; min-height: 100dvh; }

/* ───────────── page primitives ───────────── */
.page { padding: 24px var(--gutter) 40px; max-width: 1360px; }
.page.narrow { max-width: 920px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { min-width: 0; }
.page-head .sub { margin-top: 4px; color: var(--muted); font-size: var(--fs-13); }
.page-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-head .back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-13); margin-bottom: 6px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.toolbar .grow { flex: 1; min-width: 160px; }
.section { margin-top: 28px; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.section-head .aside { color: var(--muted); font-size: var(--fs-13); }
.panel { background: var(--panel); border-radius: var(--r-l); padding: 16px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

/* hairline lists */
.list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.list.no-top { border-top: 0; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none; background: none;
  border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left;
}
a.list-row:hover, button.list-row:hover, .list-row.is-link:hover { background: var(--panel); text-decoration: none; cursor: pointer; }
.list-row.is-active { background: var(--brand-soft); }
.list-row.is-urgent { background: var(--err-soft); }
.list-row.is-urgent:hover { background: #f8dedb; }
.list-row .main-col { flex: 1; min-width: 0; }
.list-row .title { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { color: var(--muted); font-size: var(--fs-13); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .end { flex: none; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.list-group-title { padding: 14px 8px 6px; font-size: var(--fs-12); font-weight: 600; color: var(--muted); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 500; font-size: var(--fs-12); color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.group td { background: var(--panel); font-weight: 600; color: var(--ink); font-size: var(--fs-13); padding: 8px 10px; }
.table td.num, .table th.num { text-align: right; }
.table tbody tr:hover td { background: #f8fafb; }
.table tbody tr.group:hover td { background: var(--panel); }

/* ───────────── controls ───────────── */
.btn {
  --h: 36px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); min-width: var(--h); padding: 0 14px;
  border-radius: var(--r-s); border: 1px solid var(--line-2);
  background: var(--bg); color: var(--ink);
  font-weight: 500; font-size: var(--fs-14); line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--panel); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ic { color: currentColor; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--panel); color: var(--ink); }
.btn-danger { background: var(--bg); border-color: #e8c3bf; color: var(--err); }
.btn-danger:hover { background: var(--err-soft); }
.btn-danger.solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger.solid:hover { background: #962019; }
.btn-sm { --h: 30px; padding: 0 10px; font-size: var(--fs-13); gap: 6px; border-radius: 7px; }
.btn-lg { --h: 44px; padding: 0 18px; font-size: var(--fs-16); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--h); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .spinner { position: absolute; inset: 0; margin: auto; color: var(--ink); }
.btn-primary.is-loading .spinner, .btn-danger.solid.is-loading .spinner { color: #fff; }
.btn .badge-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--err); border: 2px solid var(--bg); }
.linklike { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font-weight: 500; }
.linklike:hover { text-decoration: underline; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--bg); color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  font-variant-numeric: tabular-nums;
}
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); outline: none; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--panel); color: var(--muted); cursor: not-allowed; }
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--err); }
.input.is-error:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, .18); }
.input-sm, .select.input-sm { height: 30px; padding: 0 10px; font-size: var(--fs-13); }
.input.quiet { border-color: transparent; background: transparent; padding: 0 8px; }
.input.quiet:hover { border-color: var(--line-2); background: var(--bg); }
.input.quiet:focus { border-color: var(--brand); background: var(--bg); }
.textarea { height: auto; min-height: 88px; padding: 9px 12px; line-height: 1.5; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2359666f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input[type="time"].input { padding-right: 6px; min-width: 96px; }
input[type="number"].input { -moz-appearance: textfield; }
input[type="number"].input::-webkit-inner-spin-button { opacity: .4; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .ic { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 36px; }
.input-wrap > .kbd { position: absolute; right: 8px; }
.input-wrap > .input:focus ~ .kbd { display: none; }
.input-suffix { position: absolute; right: 12px; color: var(--muted); font-size: var(--fs-13); pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .label { font-size: var(--fs-13); font-weight: 500; color: var(--text); }
.field .hint { font-size: var(--fs-12); color: var(--muted); }
.field .error { font-size: var(--fs-12); color: var(--err); display: flex; gap: 6px; align-items: flex-start; }
.field .error:empty, .field .hint:empty { display: none; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-weight: 500; font-size: var(--fs-13);
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(17, 24, 30, .08), 0 0 0 1px var(--line); }
.seg.seg-sm button { height: 24px; padding: 0 9px; font-size: var(--fs-12); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-height: 28px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 36px; height: 22px; border-radius: 999px; background: var(--line-2); transition: background var(--t) var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(17, 24, 30, .25); transition: transform var(--t) var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.switch .switch-label { color: var(--ink); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px;
  background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1;
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 12px; border: 0; background: none;
  color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.tabs .count { height: 18px; min-width: 18px; font-size: 11px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
  font-size: var(--fs-13); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chip:hover { background: var(--panel); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: #b6dbe0; color: var(--brand-d); }
.chip .count { height: 18px; min-width: 18px; font-size: 11px; }

/* ───────────── data display ───────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: var(--fs-12); font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--panel-2); color: var(--text);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.tone-brand { background: var(--brand-soft); color: var(--brand-d); }
.pill.tone-ok { background: var(--ok-soft); color: #11704a; }
.pill.tone-warn { background: var(--warn-soft); color: #95520f; }
.pill.tone-err { background: var(--err-soft); color: var(--err); }
.pill.tone-info { background: var(--info-soft); color: #1a5db0; }
.pill.tone-violet { background: var(--violet-soft); color: #5a3fc4; }
.pill.tone-tg { background: var(--tg-soft); color: var(--tg); }
.pill.tone-ig { background: var(--ig-soft); color: #a52b70; }
.pill.tone-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--muted); }
.pill.tone-dashed { background: var(--bg); color: var(--brand-d); outline: 1.5px dashed var(--brand); outline-offset: -1.5px; }
.pill.tone-strike { background: var(--panel); color: var(--muted); text-decoration: line-through; }
.pill-lg { height: 26px; padding: 0 10px; font-size: var(--fs-13); }

/* appointment status helpers for other views (calendar blocks, rows) */
.st-hold { --st: var(--st-hold); }
.st-planned { --st: var(--st-planned); }
.st-confirmed { --st: var(--st-confirmed); }
.st-arrived { --st: var(--st-arrived); }
.st-in_chair { --st: var(--st-inchair); }
.st-done { --st: var(--st-done); }
.st-no_show { --st: var(--st-noshow); }
.st-cancelled { --st: var(--st-cancelled); }
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--st-planned)); flex: none; display: inline-block; }
.st-fill { background: color-mix(in srgb, var(--st, var(--st-planned)) 13%, #fff); color: color-mix(in srgb, var(--st, var(--st-planned)) 78%, #11181e); }
.st-solid { background: var(--st, var(--st-planned)); color: #fff; }

.ch {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 22px; min-width: 22px; padding: 0 5px; border-radius: 6px;
  font-size: var(--fs-12); font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--panel-2); color: var(--muted);
}
.ch.ch-tg, .ch.ch-tg_group { background: var(--tg-soft); color: var(--tg); }
.ch.ch-ig, .ch.ch-ig_comment { background: var(--ig-soft); color: #a52b70; }
.ch.ch-web { background: var(--brand-soft); color: var(--brand-d); }
.ch.ch-phone, .ch.ch-walkin { background: var(--panel-2); color: var(--text); }
.ch.is-icon { padding: 0; width: 22px; }

.avatar {
  --av: 32px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--av); height: var(--av); border-radius: 50%;
  background: color-mix(in srgb, var(--av-c, var(--brand)) 15%, #fff);
  color: color-mix(in srgb, var(--av-c, var(--brand)) 72%, #11181e);
  font-size: calc(var(--av) * .38); font-weight: 600; letter-spacing: .01em;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.urgent-mark { display: inline-flex; align-items: center; gap: 4px; color: var(--err); font-weight: 600; font-size: var(--fs-12); }
.wait { font-variant-numeric: tabular-nums; color: var(--muted); }
.wait.is-late { color: var(--warn); font-weight: 600; }
.wait.is-critical { color: var(--err); font-weight: 600; }

/* ───────────── feedback ───────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--muted); }
.empty .empty-ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--panel); color: var(--brand); margin-bottom: 4px; }
.empty .empty-title { color: var(--ink); font-weight: 600; font-size: var(--fs-16); }
.empty .empty-text { max-width: 46ch; font-size: var(--fs-14); }
.empty .empty-action { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.empty.compact { padding: 20px 12px; }
.empty.compact .empty-ic { width: 40px; height: 40px; }
.empty.compact .empty-title { font-size: var(--fs-14); }
.empty.is-error .empty-ic { background: var(--err-soft); color: var(--err); }
.empty.is-soon .empty-ic { background: var(--brand-soft); }

.skel-group { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.skel-row { display: flex; align-items: center; gap: 12px; }
.skel {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 40%, var(--panel) 80%);
  background-size: 300% 100%;
  animation: skel 1.4s ease-in-out infinite;
}
.skel.circle { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.skel.block { height: 64px; border-radius: var(--r); }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; flex: none; opacity: .9; }
@keyframes spin { to { transform: rotate(360deg); } }

.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--muted); min-height: 28px; transition: opacity var(--t) var(--ease); }
.save-state[data-state="idle"] { opacity: 0; }
.save-state[data-state="saved"] .ic { color: var(--ok); }
.save-state[data-state="error"] { color: var(--err); }
.save-state .spinner { width: 13px; height: 13px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--panel); color: var(--text); font-size: var(--fs-13); }
.notice .ic { color: var(--brand); margin-top: 1px; }
.notice.tone-warn { background: var(--warn-soft); }
.notice.tone-warn .ic { color: var(--warn); }
.notice.tone-err { background: var(--err-soft); }
.notice.tone-err .ic { color: var(--err); }

/* toasts */
/* compact, bottom-left on desktop (over the sidebar's empty end, off the calendar grid and the lead card's buttons); top on phones.
   At most 2 at a time (core/toast-queue.js). */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 10px 10px 12px; border-radius: var(--r);
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  color: var(--ink); font-size: var(--fs-13);
  animation: toast-in var(--t) var(--ease);
}
.toast.is-leaving { animation: toast-out 160ms ease-in forwards; }
.toast .t-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--panel); color: var(--brand); flex: none; }
.toast.k-ok .t-ic { background: var(--ok-soft); color: var(--ok); }
.toast.k-warn .t-ic { background: var(--warn-soft); color: var(--warn); }
.toast.k-err .t-ic, .toast.k-urgent .t-ic { background: var(--err-soft); color: var(--err); }
.toast.k-lead .t-ic { background: var(--brand-soft); color: var(--brand); }
.toast.k-urgent { background: #fff8f7; border-color: #f1cdc9; }
.toast .t-body { flex: 1; min-width: 0; padding-top: 4px; }
.toast .t-text { overflow-wrap: anywhere; }
.toast .t-actions { display: flex; gap: 8px; margin-top: 8px; }
.toast .t-close { margin: -2px -2px 0 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ───────────── overlays ───────────── */
.drawer-layer { position: fixed; inset: 0; z-index: var(--z-drawer); pointer-events: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(17, 24, 30, .18); opacity: 0; transition: opacity var(--t) var(--ease); pointer-events: auto; }
.drawer-layer.no-scrim .drawer-scrim { display: none; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(var(--dw, 440px), 100vw);
  display: flex; flex-direction: column;
  background: var(--bg); box-shadow: var(--shadow-3); border-left: 1px solid var(--line);
  transform: translateX(104%); transition: transform 240ms var(--ease);
  pointer-events: auto;
}
.drawer-layer.is-open .drawer { transform: none; }
.drawer-layer.is-open .drawer-scrim { opacity: 1; }
.drawer-head { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 12px 10px 20px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-head .d-title { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: var(--fs-18); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head .d-sub { color: var(--muted); font-size: var(--fs-13); margin-top: 2px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.drawer-body.flush { padding: 0; }
.drawer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--bg); flex: none; }
.drawer-foot:empty { display: none; }

dialog.dlg {
  border: 0; padding: 0; border-radius: var(--r-l); box-shadow: var(--shadow-3);
  width: min(440px, calc(100vw - 32px)); color: var(--text); background: var(--bg);
}
dialog.dlg::backdrop { background: rgba(17, 24, 30, .32); }
dialog.dlg[open] { animation: dlg-in var(--t) var(--ease); }
.dlg-body { padding: 22px 22px 8px; }
.dlg-body h2 { font-size: var(--fs-18); margin-bottom: 8px; }
.dlg-body .dlg-text { color: var(--text); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

.pop {
  position: fixed; z-index: var(--z-menu);
  min-width: 200px; max-width: min(360px, calc(100vw - 16px));
  max-height: min(460px, calc(100dvh - 16px)); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2);
  padding: 6px;
  animation: pop-in 140ms var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 36px; padding: 6px 10px; border: 0; border-radius: 7px; background: none;
  color: var(--ink); text-align: left; cursor: pointer; font-size: var(--fs-14);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel); outline: none; }
.menu-item .ic { color: var(--muted); }
.menu-item.is-danger { color: var(--err); }
.menu-item.is-danger .ic { color: var(--err); }
.menu-item[disabled] { opacity: .45; cursor: not-allowed; }
.menu-item .mi-label { flex: 1; min-width: 0; }
.menu-item .mi-hint { color: var(--muted); font-size: var(--fs-12); }
.menu-item .mi-check { color: var(--brand); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-head { padding: 8px 10px 6px; font-size: var(--fs-12); color: var(--muted); }
.menu-head b { display: block; color: var(--ink); font-size: var(--fs-14); font-weight: 600; }

/* global search results / picker results */
.results { padding: 4px; }
.result {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 48px; padding: 6px 10px; border: 0; border-radius: 8px; background: none;
  text-align: left; cursor: pointer; color: var(--ink);
}
.result:hover, .result.is-active { background: var(--panel); }
.result .r-main { flex: 1; min-width: 0; }
.result .r-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .r-meta { color: var(--muted); font-size: var(--fs-12); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result mark { background: var(--brand-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.results-empty { padding: 14px 12px; color: var(--muted); font-size: var(--fs-13); }

/* patient picker */
.picker { position: relative; }
.picker-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); max-height: 340px; overflow-y: auto; }
.picker-selected { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--bg); }
.picker-selected .ps-main { flex: 1; min-width: 0; }
.picker-new { display: grid; grid-template-columns: 1.1fr 1fr; gap: 10px; padding: 12px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel); }
.picker-new .pn-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; font-weight: 600; color: var(--ink); }
.picker-new .pn-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.picker-dup { grid-column: 1 / -1; }

/* ───────────── login ───────────── */
.login { min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center; padding: 56px 16px 40px; background: var(--panel); }
.login-sheet { width: min(720px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-1); overflow: hidden; }
.login-head { display: flex; align-items: center; gap: 16px; padding: 28px 32px 20px; }
.login-head img { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.login-head h1 { font-size: var(--fs-22); }
.login-head p { color: var(--muted); margin-top: 4px; max-width: 54ch; }
.roles { border-top: 1px solid var(--line); }
.role-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 18px 32px; border-bottom: 1px solid var(--line); }
.role-row:last-child { border-bottom: 0; }
.role-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.role-row h2 { font-size: var(--fs-16); }
.role-row .role-desc { color: var(--muted); font-size: var(--fs-13); margin-top: 2px; max-width: 60ch; }
.people { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.person {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 44px; padding: 5px 14px 5px 5px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; text-align: left; color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.person:hover { border-color: var(--brand); background: var(--brand-soft); }
.person:active { transform: translateY(1px); }
.person .p-name { font-weight: 500; line-height: 1.15; }
.person .p-sub { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.person.is-loading { opacity: .6; pointer-events: none; }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 32px 22px; background: var(--panel); border-top: 1px solid var(--line); }
.login-foot a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.pin { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 32px 32px; }
.pin-who { display: flex; align-items: center; gap: 12px; }
.pin-dots { display: flex; gap: 12px; height: 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; }
.pin-pad button { height: 60px; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); font-size: 22px; font-weight: 500; color: var(--ink); cursor: pointer; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.pin-pad button:hover { background: var(--panel); }
.pin-pad button:active { background: var(--panel-2); }
.pin-err { color: var(--err); min-height: 20px; font-size: var(--fs-13); }

/* ───────────── dashboard ───────────── */
.dash { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 36px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.dash-block .section-head { margin-bottom: 8px; }
.wait-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wait-row .who .title { min-width: 0; flex: 0 1 auto; }
.st-legend a.muted { color: var(--muted); }
.wait-row .wait { font-size: var(--fs-14); }

.funnel { display: flex; flex-direction: column; gap: 2px; }
.funnel-step { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; align-items: center; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.funnel-step:last-child { border-bottom: 0; }
.funnel-step .fs-label { color: var(--text); }
.funnel-step .fs-val { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.funnel-step .fs-val small { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: var(--fs-12); }
.funnel-step .fs-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.funnel-step .fs-bar i { display: block; height: 100%; border-radius: 3px; background: var(--brand); opacity: var(--o, 1); transition: width 400ms var(--ease); }
.channels-line { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: var(--fs-13); }
.channels-line span { display: inline-flex; align-items: center; gap: 6px; }
.channels-line b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.stbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-2); gap: 2px; }
.stbar i { display: block; height: 100%; background: var(--st); min-width: 4px; }
.st-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 20px; margin-top: 12px; }
.st-legend a, .st-legend div { display: flex; align-items: center; gap: 8px; padding: 5px 0; color: var(--text); text-decoration: none; font-size: var(--fs-13); }
.st-legend b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }

.compare { display: flex; flex-direction: column; gap: 10px; }
.compare-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: var(--fs-13); }
.compare-row .c-bar { height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.compare-row .c-bar i { display: block; height: 100%; background: var(--brand); border-radius: 4px; transition: width 400ms var(--ease); }
.compare-row.is-avg .c-bar i { background: var(--line-2); }
.compare-row .c-val { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.compare-note { color: var(--muted); font-size: var(--fs-13); margin-top: 6px; }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: var(--warn); font-weight: 600; }

.tl { display: flex; flex-direction: column; }
.tl-scale { display: grid; grid-template-columns: 200px minmax(0, 1fr) 52px; gap: 14px; padding-bottom: 6px; }
.tl-scale .ticks { position: relative; height: 16px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-scale .ticks span { position: absolute; transform: translateX(-50%); }
.tl-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) 52px; gap: 14px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
a.tl-row:hover { text-decoration: none; background: linear-gradient(var(--panel), var(--panel)) padding-box; }
.tl-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tl-who .n { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-who .s { color: var(--muted); font-size: var(--fs-12); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 30px; border-radius: 7px; background: var(--panel); overflow: hidden; }
.tl-off { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(17, 24, 30, .06) 5px 6px); }
.tl-lunch { position: absolute; top: 0; bottom: 0; background: var(--panel-2); }
.tl-appt { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; background: color-mix(in srgb, var(--st) 22%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--st) 45%, #fff); }
.tl-appt.st-hold { background: var(--bg); box-shadow: none; outline: 1.5px dashed var(--brand); outline-offset: -1.5px; }
.tl-appt.st-done { background: color-mix(in srgb, var(--st-done) 30%, #fff); }
.tl-appt.st-in_chair { background: color-mix(in srgb, var(--st-inchair) 35%, #fff); }
.tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--err); border-radius: 1px; }
.tl-load { text-align: right; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tl-load.is-low { color: var(--muted); font-weight: 500; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: var(--fs-12); color: var(--muted); }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-legend i { width: 14px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--st) 22%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--st) 45%, #fff); }
.tl-legend i.hold { background: var(--bg); box-shadow: none; outline: 1.5px dashed var(--brand); outline-offset: -1.5px; }

/* ───────────── settings ───────────── */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.set-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.set-nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--r-s); color: var(--text); font-weight: 500; text-decoration: none; }
.set-nav a:hover { background: var(--panel); }
.set-nav a .ic { color: var(--muted); }
.set-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-d); }
.set-nav a[aria-current="page"] .ic { color: var(--brand); }
.set-body { min-width: 0; max-width: 920px; }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.set-head h2 { font-size: var(--fs-18); }
.set-intro { color: var(--muted); margin-bottom: 20px; max-width: 70ch; }
.set-group { padding: 20px 0; border-top: 1px solid var(--line); }
.set-group:first-of-type { border-top: 0; padding-top: 4px; }
.set-group > h3 { margin-bottom: 4px; font-size: var(--fs-16); }
.set-group > .g-intro { color: var(--muted); font-size: var(--fs-13); margin-bottom: 14px; max-width: 70ch; }
/* Telegram linking (PROD-5): local QR, the one-time link, bot status */
.tg-status { margin: 8px 0 4px; }
.tg-qr { display: grid; place-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); background: var(--bg); }
.tg-qr svg { width: min(240px, 100%); height: auto; }
.tg-url { display: block; padding: 8px 10px; background: var(--panel); border-radius: var(--r-s); overflow-wrap: anywhere; font-size: var(--fs-13); }
/* consent preview: the patient's message bubble with its two buttons (LEG-1) */
.consent-bubble { padding: 10px 12px; border-radius: var(--r); background: var(--panel); color: var(--ink); font-size: var(--fs-13); }
.consent-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.consent-btns span { display: grid; place-items: center; min-height: 32px; border-radius: var(--r-s); background: var(--bg); border: 1px solid var(--line); color: var(--tg); font-weight: 500; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .sr-text { min-width: 0; }
.set-row .sr-title { color: var(--ink); font-weight: 500; }
.set-row .sr-desc { color: var(--muted); font-size: var(--fs-13); margin-top: 2px; max-width: 62ch; }
/* phones: a long control (segmented «Называть «от»», URL input) moves under its text instead of running off the screen */
@media (max-width: 759px) { .set-row { flex-wrap: wrap; } .set-row > .seg { max-width: 100%; overflow-x: auto; } }
.hours-grid { display: grid; grid-template-columns: 120px auto 1fr; gap: 8px 16px; align-items: center; }
.hours-grid .h-times { display: flex; align-items: center; gap: 8px; }
.hours-grid .h-times .input { width: 108px; }
.hours-grid .h-closed { color: var(--muted); font-size: var(--fs-13); }
.sched { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sched th { text-align: left; font-weight: 500; font-size: var(--fs-12); color: var(--muted); padding: 6px 8px; }
.sched td { padding: 4px 8px; border-top: 1px solid var(--line); }
.sched td .input { width: 104px; }
.sched td .select { width: 120px; }
.sched tr.is-off td:not(:first-child):not(:nth-child(2)) { opacity: .35; }
.doc-row { border-bottom: 1px solid var(--line); }
.doc-row > .doc-sum { display: flex; align-items: center; gap: 12px; padding: 12px 4px; width: 100%; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.doc-row > .doc-sum:hover { background: var(--panel); }
.doc-row .doc-name { font-weight: 600; color: var(--ink); }
.doc-row .doc-meta { color: var(--muted); font-size: var(--fs-13); }
.doc-row .chev { transition: transform var(--t) var(--ease); color: var(--muted); }
.doc-row.is-open .chev { transform: rotate(180deg); }
.doc-body { padding: 4px 4px 20px; display: flex; flex-direction: column; gap: 16px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.svc-table td .input { min-width: 0; }
.svc-table .c-name { width: 34%; }
.svc-table .c-dur { width: 92px; }
.svc-table .c-price { width: 190px; }
.svc-table .c-spec { width: 170px; }
.svc-table .c-on { width: 64px; text-align: center; }
.svc-table .c-ikpu { width: 190px; }
.svc-table .c-ikpu .input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.price-cell { display: flex; align-items: center; gap: 6px; }
.price-cell .input { text-align: right; }
.codeblock { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; color: var(--ink); overflow-x: auto; white-space: pre; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 12px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-d); font-weight: 600; font-size: var(--fs-13); }
.steps li b { color: var(--ink); font-weight: 600; }
.range { width: 100%; accent-color: var(--brand); }
.reply-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.reply-item .ri-texts { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ───────────── responsive ───────────── */
@media (max-width: 1279px) {
  .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .brandmark { width: auto; }
  .side { padding: 12px 8px; align-items: stretch; }
  .nav-item { justify-content: center; padding: 0; height: 44px; }
  .nav-item .label { display: none; }
  .nav-item .count { position: absolute; top: 2px; right: 4px; height: 17px; min-width: 17px; padding: 0 4px; font-size: 10.5px; box-shadow: 0 0 0 2px var(--panel); }
  .nav-sep { margin: 8px 4px; }
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-col.side-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
}
@media (max-width: 1100px) {
  .usermenu-btn .who { display: none; }
  .settings { grid-template-columns: 180px minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 900px) {
  .brandmark .bm-text { display: none; }
  .top-sim-label { display: none; }
  .dash-col.side-col { grid-template-columns: minmax(0, 1fr); }
  .tl-scale, .tl-row { grid-template-columns: 150px minmax(0, 1fr) 44px; gap: 10px; }
}
@media (max-width: 759px) {
  :root { --gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top-h) minmax(0, 1fr) calc(var(--tab-h) + env(safe-area-inset-bottom)); grid-template-areas: "top" "main" "tab"; }
  .side { display: none; }
  .top { gap: 8px; padding: 0 8px 0 12px; }
  .top-search, .top-lang, .top-sim { display: none; }
  .phone-only { display: inline-flex !important; }
  .tabbar {
    grid-area: tab; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
    z-index: var(--z-tab);
  }
  .tab-item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--tab-h); border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 500; text-decoration: none; cursor: pointer; }
  .tab-item:hover { text-decoration: none; }
  .tab-item[aria-current="page"] { color: var(--brand); }
  .tab-item .count { position: absolute; top: 6px; left: calc(50% + 6px); height: 17px; min-width: 17px; padding: 0 4px; font-size: 10.5px; }
  .toasts { left: 12px; right: 12px; width: auto; bottom: auto; top: calc(var(--top-h) + 8px); }
  .bare .toasts, body.no-tabbar .toasts { top: 12px; }
  .page { padding: 16px var(--gutter) 32px; }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 20px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .drawer { width: 100vw; border-left: 0; transform: translateY(100%); }
  .drawer-layer.is-open .drawer { transform: none; }
  .drawer-head { padding: 8px 8px 8px 16px; }
  .drawer-body { padding: 16px; }
  .drawer-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .drawer-foot .btn { flex: 1; }
  .login { padding: 16px 12px 32px; }
  .login-head { padding: 22px 18px 16px; }
  .role-row { padding: 16px 18px; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .role-ic { width: 40px; height: 40px; }
  .login-foot { padding: 14px 18px 18px; }
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .set-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav a { flex: none; height: 40px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; }
  .hours-grid { grid-template-columns: 1fr auto; }
  .hours-grid .h-times { grid-column: 1 / -1; padding-bottom: 8px; }
  .sched, .sched tbody, .sched tr, .sched td { display: block; }
  .sched thead { display: none; }
  .sched tr { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
  .sched td { border: 0; padding: 0; }
  .sched td.day { width: 100%; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
  .sched td .input, .sched td .select { width: 100%; }
  .sched td.t { width: calc(50% - 4px); }
  .svc-table, .svc-table tbody, .svc-table tr, .svc-table td { display: block; width: auto !important; }
  .svc-table thead { display: none; }
  .svc-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .svc-table tr.group { display: block; }
  .svc-table td { border: 0; padding: 0; }
  .svc-table td.c-name { grid-column: 1 / -1; }
  .reply-item .ri-texts { grid-template-columns: minmax(0, 1fr); }
  .tl-scale, .tl-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .tl-scale > :first-child { display: none; }
  .tl-row .tl-who { grid-column: 1 / -1; }
  .tl-row .tl-track { grid-column: 1; }
  .st-legend { grid-template-columns: 1fr; }
}
@media (pointer: coarse) {
  .btn { --h: 44px; }
  .btn-sm { --h: 38px; }
  .input, .select { height: 44px; font-size: 16px; }
  .input-sm, .select.input-sm { height: 38px; }
  .seg button { height: 36px; }
  .chip { height: 38px; }
  .nav-item, .menu-item { min-height: 44px; }
  .list-row { min-height: 56px; }
  .tabs button { height: 44px; }
  .result { min-height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
