/* Dentalitika page styles (TZ-6). Only tokens from tokens.css: no colours or sizes of its own (checked by tests/test_tokens.py). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); color: var(--ink); font-size: var(--t-m); line-height: 1.45; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: var(--t-l); }
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
:focus-visible { outline: var(--focus) solid var(--accent); outline-offset: var(--focus); }
.muted { color: var(--ink-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- controls: buttons, tags, fields, segments, filter chips (canvas, sheet «Элементы») ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--control-h);
  padding: 0 var(--sp-4); border: var(--bw) solid var(--control); border-radius: var(--r-m); background: var(--surface);
  color: var(--ink); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color var(--motion), border-color var(--motion), color var(--motion); }
.btn:hover, .btn[aria-pressed="true"] { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.soft { background: var(--neutral-bg); border-color: transparent; }
.btn.soft:hover { background: var(--line); }
.btn.danger { background: var(--late); border-color: var(--late); color: var(--surface); font-weight: 600; }
.btn.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent-ink); font-weight: 500; text-decoration: none; }
.btn.link:hover { text-decoration: underline; text-underline-offset: var(--sp-1); background: none; }
.btn.chip { min-height: calc(var(--control-h) - var(--sp-1)); padding: 0 var(--sp-4); border-color: var(--line); border-radius: var(--r-pill); }
.btn.chip:hover { border-color: var(--control); background: var(--surface); }
.btn.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }
.btn.chip[aria-pressed="true"] .count { color: inherit; opacity: 0.8; }
.btn .count { color: var(--ink-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.btn.icon { padding: 0; min-width: var(--control-h); }
.tag { display: inline-flex; align-items: center; min-height: calc(var(--sp-5) + var(--sp-1)); padding: 0 var(--sp-3); border-radius: var(--r-pill);
  background: var(--neutral-bg); color: var(--neutral); font-size: var(--t-s); font-weight: 500; white-space: nowrap; }
.tag.late { background: var(--late-bg); color: var(--late); }
.tag.today { background: var(--today-bg); color: var(--today); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.info { background: var(--info-bg); color: var(--info); }
.seg { display: inline-flex; gap: var(--bw); padding: calc(var(--sp-1) - var(--bw)); border-radius: var(--r-m); background: var(--neutral-bg); }
.seg button, .seg .r-radio { min-height: calc(var(--control-h) - var(--sp-2)); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-s); background: transparent;
  color: var(--ink-2); font-weight: 500; cursor: pointer; transition: background-color var(--motion), color var(--motion); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--seg-shadow); }
.seg button:disabled { opacity: 0.4; cursor: default; }
.field { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--ink-2); }
select, input[type="search"], input[type="text"], input[type="password"], input[type="datetime-local"] { min-height: var(--control-h);
  padding: 0 var(--sp-3); border: var(--bw) solid var(--control); border-radius: var(--r-m); background: var(--field); color: var(--ink); }
input::placeholder { color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.badge { display: inline-block; white-space: nowrap; font-size: var(--t-s); font-weight: 500; background: var(--today-bg); color: var(--today);
  border-radius: var(--r-pill); padding: 0 var(--sp-2); margin-left: var(--sp-2); vertical-align: middle; }

/* ---------- frame (TZ-6, 1): the menu on the left on --bg, the working area white; on a phone a top bar and the bottom navigation ---------- */
body.app:not(.auth-mode) { display: grid; grid-template-columns: var(--w-nav) minmax(0, 1fr); min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: var(--sp-6); height: 100vh; padding: var(--sp-5) var(--sp-3) var(--sp-3);
  overflow-y: auto; background: var(--bg); border-right: var(--bw) solid var(--line); }
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; padding: 0 var(--sp-2); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-name { font-size: var(--t-m); font-weight: 700; }
.clinic { min-width: 0; color: var(--ink-3); font-size: var(--t-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; flex-direction: column; gap: var(--sp-1); }
.tabs a { display: flex; align-items: center; gap: var(--sp-3); min-height: calc(var(--control-h) + var(--sp-1)); padding: 0 var(--sp-3); font-size: var(--t-nav);
  border: var(--bw) solid transparent; border-radius: var(--r-m); color: var(--ink-2); font-weight: 500; text-decoration: none;
  transition: background-color var(--motion), color var(--motion); }
.tabs a:hover { background: var(--hover); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.nav-ico { width: var(--ico); height: var(--ico); flex: none; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { min-width: calc(var(--sp-5) + var(--sp-1)); padding: 0 var(--sp-2); border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent);
  font-size: var(--t-xs); font-weight: 600; line-height: calc(var(--sp-5) + var(--sp-1)); text-align: center; font-variant-numeric: tabular-nums; }
.nav-count:empty { display: none; }
.side-foot { position: relative; display: flex; flex-direction: column; gap: var(--sp-1); margin-top: auto; }
.side-link { display: flex; align-items: center; min-height: var(--control-h); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-m); background: none;
  color: var(--ink-2); font-size: var(--t-s); text-align: left; text-decoration: none; cursor: pointer; }
.side-link:hover { background: var(--hover); color: var(--ink); }
#user-actions { margin-top: var(--sp-2); padding-top: var(--sp-3); border-top: var(--bw) solid var(--line); }
.user-btn { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-2); border: 0; border-radius: var(--r-m); background: none;
  text-align: left; cursor: pointer; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--hover); }
