/* The staff workplace and the client's cabinet: layout, lists and forms. Colours, sizes and fonts come from the site's
   tokens.css (copied by cabinet/deploy.sh into static/site/), so both look the same. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fw-regular) var(--fs-sm)/var(--lh-body, 1.55) var(--font-sans); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: var(--lh-head); }
h1 { font: var(--fw-medium) var(--fs-h3)/var(--lh-head) var(--font-serif); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
a { color: var(--accent); }
img { max-width: 100%; }
.w-hide { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: var(--border-bold) solid var(--focus); outline-offset: var(--border); }

/* ---- Top bar ------------------------------------------------------------------- */
.w-top { position: sticky; top: 0; z-index: var(--z-header); background: var(--header-bg); backdrop-filter: blur(var(--space-3)); border-bottom: var(--border) solid var(--line); }
.w-top-in { display: flex; align-items: center; gap: var(--space-5); min-height: calc(var(--header-h, 64px) - var(--space-2)); max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.w-brand { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--ink); }
.w-brand span { font: var(--fw-semibold) var(--fs-lg)/1 var(--font-serif); color: var(--wordmark, var(--ink)); }
.w-brand small { padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.w-brand-big { justify-content: center; margin: 0; }
.w-nav { display: flex; gap: var(--space-1); margin-right: auto; }
.w-nav a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: var(--fw-medium); white-space: nowrap; }
.w-nav-plus { display: none; font-weight: var(--fw-bold); }
.w-nav a:hover { background: var(--surface-2); }
.w-nav a[aria-current] { background: var(--sidebar-active-bg); font-weight: var(--fw-bold); }
.w-me { position: relative; }
.w-me > summary { list-style: none; cursor: pointer; }
.w-me > summary::-webkit-details-marker { display: none; }
.ava { width: var(--icon-btn); height: var(--icon-btn); display: inline-grid; place-items: center; border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); font-weight: var(--fw-bold); }
.w-me-menu { position: absolute; right: 0; top: calc(100% + var(--space-2)); min-width: calc(var(--space-11) * 2 + var(--space-7)); display: grid; gap: var(--space-1); padding: var(--space-2); background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); }
.w-me-menu a, .w-me-menu form button { display: block; width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); text-align: left; text-decoration: none; font: inherit; cursor: pointer; }
.w-me-menu a:hover, .w-me-menu form button:hover { background: var(--surface-2); }
.w-me-who { display: grid; gap: var(--space-1); margin: 0 0 var(--space-1); padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: var(--border) solid var(--line); }
.w-me-who small { color: var(--muted); overflow-wrap: anywhere; }
.w-theme { display: flex; gap: var(--space-2); padding: var(--space-1) var(--space-2); }
.w-theme button { width: var(--icon-btn); height: var(--icon-btn); display: grid; place-items: center; border: var(--border) solid transparent; border-radius: var(--radius-pill); background: none; color: var(--nav-icon); cursor: pointer; }
.w-theme button svg { width: var(--icon); height: var(--icon); }
.w-theme button[aria-pressed="true"] { border-color: var(--pick-line); box-shadow: inset 0 0 0 var(--border) var(--pick-line); }

/* ---- Page ------------------------------------------------------------------------ */
.w-main { max-width: calc(var(--container) + 2 * var(--gutter)); margin-inline: auto; padding: var(--space-6) var(--gutter) var(--space-10); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); }   /* minmax: a long option in a select must not widen the page */
.w-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }
.w-head h1 { margin-right: auto; }
.w-crumbs { color: var(--muted); font-size: var(--fs-xs); }
.w-card { background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); display: grid; gap: var(--space-4); align-content: start; box-shadow: var(--shadow-card); }
.w-narrow { max-width: calc(var(--space-11) * 5); }
.w-center { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6) var(--gutter); }
.w-login-card { width: 100%; max-width: calc(var(--space-11) * 4 + var(--space-6)); }
.w-login-card h1 { text-align: center; font-size: var(--fs-h4); }
.w-form-stack { display: grid; gap: var(--space-3); }
.w-trap { position: absolute; left: -100vw; width: 1px; height: 1px; overflow: hidden; }     /* a field only robots fill */
.w-or { display: flex; align-items: center; gap: var(--space-3); margin: 0; color: var(--muted); font-size: var(--fs-xs); }
.w-or::before, .w-or::after { content: ""; flex: 1; border-top: var(--border) solid var(--line); }
.w-note { color: var(--muted); font-size: var(--fs-xs); margin: 0; }
.w-empty { color: var(--muted); }
.w-error { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--status-err-bg); color: var(--status-err-fg); }
.w-ok { margin: 0; padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--status-ok-bg); color: var(--status-ok-fg); }

/* ---- Controls ----------------------------------------------------------------------- */
.w-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 var(--space-5); border: var(--border) solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font: var(--fw-bold) var(--fs-sm)/1.2 var(--font-sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.w-btn:hover { border-color: var(--ink); }
.w-btn[disabled] { opacity: .5; cursor: not-allowed; }
.w-btn[hidden] { display: none; }                  /* the «Сохранить» of a choice that saves itself (worker.js) */
.w-btn-sm { min-height: var(--control-h-sm); padding: 0 var(--space-4); font-size: var(--fs-xs); }
.w-btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.w-btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.w-btn-quiet { border-color: transparent; background: none; color: var(--accent); }
.w-btn-quiet:hover { background: var(--surface-2); border-color: transparent; }
.w-btn-ok { border-color: var(--mark-ok); color: var(--mark-ok); }
.w-btn-err { border-color: var(--mark-fix); color: var(--mark-fix); }
.w-link { color: var(--accent); }
.w-input { width: 100%; min-height: var(--control-h-sm); padding: var(--space-2) var(--space-3); border: var(--border) solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
textarea.w-input { resize: vertical; }
.w-field { display: grid; gap: var(--space-1); }
.w-field > span, .w-label { color: var(--muted); font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; margin: 0; }
.w-check { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) 0; cursor: pointer; }
.w-check input { width: var(--icon); height: var(--icon); accent-color: var(--primary); }
.w-fs { border: var(--border) solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: grid; gap: var(--space-3); margin: 0; min-width: 0; }
.w-fs legend { padding: 0 var(--space-2); color: var(--ink); font-weight: var(--fw-bold); }
.w-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.w-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--space-11) * 3)), 1fr)); gap: var(--space-4); }
.w-form { max-width: calc(var(--space-11) * 9); }
.w-badge { display: inline-block; padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-2xs); font-weight: var(--fw-bold); }
.w-badge.tone-wait { background: var(--status-wait-bg); color: var(--status-wait-fg); }
.w-badge.tone-err { background: var(--status-err-bg); color: var(--status-err-fg); }