.avatar { display: grid; place-items: center; width: var(--ava); height: var(--ava); flex: none; border-radius: var(--r-pill); background: var(--accent-soft);
  color: var(--accent-ink); font-size: var(--t-xs); font-weight: 700; }
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { font-size: var(--t-s); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: var(--ink-3); font-size: var(--t-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; left: 0; bottom: calc(100% + var(--sp-2)); z-index: 10; display: flex; flex-direction: column; gap: var(--bw);
  min-width: var(--w-menu); padding: var(--sp-1); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-m);
  box-shadow: 0 var(--sp-1) var(--sp-4) var(--shadow); }
#menu { right: 0; }
.menu .who { padding: var(--sp-1) var(--sp-2); color: var(--ink-3); font-size: var(--t-xs); }
.menu .btn { justify-content: flex-start; border: 0; border-radius: var(--r-s); background: transparent; font-weight: 400; }
.menu .btn:hover { background: var(--hover); }
.menu .mobile-only { display: none; }
.bottom-nav { display: none; }
main { min-width: 0; padding: var(--sp-7) var(--sp-8) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-4); }
main > * { width: 100%; max-width: var(--w-content); }
.section { display: flex; flex-direction: column; gap: var(--sp-4); }
.card { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; padding: var(--sp-4) var(--sp-5); background: var(--surface);
  border: var(--bw) solid var(--line); border-radius: var(--r-l); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.card-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
.board > .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

/* ---------- states: loading, empty, error, stale ---------- */
.skel-block { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-1) 0; }
.skel { height: var(--sp-4); border-radius: var(--r-s); background: var(--skeleton); }
.skel.tall { height: calc(var(--sp-7) * 2); }
.skel.short { width: 60%; }
.state-empty { padding: var(--sp-3) 0; color: var(--ink-2); }
.state-error { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; color: var(--late); }
.state-stale { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-s); background: var(--today-bg); color: var(--today); }
.sync-line { display: flex; flex-wrap: wrap; gap: var(--sp-4); color: var(--ink-2); font-size: var(--t-s); }
.sync-item.sync-bad { color: var(--late); font-weight: 500; }