/* ---- Start page: counters, funnel, the list ------------------------------------------------- */
.w-counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--space-11) * 2 + var(--space-6))), 1fr)); gap: var(--space-3); }
.w-counter { display: grid; gap: var(--space-1); padding: var(--space-4); border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); text-decoration: none; }
.w-counter b { font: var(--fw-num) var(--fs-h3)/1 var(--font-num); letter-spacing: var(--ls-num); }
.w-counter span { color: var(--muted); font-size: var(--fs-xs); }
.w-counter.is-on, .w-stage.is-on { border-color: var(--accent); background: var(--sidebar-active-bg); }
.w-counter.is-urgent { border-color: var(--status-err-fg); background: var(--status-err-bg); }
.w-counter.is-urgent span { color: var(--status-err-fg); }
.w-refund { display: grid; gap: var(--space-2); margin-top: var(--space-3); padding-top: var(--space-3); border-top: var(--border) solid var(--line); }
.w-refund h3 { margin: 0; font-size: var(--fs-base); }
.w-refund-sum { margin: 0; }
.w-refund-sum b { font-size: var(--fs-lg); }
.w-alert a { color: inherit; font-weight: var(--fw-bold); }
.w-funnel { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-1); }
.w-stage { flex: 1 0 auto; min-width: calc(var(--space-11) + var(--space-5)); display: grid; gap: var(--space-1); padding: var(--space-3); border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); text-decoration: none; }
.w-stage b { font: var(--fw-num) var(--fs-lg)/1 var(--font-num); }
.w-stage span { font-size: var(--fs-2xs); color: var(--muted); }
.w-stage.is-empty { opacity: .6; }
.w-search { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2) var(--space-3); }
.w-search .w-input { flex: 1 1 calc(var(--space-11) * 3); }
.w-table { width: 100%; border-collapse: collapse; background: var(--surface); border: var(--border) solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.w-table th, .w-table td { padding: var(--space-3); border-bottom: var(--border) solid var(--line); text-align: left; vertical-align: top; }
.w-table th { color: var(--muted); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.w-case-link { display: grid; gap: var(--space-1); text-decoration: none; color: var(--ink); }
.w-case-link small { color: var(--muted); }
.w-turn { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-pill); font-size: var(--fs-2xs); font-weight: var(--fw-bold); }
.turn-us { background: var(--status-err-bg); color: var(--status-err-fg); }          /* our move: stands out */
.turn-client { background: var(--surface-2); color: var(--muted); }
.turn-authority { background: var(--status-wait-bg); color: var(--status-wait-fg); }
.turn-wait { background: var(--status-wait-bg); color: var(--status-wait-fg); }            /* 14 days to withdraw: not ours yet */
.w-pays { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.w-pay { padding: 0 var(--space-2); border-radius: var(--radius-pill); border: var(--border) dashed var(--line-strong); color: var(--muted); font-size: var(--fs-2xs); }
.w-pay.is-paid { border-style: solid; border-color: var(--mark-ok); color: var(--mark-ok); }
.w-pay.is-issued { border-style: solid; border-color: var(--mark-edited); color: var(--mark-edited); }   /* invoiced, not paid */
.w-stage-all { border-style: dashed; }
@media (max-width: 760px) {
  .w-table, .w-table tbody, .w-table tr, .w-table td { display: block; width: 100%; }
  .w-table thead { display: none; }
  .w-table tr { padding: var(--space-3); border-bottom: var(--border) solid var(--line); }
  .w-table td { border: 0; padding: var(--space-1) 0; }
  .w-table td::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-2xs); }
  .w-table td:first-child::before { content: none; }
  .w-nav a { padding-inline: var(--space-2); }
  .w-brand small { display: none; }
}

/* ---- Case page ---------------------------------------------------------------------------- */
.w-stage-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); }
.w-stage-form label { display: grid; gap: var(--space-1); }
.w-share { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.w-share form { display: contents; }
.w-letters { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.w-letters li { display: grid; gap: var(--space-1); justify-items: start; }
.w-letters small { color: var(--muted); font-size: var(--fs-2xs); overflow-wrap: anywhere; }
.w-saved { align-self: center; color: var(--mark-ok); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.w-sort { flex: 0 1 auto; }
.w-sort .w-input { width: auto; }
.w-stage-form label span { color: var(--muted); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); font-weight: var(--fw-bold); }
.w-case { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-items: start; }
@media (min-width: 1100px) { .w-case { grid-template-columns: minmax(0, 1fr) calc(var(--space-11) * 3 + var(--space-6)); } .w-case-side { position: sticky; top: calc(var(--header-h, 64px) + var(--space-4)); max-height: calc(100vh - var(--header-h, 64px) - var(--space-6)); overflow: auto; } }
.w-case-side { display: grid; gap: var(--space-4); }
.w-dl { margin: 0; display: grid; gap: var(--space-1); }
.w-dl div { display: grid; grid-template-columns: calc(var(--space-11) - var(--space-3)) minmax(0, 1fr); gap: var(--space-2); }
.w-dl dt { color: var(--muted); }
.w-dl dd { margin: 0; overflow-wrap: anywhere; }
.w-paylist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.w-payrow { display: grid; gap: var(--space-2); padding-bottom: var(--space-3); border-bottom: var(--border) solid var(--line); }
.w-payhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); }
.w-payhead span { font: var(--fw-num) var(--fs-sm)/1.3 var(--font-num); letter-spacing: var(--ls-num); }
.w-paid { margin: 0; color: var(--mark-ok); }
.w-payform { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); }
.w-payform input[name="note"], .w-payform button { grid-column: 1 / -1; }
.w-undo summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); }
.w-log { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); font-size: var(--fs-xs); color: var(--muted); }
.w-log time { color: var(--ink); font-family: var(--font-num); }

/* ---- Messages and dialogs ------------------------------------------------------------------------ */
.w-toast { position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 2 * var(--space-4)); padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-card); }
.w-dialog { border: var(--border) solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: var(--space-5); width: min(100% - 2 * var(--space-4), calc(var(--space-11) * 5)); box-shadow: var(--shadow-card); }
.w-dialog::backdrop { background: color-mix(in srgb, var(--ink) 40%, transparent); }
.w-dialog form { display: grid; gap: var(--space-4); }
.w-dialog-bar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.w-reasons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.w-reasons textarea { flex-basis: 100%; }
.w-chip { padding: var(--space-1) var(--space-3); border: var(--border) solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.w-chip.is-on { background: var(--status-err-bg); border-color: var(--mark-fix); color: var(--status-err-fg); }
.w-targets { display: grid; gap: var(--space-1); max-height: 50vh; overflow: auto; }
.w-waiting { margin: var(--space-2) 0 0; padding-left: var(--space-5); }

/* ---- Password with an eye, rows of buttons, the case's service and stage, invoices ------------------- */
.w-pw { position: relative; display: block; }
.w-pw .w-input { padding-right: calc(var(--icon-btn) + var(--space-2)); }
.w-eye { position: absolute; right: var(--space-1); top: 50%; transform: translateY(-50%); width: var(--icon-btn); height: var(--icon-btn); display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm); }
.w-eye svg { width: var(--icon); height: var(--icon); }
.w-eye[aria-pressed="true"] { color: var(--accent); }
.w-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.w-case-meta { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-6); }
.w-inv { margin: 0; color: var(--mark-edited); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }

/* ---- The register of documents; the new case's list ------------------------------------------------- */
.w-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-4); }
.w-check-sub { font-size: var(--fs-xs); color: var(--muted); }
.w-reg-group { display: grid; gap: var(--space-3); }
.w-reg-item > summary, .w-reg-new > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); list-style: none; }
.w-reg-item > summary::-webkit-details-marker, .w-reg-new > summary::-webkit-details-marker { display: none; }
.w-reg-item > summary small { flex-basis: 100%; color: var(--muted); font-size: var(--fs-xs); }
.w-reg-item.is-off { opacity: .6; }
.w-reg-form { display: grid; gap: var(--space-3); margin-top: var(--space-3); }

/* ---- Links to the client's cabinet (staff) and the client's own pages ---------------------------- */
.w-link { display: grid; gap: var(--space-2); padding-top: var(--space-3); border-top: var(--border) solid var(--line); }
.w-link-row { display: flex; gap: var(--space-2); }
.w-link-row .w-input { flex: 1 1 auto; min-width: 0; font-size: var(--fs-xs); }
.w-inv-x { margin: 0; color: var(--muted); font-size: var(--fs-xs); }
.w-inv-x s { color: var(--muted); }
.c-meta { margin: calc(var(--space-4) * -1) 0 0; color: var(--muted); }
.c-meta b { color: var(--ink); }
.c-contacts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.w-google { gap: var(--space-3); background: var(--google-bg); color: var(--google-ink); border-color: var(--google-line); }
.w-google:hover { background: color-mix(in srgb, var(--google-ink) 8%, var(--google-bg)); border-color: var(--google-line); color: var(--google-ink); }
.g-logo { width: var(--icon); height: var(--icon); padding: var(--space-1); box-sizing: content-box; background: var(--google-g-bg); border-radius: var(--radius-pill); }
.g-r { fill: var(--google-red); }
.g-b { fill: var(--google-blue); }
.g-y { fill: var(--google-yellow); }
.g-g { fill: var(--google-green); }

/* A phone: the staff bar keeps the W icon and the menu; the name and «Новое дело» in words do not fit next to it. */
@media (max-width: 560px) {
  .w-top-staff .w-top-in { gap: var(--space-2); }
  .w-top-staff .w-brand span { display: none; }
  .w-top-staff .w-nav-text { display: none; }
  .w-top-staff .w-nav-plus { display: inline; padding-inline: var(--space-1); }
}