/* ---------- tiles ---------- */
/* ---------- overview rows (U4): each row has its period in the heading ---------- */
.ov-row { display: flex; flex-direction: column; gap: var(--sp-3); }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-head h2 { margin: 0; }
.replies-by { font-size: var(--t-s); }
.print-title { display: none; }
/* public page «Что видит Денталитика» (TZ-4 C4) */
main.doc { max-width: var(--w-list); margin: 0 auto; padding: var(--sp-7) var(--sp-6); gap: var(--sp-3); line-height: 1.55; }
.doc h1 { margin: var(--sp-2) 0; font-size: var(--t-xl); }
.doc h2 { margin: var(--sp-4) 0 0; font-size: var(--t-l); }
.doc p, .doc ul { margin: 0; }
.doc ul { padding-left: var(--sp-6); }
.today { display: grid; grid-template-columns: minmax(0, 1.1fr) 2fr; gap: var(--sp-4); }
.hero-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--r-s); }
.hero-open:hover .hero-value, .hero-open[aria-pressed="true"] .hero-value { color: var(--accent-ink); }
.hero-sub { margin-top: var(--sp-1); color: var(--ink-2); font-size: var(--t-s); }
a.tile { display: block; color: inherit; text-decoration: none; transition: background-color var(--motion); }
a.tile:hover { background: var(--hover); }
#today-tiles, #replies-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.table-gap { margin-top: var(--sp-3); }
table.data tr.hl td, table.data tr.hl th { background: var(--hover); }
table.data tr.total td { font-weight: 600; }
table.data tr.group th { padding-top: var(--sp-4); color: var(--ink-2); font-size: var(--t-s); font-weight: 500; text-align: left; }
table.data td.hl-col, table.data th.hl-col { box-shadow: inset 0 calc(-1 * var(--focus)) 0 var(--accent); }
.th-sort { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: inherit; }
.th-sort:hover { color: var(--ink); text-decoration: underline; }
.row .num .share { color: var(--ink-2); font-size: var(--t-s); }
.row.head .bar-gap { color: var(--ink-2); font-size: var(--t-s); }
.r-range { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.hero-label { color: var(--ink-2); }
.hero-value { margin: var(--sp-1) 0; font-size: var(--t-xxl); font-weight: 600; line-height: 1.1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--w-name) + var(--sp-7)), 1fr)); gap: var(--sp-3); align-items: start; }
.today .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { padding: var(--sp-3) var(--sp-4); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-l); text-align: left; }
.card .tile { border: 0; background: var(--bg); }
button.tile { cursor: pointer; font: inherit; color: inherit; transition: background-color var(--motion); }
button.tile:hover { background: var(--hover); }
button.tile[aria-pressed="true"] { outline: var(--focus) solid var(--accent); outline-offset: calc(-1 * var(--focus)); }
.tile-label { color: var(--ink-2); }
.tile-value { margin-top: var(--sp-1); font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.02em; }
.tile-sub { margin-top: var(--sp-1); color: var(--ink-2); }
.delta { font-weight: 500; }
.delta.good { color: var(--ok); }
.delta.bad { color: var(--late); }
.plan { margin-top: var(--sp-2); }
.plan .meter { margin: var(--sp-1) 0; }
.plan-text { color: var(--ink-2); }