/* ---- Contract: the editor next to the text, the text itself, the signature box ------------------ */
.w-badge.tone-ok { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.w-letters li.is-off { opacity: .6; }
.w-contract { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-items: start; }   /* a phone: never wider than the screen */
@media (min-width: 1100px) { .w-contract { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } .w-contract-client { grid-template-columns: minmax(0, 1fr); max-width: calc(var(--space-11) * 10); } }
.w-priced { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); }
.w-priced > .w-input { flex: 1 1 calc(var(--space-11) * 3); }
.w-price { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--muted); }
.w-price .w-input { width: calc(var(--space-11) + var(--space-4)); text-align: right; }
.w-parts { display: grid; gap: var(--space-2); }
.w-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.w-paper { display: grid; gap: var(--space-3); line-height: var(--lh-body, 1.55); }
.w-paper h3 { margin: var(--space-3) 0 0; font-size: var(--fs-base); color: var(--primary); }
.w-paper p, .w-paper ul { margin: 0; }
.w-paper ul { padding-left: var(--space-5); display: grid; gap: var(--space-1); }
.w-paper-title { margin: 0; font: var(--fw-semibold) var(--fs-h4)/1.2 var(--font-serif); color: var(--primary); }
.w-paper-meta { color: var(--muted); font-size: var(--fs-xs); }
.w-paper-table { width: 100%; border-collapse: collapse; }
.w-paper-table th, .w-paper-table td { padding: var(--space-2) 0; border-bottom: var(--border) solid var(--line); text-align: left; vertical-align: top; }
.w-paper-table th { color: var(--muted); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.w-paper-table td + td, .w-paper-table th + th { text-align: right; white-space: nowrap; padding-left: var(--space-3); }
.w-paper-table .is-total td { font-weight: var(--fw-bold); border-bottom: 0; }
.w-paper-signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--space-11) * 3)), 1fr)); gap: var(--space-5); margin-top: var(--space-3); }
.w-paper-signs div { display: grid; gap: var(--space-1); align-content: end; min-width: 0; padding-bottom: var(--space-2); border-bottom: var(--border) solid var(--ink); }
.w-paper-signs span { color: var(--muted); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--ls-caps); }
.w-paper-signs img { width: auto; height: auto; min-width: 0; max-width: 100%; max-height: calc(var(--space-11) + var(--space-4)); justify-self: start; background: var(--c-white); border-radius: var(--radius-sm); }
.w-paper-signs i { color: var(--muted); font-size: var(--fs-xs); min-height: var(--space-8); display: flex; align-items: end; }
.w-sign-form { display: grid; gap: var(--space-3); }
.w-sign-form .w-btn { white-space: normal; text-align: center; padding-block: var(--space-2); }   /* «Подписать дополнительное соглашение» on 360 px */
.w-team { display: grid; gap: var(--space-3); }                       /* Settings → «Сотрудники»: one form per person */
.w-team + .w-team { border-top: var(--border) solid var(--line); padding-top: var(--space-4); }
.w-team h3 { font-size: var(--fs-base); }
.w-team .w-btn { justify-self: start; }
.w-code-form { display: grid; gap: var(--space-3); }                 /* the code from the letter (login_code.html) */
.w-code { font-family: var(--font-num); font-size: var(--fs-lg); letter-spacing: 0.3em; }
.w-sign { position: relative; height: calc(var(--space-11) * 2); border: var(--border) dashed var(--line-strong); border-radius: var(--radius-md); background: var(--c-white); touch-action: none; }
.w-sign canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: var(--radius-md); cursor: crosshair; touch-action: none; }
.w-sign-line { position: absolute; left: var(--space-5); right: var(--space-5); bottom: var(--space-8); border-top: var(--border) solid var(--line); pointer-events: none; }
.w-sign-clear { position: absolute; top: var(--space-2); right: var(--space-2); width: var(--icon-btn); height: var(--icon-btn); display: grid; place-items: center; border: var(--border) solid var(--line); border-radius: var(--radius-pill); background: var(--c-white); color: var(--c-ink); font-size: var(--fs-lg); cursor: pointer; z-index: 1; }
.w-sign-now { max-width: 100%; max-height: calc(var(--space-11) + var(--space-4)); justify-self: start; background: var(--c-white); border: var(--border) solid var(--line); border-radius: var(--radius-sm); }
.w-early { align-items: flex-start; }
.w-early-choice { display: grid; gap: var(--space-2); }
.w-receipt { display: grid; gap: var(--space-2); }
.w-receipt p { margin: 0; }
.w-receipt [lang] { display: grid; gap: var(--space-1); }
.w-receipt [lang] + [lang] { padding-top: var(--space-2); border-top: var(--border) solid var(--line); color: var(--muted); }
.w-receipt.is-fresh { border-color: var(--primary); box-shadow: inset 0 0 0 var(--border) var(--primary), var(--shadow-card); }
.w-revoke { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); justify-items: start; }
.w-revoke .w-btn { white-space: normal; text-align: center; padding-block: var(--space-2); }   /* two languages on a 360 px phone */
.w-revoke form { justify-self: stretch; }
.w-early-choice legend { font-weight: var(--fw-bold); }
.w-early b span + span, .w-early-choice legend span + span { font-weight: var(--fw-regular); color: var(--muted); }
.w-early b { color: var(--ink); }
.w-warn { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--status-wait-bg); color: var(--status-wait-fg); }
.w-early input { flex: none; margin-top: var(--space-1); }
.w-early > span { display: grid; gap: var(--space-1); }
.w-early > span > span { color: var(--muted); font-size: var(--fs-xs); }
.w-early-paid { display: grid; gap: var(--space-1); margin: 0; }   /* «we start only after the payment», in each language of the paper */
.w-early-paid span + span { color: var(--muted); }
.c-contract.is-due { border-color: var(--primary); box-shadow: inset 0 0 0 var(--border) var(--primary), var(--shadow-card); }
/* Two languages: side by side from tablet width, German on the left; on a phone the second one under the first, quieter. */
.w-paper-row { display: grid; gap: var(--space-2); }
.w-paper-row p { white-space: pre-line; }
.w-paper-table span { display: block; }
.w-paper.is-two .w-paper-table span + span { color: var(--muted); font-size: var(--fs-xs); }
.w-paper.is-two .w-paper-row > div + div { color: var(--muted); padding-left: var(--space-3); border-left: var(--border) solid var(--line); }
@media (min-width: 760px) {
  .w-paper.is-two .w-paper-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); }
  .w-paper.is-two .w-paper-row > div + div { color: inherit; }
}