/* ---------- rows with a bar ---------- */
.rows { display: flex; flex-direction: column; }
.row { display: grid; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-1); border-top: var(--bw) solid var(--line-soft); border-radius: var(--r-s); }
.row.head { border-top: 0; color: var(--ink-2); font-size: var(--t-s); }
.row:not(.head):hover { background: var(--hover); }
.row .name { min-width: 0; }
.row .name .sub { color: var(--ink-2); font-size: var(--t-s); overflow-wrap: anywhere; }
.row .num.over { color: var(--late); font-weight: 600; }
.row .short { display: none; }
.funnel .row { grid-template-columns: minmax(var(--w-col), 1.3fr) minmax(var(--w-num), 1fr) repeat(4, minmax(var(--w-num), 0.5fr)); }
.funnel.no-money .row { grid-template-columns: minmax(var(--w-col), 1.3fr) minmax(var(--w-num), 1fr) repeat(3, minmax(var(--w-num), 0.5fr)); }
.meters .row { grid-template-columns: minmax(var(--w-col), 1fr) minmax(var(--w-col), 1.2fr) var(--w-num) calc(var(--w-num) * 2); }
.rows.channels, .rows.reasons { display: grid; max-width: var(--w-list); column-gap: var(--sp-3); }
#sources-table { max-width: var(--w-list); }
.rows.channels { grid-template-columns: minmax(var(--w-name), max-content) minmax(var(--w-name), 1fr) repeat(3, max-content); }
.rows.reasons { grid-template-columns: minmax(var(--w-name), max-content) minmax(var(--w-num), 1fr) max-content; }
.rows.channels > .row, .rows.reasons > .row { grid-column: 1 / -1; grid-template-columns: subgrid; }
.bar-track { position: relative; height: var(--bar-h); }
.bar { height: var(--bar-h); min-width: 0; background: var(--s1); border-radius: 0 var(--sp-1) var(--sp-1) 0; }
.meter { height: var(--meter-h); overflow: hidden; background: var(--track); border-radius: var(--sp-1); }
.meter > div { height: 100%; background: var(--s1); border-radius: var(--sp-1); }
.meter.over > div { background: linear-gradient(to right, var(--s1) var(--full), var(--late) var(--full)); }
table.data td:not(:first-child) { white-space: nowrap; }
.cell-meter { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
.cell-meter .meter { width: calc(var(--w-num) * 1.2); flex: none; }
.cell-meter .over { color: var(--late); }

/* ---------- charts and tables ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .tick { fill: var(--ink-2); font-size: var(--t-s); font-variant-numeric: tabular-nums; }
.chart .endlabel { fill: var(--ink); font-size: var(--t-s); }
.chart .endlabel .muted { fill: var(--ink-2); }
.chart .caplabel { fill: var(--ink); font-size: var(--t-s); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .colhit { fill: transparent; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); color: var(--ink-2); font-size: var(--t-s); }
.legend .key { display: inline-block; width: var(--sp-4); height: var(--focus); margin-right: var(--sp-2); vertical-align: middle; border-radius: var(--bw); background: var(--key); }
.legend .key.dash { background: repeating-linear-gradient(to right, var(--key) 0 var(--sp-2), transparent var(--sp-2) calc(var(--sp-3) - var(--bw))); }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: var(--sp-2); border-top: var(--bw) solid var(--line-soft); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { border-top: 0; color: var(--ink-2); font-size: var(--t-s); font-weight: 500; }
.table-wrap { overflow-x: auto; }
.tooltip { position: fixed; z-index: 20; min-width: var(--w-tip); padding: var(--sp-2) var(--sp-3); pointer-events: none; background: var(--surface);
  color: var(--ink); border: var(--bw) solid var(--line); border-radius: var(--r-s); box-shadow: 0 var(--sp-1) var(--sp-4) var(--shadow); }
.tooltip .t-title { margin-bottom: var(--sp-1); color: var(--ink-2); font-size: var(--t-s); }
.tooltip .t-row { display: flex; align-items: center; gap: var(--sp-2); }
.tooltip .t-row strong { font-weight: 600; }
.tooltip .t-row span { color: var(--ink-2); }
.tooltip .key { display: inline-block; width: var(--sp-3); height: var(--focus); border-radius: var(--bw); }

/* ---------- contacts ---------- */
.jstatus { color: var(--ink-2); }
.st-missed { color: var(--late); font-weight: 500; }
.coverage { position: relative; }
.coverage-pop { position: absolute; left: 0; top: calc(100% + var(--sp-1)); z-index: 10; width: max-content; max-width: var(--w-dialog);
  padding: var(--sp-2) var(--sp-3); background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--r-s);
  box-shadow: 0 var(--sp-1) var(--sp-4) var(--shadow); color: var(--ink); font-weight: 400; white-space: normal; }
.jlist { display: flex; flex-direction: column; }
.jday { position: sticky; top: 0; z-index: 2; padding: var(--sp-2) var(--sp-1);
  background: var(--surface); border-bottom: var(--bw) solid var(--line-soft); color: var(--ink-2); font-size: var(--t-s); font-weight: 600; }
.jhead, .jrow { display: grid; align-items: center; gap: var(--sp-3);
  grid-template-columns: var(--w-time) minmax(var(--w-col), 1fr) minmax(var(--w-col), 1fr) minmax(var(--w-col), 1.4fr) calc(var(--w-num) * 1.5) var(--w-num); }
.jlist.no-rec .jhead, .jlist.no-rec .jrow { grid-template-columns: var(--w-time) minmax(var(--w-col), 1fr) minmax(var(--w-col), 1fr) minmax(var(--w-col), 1.4fr) calc(var(--w-num) * 1.5); }
.jhead { padding: var(--sp-1); color: var(--ink-2); font-size: var(--t-s); }
.jrow { padding: var(--sp-2) var(--sp-1); border-bottom: var(--bw) solid var(--line-soft); cursor: pointer; transition: background-color var(--motion); }
.jrow:hover, .jrow:focus-visible { background: var(--hover); }
.jrow > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jrow .sub { color: var(--ink-2); }
.more { align-self: flex-start; margin-top: var(--sp-2); }

/* ---------- reply ---------- */
/* one set of columns for the whole list (subgrid), so the deadline column is as wide as its longest value in every row */
.rlist { display: grid; grid-template-columns: fit-content(var(--w-col)) minmax(0, 1fr) fit-content(var(--w-name)) max-content; column-gap: var(--sp-4); }
.rrow { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; gap: var(--sp-2) var(--sp-4);
  min-height: calc(var(--sp-8) + var(--sp-6) + var(--focus)); padding: var(--sp-2) var(--sp-2); border-bottom: var(--bw) solid var(--line-soft); cursor: pointer;
  transition: background-color var(--motion); }
.rrow:hover, .rrow:focus-visible { background: var(--hover); }
.rrow.overdue .r-wait strong { color: var(--late); }
.r-wait { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2); min-width: 0; }
.r-wait strong { font-size: var(--t-m); font-weight: 600; }
.r-due { color: var(--ink-2); font-size: var(--t-s); }
.r-due.late { color: var(--late); font-weight: 600; }
.btn.chip.late { color: var(--late); }
.btn.chip.late[aria-pressed="true"] { color: var(--surface); }
/* what happened in two lines (TZ-6, acceptance 05.12 item 2): who on top, the matter below, wrapped, never cut */
.r-mid { display: flex; flex-direction: column; gap: var(--bw); min-width: 0; }
.r-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2); min-width: 0; }
.r-what { color: var(--ink-2); font-size: var(--t-s); overflow-wrap: anywhere; }
.r-phone { font-weight: 600; font-variant-numeric: tabular-nums; }
.r-name { font-weight: 500; }
.r-right { display: flex; flex-direction: column; font-size: var(--t-s); overflow-wrap: anywhere; }
.r-acts { display: flex; align-items: center; gap: var(--sp-1); }
.btn.quiet { border-color: transparent; }
.btn.quiet:hover, .btn.quiet:focus-visible { border-color: var(--control); }
.r-filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.r-search-btn, .short { display: none; }
#sec-reply .btn .short { display: none; }
.panel-head .card-actions { flex-wrap: wrap; justify-content: flex-end; }
.r-menu { position: absolute; right: auto; z-index: 25; min-width: var(--w-menu); }
.r-time { display: flex; gap: var(--sp-1); padding-top: var(--sp-1); border-top: var(--bw) solid var(--line-soft); }
.r-comment { display: flex; gap: var(--sp-2); }
.r-comment input { flex: 1; min-width: 0; }
.r-new { display: flex; flex-direction: column; gap: var(--sp-3); min-width: var(--w-login); text-align: left; }
.r-new .card-actions { justify-content: flex-start; }
.r-new .field { justify-content: space-between; }
.r-radio { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-3); min-height: calc(var(--control-h) - 2 * var(--bw)); }

/* ---------- side panel, toast, dialog, login ---------- */
.scrim { position: fixed; inset: 0; z-index: 19; background: var(--scrim); }
.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; display: flex; flex-direction: column; width: min(var(--w-panel), 100%);
  background: var(--surface); border-left: var(--bw) solid var(--line); box-shadow: 0 0 var(--sp-6) var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6);
  border-bottom: var(--bw) solid var(--line-soft); }
.panel-body { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6); overflow-y: auto; }
.panel-item { display: grid; grid-template-columns: calc(var(--w-num) * 1.5) 1fr; gap: var(--sp-1) var(--sp-3); padding-bottom: var(--sp-3);
  border-bottom: var(--bw) solid var(--line-soft); }