/* ---- «Источники сайта»: statements and their official sources (site_sources.py) ------------------- */
.w-src-page h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-3); margin: 0; font-size: var(--fs-lg); }
.w-src-url { color: var(--accent); font-size: var(--fs-xs); font-weight: var(--fw-regular); overflow-wrap: anywhere; }
.w-src-list { margin: 0; padding-left: var(--space-5); display: grid; gap: var(--space-4); }
.w-src-list li { display: grid; gap: var(--space-1); }
.w-src-list p { margin: 0; }
.w-src-meta { color: var(--muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.w-src-quote { color: var(--muted); font-size: var(--fs-xs); font-style: italic; overflow-wrap: anywhere; }

/* ---- «Руководство по ситуациям» (guide.py): long text to read — a narrow column, bigger type, the chapters at the side ---- */
.g-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.g-side { display: none; }
.g-toc-phone { margin-bottom: var(--space-4); border: var(--border) solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.g-toc-phone > summary { padding: var(--space-3) var(--space-4); cursor: pointer; font-weight: var(--fw-bold); color: var(--ink); }
.g-toc-phone[open] > summary { border-bottom: var(--border) solid var(--line); }
.g-toc-phone .g-search, .g-toc-phone .g-chapters { margin: var(--space-3) var(--space-4); }
@media (min-width: 1000px) {
  .g-wrap { grid-template-columns: calc(var(--space-11) * 4) minmax(0, 1fr); }
  .g-side { display: block; position: sticky; top: calc(var(--header-h, 64px) + var(--space-4)); max-height: calc(100vh - var(--header-h, 64px) - var(--space-6)); overflow: auto; padding-right: var(--space-2); }
  .g-toc-phone { display: none; }
}
.g-search { margin-bottom: var(--space-3); }
.g-search .w-input { width: 100%; }
.g-chapters, .g-sit, .g-found { list-style: none; margin: 0; padding: 0; }
.g-chapters a { display: block; padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: var(--fs-xs); line-height: 1.35; }
.g-chapters a:hover { background: var(--surface-2); }
.g-chapters a[aria-current] { background: var(--sidebar-active-bg); font-weight: var(--fw-bold); }
.g-sit { margin: var(--space-1) 0 var(--space-2) var(--space-3); border-left: var(--border) solid var(--line); }
.g-sit a { color: var(--muted); font-size: var(--fs-2xs); }
.g-doc { max-width: calc(var(--space-11) * 9); font-size: var(--fs-base); line-height: 1.65; color: var(--text); }
.g-doc h1 { font: var(--fw-medium) var(--fs-h3)/var(--lh-head) var(--font-serif); margin: 0 0 var(--space-5); }
.g-ins { padding: 0 2px; border-radius: var(--radius-xs, 3px); background: var(--accent-soft); box-decoration-break: clone; -webkit-box-decoration-break: clone; }   /* a fact shown from «Ратуши» */
.g-ins-list { display: block; margin: var(--space-2) 0; padding: var(--space-2) var(--space-3); border-left: 2px solid var(--accent); background: var(--surface-2); }
.g-ins-list ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); }
.g-ins > a:first-child { font-weight: var(--fw-bold); }
.g-ins-missing { color: var(--status-err-fg); }
.g-doc h2 { margin: var(--space-8) 0 var(--space-3); font-size: var(--fs-lg); scroll-margin-top: calc(var(--header-h, 64px) + var(--space-3)); }
.g-doc h3 { margin: var(--space-7) 0 var(--space-3); padding-top: var(--space-5); border-top: var(--border) solid var(--line); font-size: var(--fs-lg); scroll-margin-top: calc(var(--header-h, 64px) + var(--space-3)); }
.g-doc h4 { margin: var(--space-5) 0 var(--space-2); font-size: var(--fs-base); color: var(--ink); }
.g-doc p, .g-doc ul, .g-doc ol { margin: 0 0 var(--space-3); }
.g-doc ul, .g-doc ol { padding-left: var(--space-5); }
.g-doc li { margin: var(--space-1) 0; }
.g-doc li > p { margin: 0; }
.g-doc strong { color: var(--ink); }
.g-doc blockquote { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-4); border-left: var(--border-bold) solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.g-doc code { font-size: .9em; padding: 0 var(--space-1); border-radius: var(--radius-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.g-doc pre { overflow: auto; padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-2); }
.g-doc pre code { padding: 0; background: none; }
.g-doc a { overflow-wrap: anywhere; }
.g-table { overflow-x: auto; margin: 0 0 var(--space-4); }
.g-doc table { border-collapse: collapse; font-size: var(--fs-xs); line-height: 1.45; min-width: 100%; }
.g-doc th, .g-doc td { padding: var(--space-2); border: var(--border) solid var(--line); vertical-align: top; text-align: left; }
.g-doc th { background: var(--surface-2); color: var(--ink); }
.g-anchor { margin-left: var(--space-1); color: var(--muted); text-decoration: none; opacity: 0; }
.g-doc h3:hover .g-anchor, .g-anchor:focus-visible { opacity: 1; }
.g-foot { margin-top: var(--space-8); padding-top: var(--space-4); border-top: var(--border) solid var(--line); color: var(--muted); font-size: var(--fs-xs); }
.g-found li { padding: var(--space-3) 0; border-bottom: var(--border) solid var(--line); }
.g-found small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.g-found p { margin: var(--space-1) 0 0; font-size: var(--fs-sm); }
.g-found mark, .g-doc mark { background: var(--accent-soft); color: inherit; border-radius: var(--radius-sm); }
.w-nav-book { display: none; }
@media (max-width: 560px) { .w-top-staff .w-nav-book { display: inline; padding-inline: var(--space-1); } }

/* ---- «Ратуши» (townhalls.html, townhalls.js): every town hall in one table, like a spreadsheet ---------------- */
.w-wide .w-main { max-width: none; padding-inline: var(--space-3); }
/* A page that fills the screen («Ратуши»: the table, the map): the page itself does not scroll, the table scrolls
   inside, so its lower edge with the scroll bar is always at the bottom of the screen (owner, 2026-11-09: «нижней
   границы таблицы не видно… она всегда должна быть»). A screen too low for it scrolls as before. */
@media (min-height: 480px) {
  .w-fill { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .w-fill > .w-top { flex: none; }
  .w-fill > .w-main { flex: 1 1 auto; min-height: 0; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; padding-top: var(--space-3); padding-bottom: var(--space-2); }
  .w-fill .th-page { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  /* never squeezed to nothing: on a screen too low for the head and the table the page scrolls a little */
  .w-fill .th-wrap, .w-fill .th-map { flex: 1 1 auto; min-height: min(60vh, 20rem); max-height: none; height: auto; }
}
.th-page { display: grid; gap: var(--space-3); min-width: 0; }
/* ---- «Ратуши»: the page header and the filter panel (townhalls.html, townhalls_map.html; design/spec.md) -------------
   One header for the table and the map, two rows. Row 1: the title with its count, the search, then on the right the
   bot's status with «Обновить» and the tools of the view. Row 2, under the title: the view as two icons, table and map,
   right before «Фильтры» (owner, 2026-11-09: «слово ратуши чуть подними, А перед фильтры поставь значок карты»), then
   «Фильтры» and the filters that are on, each with its ✕. The panel opens under row 2. The header is low, so the table (or the map) takes the rest of the screen
   (.w-fill) and its scroll bar stays at the bottom of the screen (owner, 2026-11-09).
   The dropdowns are <details>: they open and close without JavaScript; an open one lays an invisible layer over the
   page (summary::before), so a click anywhere else closes it. Esc and the ✕ of the phone sheet: townhalls-head in
   worker.js. Colours, sizes and fonts: only tokens.css (and --mark-* of docs.css). */

.th-head { display: grid; gap: var(--space-2); min-width: 0; }
.th-bar, .th-bar2 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); min-width: 0; }
.th-bar2 { position: relative; }        /* the filter panel hangs from row 2 */
.th-bar-side { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-left: auto; min-width: 0; }
.th-head form { margin: 0; }

/* Title and how many town halls are shown */
.th-title { display: inline-flex; align-items: baseline; gap: var(--space-2); margin: 0; font: var(--fw-medium) var(--fs-h4)/var(--lh-snug) var(--font-serif); white-space: nowrap; }
.th-count { color: var(--muted); font: var(--fw-num) var(--fs-sm)/1 var(--font-num); letter-spacing: var(--ls-num); }

/* The view under the title (two icons: table, map) and every «one of» choice in the panel: a track, the chosen part filled */
.th-views, .th-seg { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1); border: var(--border) solid var(--line); border-radius: var(--radius-pill); background: var(--surface); }
.th-views { padding: calc(var(--space-1) / 2); }
.th-views a { display: grid; place-items: center; width: var(--space-8); height: var(--space-7); border-radius: var(--radius-pill); color: var(--muted); text-decoration: none; }
.th-views a:hover { background: var(--surface-2); color: var(--ink); }
.th-views a[aria-current] { background: var(--primary); color: var(--on-primary); }
.th-head .th-views svg { width: var(--icon); height: var(--icon); }
@media (pointer: coarse) { .th-views a { width: var(--icon-btn); height: var(--icon-btn); } }

/* Search: Enter or the magnifier sends it, with the filters of the panel: one form (#th-filter in row 2; the search
   field and its button belong to it through form="th-filter") */
.th-find { display: flex; align-items: center; }
.th-search { position: relative; flex: 1 1 calc(var(--space-11) * 2 + var(--space-6)); max-width: calc(var(--space-11) * 3 + var(--space-6)); min-width: 0; }
.th-search .w-input { width: 100%; padding-left: var(--icon-btn); }
.th-search-go { position: absolute; top: 0; bottom: 0; left: 0; width: var(--icon-btn); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; }
.th-search-go:hover { color: var(--ink); }

/* Icons in the header: _icon_*.html, stroke = currentColor */
.th-head svg { width: var(--icon-sm); height: var(--icon-sm); flex: none; }
.th-search-go svg, .th-icon-only svg, .th-x svg { width: var(--icon); height: var(--icon); }

/* A dropdown: <details class="th-dd"> with a .w-btn as its summary and a .th-dd-box */
.th-dd > summary { list-style: none; }
.th-dd > summary::-webkit-details-marker { display: none; }
.th-dd[open] > summary { background: var(--sidebar-active-bg); border-color: var(--accent); color: var(--ink); }
.th-dd[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: var(--z-menu); cursor: default; }   /* a click outside closes */
.th-dd-own { position: relative; }      /* a small box under its own button; without it the box hangs from the whole .th-bar */
.th-dd-box { position: absolute; z-index: var(--z-menu); top: calc(100% + var(--space-2)); background: var(--surface); color: var(--text); border: var(--border) solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-menu); }
.th-dd-own > .th-dd-box { right: 0; }
.th-caret { transition: transform var(--dur-fast) var(--ease); }
.th-dd[open] .th-caret { transform: rotate(180deg); }

/* «Фильтры» and the number of filters that are on */
.th-fbtn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.th-badge { display: inline-grid; place-items: center; min-width: var(--space-5); height: var(--space-5); padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); font: var(--fw-bold) var(--fs-2xs)/1 var(--font-num); }

/* The filter panel: under the header row, over the table or the map, never pushing them down */
.th-fpanel { left: 0; width: min(100%, var(--container)); max-height: calc(100dvh - var(--header-h) - 2 * var(--control-h-sm) - var(--space-8)); display: flex; flex-direction: column; overflow: hidden; }
.th-fpanel-head { position: absolute; top: var(--space-2); right: var(--space-2); }   /* a computer: only the ✕ in the corner */
.th-fpanel-head h2 { display: none; margin-right: auto; font: var(--fw-medium) var(--fs-h4)/1 var(--font-serif); }
.th-x { width: var(--icon-btn); height: var(--icon-btn); display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--radius-pill); background: none; color: var(--muted); cursor: pointer; }
.th-x:hover { background: var(--surface-2); color: var(--ink); }
.th-fgrid { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5) var(--space-7); padding: var(--space-5) var(--space-6); }
.th-fcol { display: grid; gap: var(--space-4); align-content: start; min-width: 0; }
.th-fwide { grid-column: 1 / -1; }
.th-fg { min-width: 0; margin: 0; padding: 0; border: 0; }
.th-fg > legend { padding: 0; margin-bottom: var(--space-2); color: var(--muted); font-size: var(--fs-2xs); font-weight: var(--fw-bold); letter-spacing: var(--ls-caps); text-transform: uppercase; }
.th-fg .th-fg { margin-top: var(--space-3); }
.th-fg .th-fg > legend { margin-bottom: var(--space-1); color: var(--ink); font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: normal; text-transform: none; }
.th-hint { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--fs-2xs); }
.th-fpanel-foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-6); border-top: var(--border) solid var(--line); background: var(--surface-2); }
.th-fpanel-note { margin: 0 0 0 auto; color: var(--muted); font-size: var(--fs-2xs); }

/* An option: the real checkbox or radio lies over its pill, invisible, so a click, Space and the arrows work as usual.
   Apart from each other = «можно несколько» (checkbox); inside a .th-seg track = «одно из» (radio). */
.th-opts { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.th-opt { position: relative; display: inline-flex; }
.th-opt > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.th-opt > span { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); min-height: var(--space-7); padding: 0 var(--space-3); border: var(--border) solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font: var(--fw-medium) var(--fs-xs)/1.2 var(--font-sans); white-space: nowrap; }
.th-opt:hover > span { border-color: var(--line-strong); }
.th-opt > input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.th-opts .th-opt > input:checked + span::before { content: "✓"; font-weight: var(--fw-bold); }
.th-opt > input:focus-visible + span { outline: var(--border-bold) solid var(--focus); outline-offset: var(--border); }
.th-days .th-opt > span { min-width: var(--icon-btn); }
.th-seg .th-opt > span { min-height: calc(var(--space-7) - 2 * var(--space-1)); padding: 0 var(--space-2); border-color: transparent; }
.th-seg .th-opt:hover > span { background: var(--surface-2); }
.th-seg .th-opt-any > input:checked + span { background: var(--surface-2); border-color: var(--line); color: var(--ink); }   /* «любые», «не важно»: chosen, filters nothing */

/* «Текст в колонке»: column + «содержит» + text; one empty line more for a new condition */
.th-cond { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); max-width: calc(var(--space-11) * 6); }
.th-cond + .th-cond { margin-top: var(--space-2); }
.th-cond .w-input { width: auto; min-width: 0; }
.th-cond select.w-input { flex: 0 1 calc(var(--space-11) * 2); }
.th-cond input.w-input { flex: 1 1 calc(var(--space-11) * 2); }
.th-cond span { color: var(--muted); font-size: var(--fs-xs); }