.panel-item .when { color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: var(--sp-6); z-index: 30; display: flex; align-items: center; gap: var(--sp-3); transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-s); background: var(--ink); color: var(--surface); }
.toast .btn { min-height: 0; padding: 0 var(--sp-2); border-color: var(--surface); color: var(--surface); }
/* call recording player (TZ-5): one at a time, above the side panel */
.player { position: fixed; left: var(--sp-6); bottom: var(--sp-6); z-index: 26; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3);
  width: min(var(--w-dialog), calc(100% - 2 * var(--sp-6))); padding: var(--sp-2) var(--sp-3); background: var(--surface);
  border: var(--bw) solid var(--line); border-radius: var(--r-l); box-shadow: 0 0 var(--sp-6) var(--shadow); }
.player audio { flex: 1; min-width: 0; height: var(--control-h); }
.player .player-title { color: var(--ink-2); font-size: var(--t-s); }
.player .player-msg { flex-basis: 100%; color: var(--late); }
.rec-btn { white-space: nowrap; }
/* login screen (TZ-3 U0.0, docs/mockups/login.html): no header, the product mark over a card, a quiet chart line behind */
.auth-mode .top, .auth-mode main, .auth-mode .bottom-nav { display: none !important; }
.auth { position: relative; display: grid; grid-template-rows: 1fr auto 1.4fr; justify-items: center; min-height: 100vh; padding: var(--sp-6) var(--sp-4);
  overflow: hidden; background: var(--bg); }
.auth-main { position: relative; z-index: 1; grid-row: 2; display: flex; flex-direction: column; gap: var(--sp-6); width: 100%; max-width: var(--w-auth); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.auth-brand .brand-name { font-size: var(--t-xl); font-weight: 700; }
.mark { width: var(--mark); height: var(--mark); flex: none; }
.auth-card { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-7); background: var(--surface); border: var(--bw) solid var(--line-soft);
  border-radius: var(--r-l); }
.auth-card h1 { font-size: var(--t-xl); line-height: 1.25; text-wrap: balance; }
.auth-sub { margin: calc(-1 * var(--sp-3)) 0 0; color: var(--ink-2); }
.auth-field { display: flex; flex-direction: column; gap: var(--sp-1); }
.auth-label { color: var(--ink-2); font-size: var(--t-s); }
.auth-control { position: relative; display: flex; }
.auth-control input { width: 100%; height: var(--field-h); padding: 0 var(--sp-3); border: var(--bw) solid var(--control); border-radius: var(--r-s);
  background: var(--field); color: var(--ink); transition: border-color var(--motion); }
.auth-control input:hover { border-color: var(--ink-2); }
.auth-control input:focus-visible { outline: var(--focus) solid var(--accent); outline-offset: var(--bw); border-color: var(--accent); }
.auth-control.has-toggle input { padding-right: calc(var(--control-h) + var(--sp-3)); }
.auth-toggle, .auth-theme { display: grid; place-items: center; border: 0; border-radius: var(--r-s); background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background-color var(--motion), color var(--motion); }
.auth-toggle { position: absolute; top: var(--sp-1); right: var(--sp-1); width: var(--control-h); height: calc(var(--field-h) - 2 * var(--sp-1)); }
.auth-toggle:hover, .auth-theme:hover { background: var(--accent-soft); color: var(--ink); }
.auth-toggle svg, .auth-theme svg { width: calc(var(--sp-4) + var(--sp-1)); height: calc(var(--sp-4) + var(--sp-1)); }
.auth-theme { position: absolute; top: var(--sp-4); right: var(--sp-4); z-index: 2; width: calc(var(--control-h) + var(--sp-1)); height: calc(var(--control-h) + var(--sp-1)); }
.auth-theme .sun { display: none; }
:root[data-theme="dark"] .auth-theme .sun { display: block; }
:root[data-theme="dark"] .auth-theme .moon { display: none; }
.auth-note { display: flex; align-items: center; gap: var(--sp-2); margin: calc(-1 * var(--sp-1)) 0 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-s); font-size: var(--t-s); }
.auth-note svg { width: var(--sp-4); height: var(--sp-4); flex: none; }
.auth-note.caps { background: var(--today-bg); color: var(--today); }
.auth-note.error { background: var(--late-bg); color: var(--late); font-weight: 500; }
.auth-submit { height: var(--field-h); margin-top: var(--sp-1); border: 0; border-radius: var(--r-s); background: var(--accent); color: var(--on-accent); font-weight: 600;
  cursor: pointer; transition: filter var(--motion); }