/* Row 2, after «Фильтры»: the filters that are on, by group; each ✕ removes only its own (owner's rule) */
.th-applied { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--fs-xs); }
.th-applied-grp { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }   /* a group's name stays with its first value */
.th-applied-g { color: var(--muted); font-weight: var(--fw-semibold); }
.th-tag { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--space-6); padding: 0 var(--space-1) 0 var(--space-3); border: var(--border) solid var(--accent); border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--ink); font-weight: var(--fw-semibold); text-decoration: none; white-space: nowrap; }
.th-tag-x { display: inline-grid; place-items: center; width: var(--space-5); height: var(--space-5); border-radius: var(--radius-pill); color: var(--accent); }
.th-head .th-tag-x svg { width: var(--space-3); height: var(--space-3); }
.th-tag:hover { border-color: var(--status-err-fg); }
.th-tag:hover .th-tag-x { background: var(--status-err-bg); color: var(--status-err-fg); }
.th-applied-reset { color: var(--accent); font-weight: var(--fw-bold); }

/* The bot's status and «Обновить» (#th-status: townhalls.js swaps it when the status changes) */
.th-live { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.th-bot { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; margin: 0; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.th-bot.is-off { color: var(--status-err-fg); font-weight: var(--fw-semibold); }
.th-dot { width: var(--space-2); height: var(--space-2); flex: none; margin-left: var(--space-1); border-radius: var(--radius-pill); background: var(--muted); }
.th-bot.is-ok .th-dot { background: var(--mark-ok); box-shadow: 0 0 0 var(--space-1) color-mix(in srgb, var(--mark-ok) 22%, transparent); }
.th-bot.is-off .th-dot { background: var(--mark-fix); box-shadow: 0 0 0 var(--space-1) color-mix(in srgb, var(--mark-fix) 22%, transparent); }
.th-busy svg { animation: th-turn calc(var(--dur-slow) * 2) linear infinite; }
@keyframes th-turn { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .th-busy svg { animation: none; } }

/* The tools of the view: quiet buttons, not a wall of pills */
.th-icon-only { width: var(--control-h-sm); padding: 0; }
.th-menu { min-width: calc(var(--space-11) * 3); display: grid; gap: var(--space-1); padding: var(--space-2); }
.th-menu button, .th-menu a { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.th-menu button:hover, .th-menu a:hover { background: var(--surface-2); }
.th-menu button[disabled] { color: var(--muted); cursor: default; background: none; }
.th-menu small { color: var(--muted); font-size: var(--fs-2xs); white-space: nowrap; }
.th-menu hr { width: 100%; margin: var(--space-1) 0; border: 0; border-top: var(--border) solid var(--line); }
.th-menu-hint { margin: 0; padding: var(--space-1) var(--space-3) var(--space-2); color: var(--muted); font-size: var(--fs-2xs); }
.th-help { width: min(calc(100vw - 2 * var(--space-3)), calc(var(--space-11) * 4)); display: grid; gap: var(--space-3); padding: var(--space-4); font-size: var(--fs-xs); }
.th-help h2 { font-size: var(--fs-sm); }
.th-help p { margin: 0; }
.th-help ul { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.th-help a { color: var(--accent); font-weight: var(--fw-bold); }

/* The table and the map under the header */
.th-wrap { border-radius: var(--radius-sm); isolation: isolate; }
.th-mapbox { position: relative; display: flex; min-height: 0; }
.w-fill .th-mapbox { flex: 1 1 auto; }
.th-mapbox > .th-map { flex: 1 1 auto; height: auto; min-height: 0; isolation: isolate; }   /* isolate: Leaflet's layers stay under the panel */
.th-key { position: absolute; left: var(--space-3); bottom: var(--space-3); z-index: var(--z-bar); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-4); max-width: calc(100% - 2 * var(--space-3) - 2 * var(--space-11)); margin: 0; padding: var(--space-2) var(--space-3); border: var(--border) solid var(--line); border-radius: var(--radius-sm); background: var(--glass-bg); backdrop-filter: blur(var(--space-2)); box-shadow: var(--shadow-card); color: var(--text); font-size: var(--fs-2xs); list-style: none; }
.th-key li { display: inline-flex; align-items: center; gap: var(--space-1); }
.th-key .th-pin, .th-key-list .th-pin { display: inline-block; width: var(--space-3); height: var(--space-3); vertical-align: middle; box-shadow: none; }
.th-key .th-key-note { color: var(--muted); }
.th-help .th-key-list { display: none; gap: var(--space-2); padding-bottom: var(--space-3); border-bottom: var(--border) solid var(--line); }   /* the map on a phone */

/* Narrower screens keep the header in one row: first «Бот на связи …» without «работает,», then the quiet tools
   keep only their icons (the words stay for screen readers and in the title) */
@media (max-width: 1279px) {
  .th-bot-long { display: none; }
  .th-tool-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .th-bar-side .th-tool { width: var(--control-h-sm); padding: 0; }
  .th-bar-side .th-caret { display: none; }
}
@media (max-width: 1199px) {
  .th-fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A phone: the title and, at its right, the status and the tools; the search on a line of its own; the view icons and
   «Фильтры»; the filters that are on. The panel is a sheet from the bottom over a dimmed page, «Применить» in reach of the
   thumb */
@media (max-width: 760px) {
  .th-bar { column-gap: var(--space-2); }
  .th-search { order: 3; flex: 1 1 100%; max-width: none; }
  .th-bar-side { flex-wrap: nowrap; gap: 0; }
  .th-applied { flex-basis: 100%; }
  .th-bot { white-space: normal; }
  .th-dd-wide[open] > summary::before { background: color-mix(in srgb, var(--tone-deep-bg) 55%, transparent); }
  .th-fpanel { position: fixed; top: auto; right: 0; bottom: 0; left: 0; width: auto; max-height: 88dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .th-fpanel-head { position: static; display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-3) var(--space-2) var(--space-4); border-bottom: var(--border) solid var(--line); }
  .th-fpanel-head h2 { display: block; }
  .th-fgrid { grid-template-columns: minmax(0, 1fr); padding: var(--space-4); }
  .th-fpanel-foot { padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); }
  .th-fpanel-foot .w-btn-primary { flex: 1 1 auto; }
  .th-fpanel-note { display: none; }
  .th-key { display: none; }                         /* a phone: the map needs every pixel; the colours are in «?» */
  .th-help .th-key-list { display: grid; }
}

.th-wrap { overflow: auto; max-height: calc(100vh - 13rem); border: 1px solid var(--line); background: var(--surface); }
/* the widths of the table and its columns: /townhalls/columns.css, from WIDTHS in townhalls.py */
.th { table-layout: fixed; border-collapse: separate; border-spacing: 0; font: 12.5px/1.35 var(--font-sans); color: var(--text); }
.th th, .th td { padding: 1px 3px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; vertical-align: top; overflow: hidden; }
.th thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); color: var(--ink); vertical-align: bottom; font-weight: var(--fw-bold); }
.th .th-tg { position: sticky; left: 0; z-index: 2; padding: 0; text-align: center; }
.th [data-col="name"] { position: sticky; left: 18px; z-index: 2; }
.th thead .th-tg, .th thead [data-col="name"] { z-index: 4; }
.th tr.th-first > td { border-top: 2px solid var(--line-strong); }
/* A cell's text is laid out only near the screen (content-visibility): 6 500 cells took 0.6 s to lay out on every
   opening; a cell out of sight counts as three lines high, and townhalls.js measures it when it comes in sight. */
.th-c { max-height: calc(3 * 1.35em); overflow: hidden; overflow-wrap: anywhere; content-visibility: auto; contain-intrinsic-size: auto 100px auto calc(3 * 1.35em); }
.th-r.open .th-c, .th-m.open .th-c { max-height: none; content-visibility: visible; }
.th-c small { color: var(--muted); }
.th-c a { color: var(--accent); text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }   /* many links in a row: quiet lines */
.th-c a:hover { text-decoration-color: currentColor; }
.th-c form { display: inline; margin: 0; }
.th-open { width: 100%; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; line-height: 1.35; }
.th-r:not(.th-more) .th-open { visibility: hidden; }
.th-r.open .th-open { color: var(--ink); transform: rotate(90deg); }
.th-fold { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.th-fold::after { content: " −"; color: var(--muted); font-weight: var(--fw-regular); }
.th th.folded, .th td.folded { padding: 0; }
.th td.folded > .th-c { display: none; }
.th th.folded .th-fold::after { content: ""; }
.th th.folded .th-h { display: block; max-height: 6.5em; overflow: hidden; writing-mode: vertical-rl; transform: rotate(180deg); color: var(--muted); font-weight: var(--fw-regular); }
.th td.folded { background: var(--surface-2); }
.th-flag, .th-bot-off { color: var(--status-err-fg); }
.th-btn { padding: 0 var(--space-1); border: 1px solid var(--line-strong); border-radius: var(--radius-xs, 3px); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-2xs, 11px); cursor: pointer; }
.th-btn:hover { border-color: var(--ink); }
.th-btn[disabled] { opacity: .35; cursor: default; }
.th-edit { text-decoration: none; }
.th-order { margin: 0; padding: 0; list-style: none; }
/* after a move the page opens at the moved town hall (#o-…): it stands just under the fixed top bar, lit */
.th-order li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-5); padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--header-h, 68px) + var(--space-3)); }
.th-order li > span { flex: 1 1 12em; font-weight: var(--fw-medium); }
.th-order form { display: inline-flex; gap: var(--space-4); margin: 0; }
.th-order .th-btn { min-width: 46px; min-height: 42px; font-size: 20px; line-height: 1; border-radius: var(--radius-sm); }
.th-order li:target { background: var(--accent-soft); border-radius: var(--radius-sm); }
.th-note textarea { width: 100%; }
.th thead th.th-filtered { background: var(--accent-soft); }
.th-num { color: var(--muted); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.th tr.th-target > td { background: var(--accent-soft); }   /* the town hall a link points to (#g-…: the map, «✓ Проверено», a note) */
.th tr.th-target .th-num { padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary); }
.th th[data-col="name"] { position: sticky; overflow: visible; }   /* its drag handle reaches over the edge */
.th-resize { position: absolute; top: 0; right: -4px; bottom: 0; width: 9px; cursor: col-resize; touch-action: none; z-index: 5; }
.th-resize::after { content: ""; position: absolute; top: 20%; bottom: 20%; left: 3px; width: 3px; border-radius: 2px; background: var(--line-strong); }
.th-resize:hover::after, .th-resize:active::after { background: var(--accent); }
.th td[data-col="name"] .th-c { overflow-wrap: anywhere; }
@media (max-width: 600px) { .th-resize { width: 18px; right: -9px; } .th-resize::after { left: 7px; } }
.th td.folded { text-align: center; }
.th td.folded::before { content: attr(data-first); color: var(--muted); font-weight: var(--fw-bold); }   /* something is written here */
/* «Ратуши» on a map (townhalls_map.html) */
.th-map { height: calc(100vh - 15rem); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.th-pin { display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--surface); color: var(--on-primary); font: var(--fw-bold) 11px/1 var(--font-sans); font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.th-map .th-pin { display: grid; }   /* leaflet.css (loaded later) makes every marker display: block, the number then sat top left */
.th-pin-free { background: var(--mark-ok); }   /* docs.css: the cabinet's green */
.th-pin-days { background: var(--primary); }
.th-pin-none { background: var(--muted); }
.th-pin-flag { border-color: var(--mark-fix); }
.th-popup .leaflet-popup-content-wrapper, .th-popup .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.th-popup .leaflet-popup-content { margin: var(--space-2) 30px var(--space-2) var(--space-3); font: 13px/1.35 var(--font-sans); overscroll-behavior: contain; }
.th-map .th-popup a.leaflet-popup-close-button { width: 30px; height: 30px; font: 20px/30px var(--font-sans); color: var(--muted); }
.th-popup .th-pop p { margin: 0 0 var(--space-1); }   /* .th-popup: leaflet.css is loaded after this file */
.th-popup .th-pop a { color: var(--accent); }
.th-pop-links a { display: inline-block; padding: var(--space-1) 0; }   /* easy to hit with a finger */
.th-pop-head { padding-bottom: var(--space-1); background: var(--surface); font-size: 14px; }
.leaflet-popup-scrolled .th-pop-head { position: sticky; top: 0; z-index: 1; }   /* in sight while a long card scrolls; a short card has no scroll box of its own, the map would hold it */
.th-pop-addr { color: var(--muted); }
.th-pop-row { margin-top: var(--space-2); padding-top: var(--space-1); border-top: 1px solid var(--line); }
.th-pop-dates { color: var(--mark-ok); font-weight: var(--fw-medium); }