.auth-submit:hover { filter: brightness(0.92); }
.auth-submit:focus-visible { outline: var(--focus) solid var(--accent); outline-offset: var(--focus); }
.auth-submit[disabled] { opacity: 0.7; cursor: progress; }
.auth-backdrop { position: absolute; right: 0; bottom: 0; left: 0; z-index: 0; width: 100%; height: 38%; pointer-events: none; }
.auth-backdrop .area { fill: var(--accent); opacity: 0.05; }
.auth-backdrop .line { fill: none; stroke: var(--accent); stroke-width: 2; opacity: 0.22; vector-effect: non-scaling-stroke; }
.auth-backdrop .rule { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .auth-theme .sun { display: block; }
  :root:where(:not([data-theme="light"])) .auth-theme .moon { display: none; }
}
@media (max-width: 480px) {
  .auth { grid-template-rows: auto auto 1fr; padding-top: calc(var(--sp-7) * 2 + var(--sp-2)); }
  .auth-card { padding: var(--sp-6) var(--sp-4); }
  .auth-backdrop { height: 26%; }
}
.error { min-height: 1em; margin: 0; color: var(--late); }
.page-error { max-width: var(--w-page); margin: var(--sp-6) auto; padding: 0 var(--sp-6); }
dialog { max-width: var(--w-dialog); padding: var(--sp-4) var(--sp-6); background: var(--surface); color: var(--ink); border: var(--bw) solid var(--line); border-radius: var(--r-l); }
dialog::backdrop { background: var(--scrim); }
dialog h3 { margin: var(--sp-3) 0 var(--sp-1); font-size: var(--t-m); }
dialog p { margin: 0 0 var(--sp-2); color: var(--ink-2); }
dialog form { margin-top: var(--sp-4); text-align: right; }

/* ---------- narrow screens: board in one column; phone (700 px): bottom navigation, lists in three lines, contact cards ---------- */
@media (max-width: 900px) {
  .board, .today { grid-template-columns: 1fr; }
}
/* print (U4): A4 without the header and buttons, light colours, blocks not torn between sheets */
@media print {
  @page { size: A4; margin: 12mm; }
  .top, .bottom-nav, .skip, #tooltip, #toast, #player, .panel, .scrim, .btn, .seg, .card-actions, .row-head .btn, #board-filters, .state-stale { display: none !important; }
  body, body.app:not(.auth-mode) { display: block; background: var(--surface); }
  main { max-width: none; padding: 0; gap: var(--sp-3); zoom: 0.8; }
  .meters .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--w-num) calc(var(--w-num) * 1.5); }
  .print-title { display: block; font-weight: 600; }
  .section, .ov-row { gap: var(--sp-2); }
  .card { padding: var(--sp-3); box-shadow: none; border: var(--bw) solid var(--line-soft); }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .today { grid-template-columns: minmax(0, 1.1fr) 2fr; }
  .card, .ov-row, .tile, .hero, table.data tr { break-inside: avoid; }
  .tile { padding: var(--sp-2) var(--sp-3); }
  .hero-value { font-size: var(--t-xl); }
  .chart svg { width: 100%; height: auto; }
  .bar, .meter, .meter > div, .legend .key, .chart svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 700px) {
  body.app:not(.auth-mode) { display: block; }
  .top { flex-direction: row; align-items: center; gap: var(--sp-2); height: calc(var(--control-h) + 2 * var(--sp-2)); padding: 0 var(--sp-2) 0 var(--sp-3);
    overflow: visible; border-right: 0; border-bottom: var(--bw) solid var(--line); }
  .brand { flex: 1; padding: 0; }
  .top .brand-name, .tabs, .side-foot > .side-link, .user-text { display: none; }
  .side-foot { margin: 0; }
  #user-actions { margin: 0; padding: 0; border: 0; }
  .user-btn { padding: var(--sp-1); }
  .menu { top: calc(100% + var(--sp-1)); bottom: auto; left: auto; right: 0; }
  .menu .mobile-only { display: flex; }
  .bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 6; display: flex; background: var(--surface); border-top: var(--bw) solid var(--line); }
  .bottom-nav a { position: relative; display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1);
    min-height: calc(var(--control-h) + var(--sp-4)); color: var(--ink-2); font-size: var(--t-xs); font-weight: 500; text-decoration: none; }
  .bottom-nav a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; }
  /* the counter sits on the top right corner of the icon, off the label (acceptance 05.12 item 1) */
  .nav-ico-wrap { position: relative; display: inline-flex; padding: var(--sp-2) var(--sp-6) 0; margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-6)) 0; }
  .bottom-nav .nav-count { position: absolute; top: 0; left: calc(50% + var(--ico) / 2 - var(--sp-2)); min-width: calc(var(--sp-4) + var(--focus));
    padding: 0 var(--sp-1); font-size: var(--t-xs); line-height: calc(var(--sp-4) + var(--focus)); }
  .clinic { font-size: var(--t-s); color: var(--ink-2); }
  .player { left: var(--sp-3); bottom: calc(var(--control-h) + var(--sp-6)); width: calc(100% - 2 * var(--sp-3)); }
  main { padding: var(--sp-4) var(--sp-3) calc(var(--control-h) + var(--sp-8)); }
  .card { padding: var(--sp-3); }
  .today .tiles, #today-tiles, #replies-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-row { gap: var(--sp-2); }
  .row-head h2 { font-size: var(--t-l); }
  .tile { padding: var(--sp-2) var(--sp-3); }
  .hero .hero-value { font-size: var(--t-xl); }
  .funnel { --n: 4; } .funnel.no-money { --n: 3; } .channels { --n: 3; }
  .rows.channels { display: flex; flex-direction: column; }
  .rows.funnel .row, .rows.channels .row { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: var(--sp-1) var(--sp-2); padding: var(--sp-2) var(--bw); }
  .funnel .row > .name, .channels .row > .name, .funnel .row > .bar-track, .channels .row > .bar-track { grid-column: 1 / -1; }
  .funnel .row.head > .name, .channels .row.head > .name, .row.head > .bar-gap { display: none; }
  .row.head .num { white-space: nowrap; }
  .row .long { display: none; } .row .short { display: inline; }
  .funnel .bar-track, .funnel .bar, .channels .bar-track, .channels .bar { height: var(--meter-h); }
  .meters .row { grid-template-columns: 1fr var(--w-num) calc(var(--w-num) * 1.5); }
  .meters .row .meter { grid-column: 1 / -1; grid-row: 2; }
  .jhead { display: none; }
  .jday { top: calc(var(--control-h) + 2 * var(--sp-2) + var(--bw)); }  /* under the phone top bar */
  .jrow, .jlist.no-rec .jrow { grid-template-columns: var(--w-time) 1fr max-content; grid-template-areas: "time status first" ". phone phone" ". channel channel"; row-gap: var(--sp-1); }
  .jrow .c-time { grid-area: time; } .jrow .c-status { grid-area: status; } .jrow .c-phone { grid-area: phone; }
  .jrow .c-channel { grid-area: channel; color: var(--ink-2); } .jrow .c-first { grid-area: first; color: var(--ink-2); } .jrow .c-rec { display: none; }
  .rlist { display: flex; flex-direction: column; }
  .rrow { grid-template-columns: minmax(0, 1fr); grid-template-areas: "wait" "mid" "right" "acts"; row-gap: var(--sp-1); padding: var(--sp-2) var(--sp-1); }
  .r-wait { grid-area: wait; } .r-mid { grid-area: mid; } .r-right { grid-area: right; flex-direction: row; gap: var(--sp-3); }
  .r-acts { grid-area: acts; } .rrow .r-acts .btn { flex: 1; }
  .r-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--sp-1); }
  .r-filters > * { flex: none; }
  .r-filters .chips { flex-wrap: nowrap; }
  #sec-reply .card-head { flex-wrap: nowrap; }
  #sec-reply .r-search-btn { display: inline-flex; }
  #sec-reply #r-search-pick { display: none; }
  #sec-reply.search-open #r-search-pick { display: inline-flex; }
  #sec-reply .r-search-label { display: none; }
  #sec-reply .btn .long { display: none; } #sec-reply .btn .short { display: inline; }
}
