/* Страница «Тестовые пациенты» (DESIGN §6e, §6e.2) в языке макетов §6d: светлый фон --shell, белые карточки --card-radius
   без тяжёлых теней, крупные тёмно-синие талоны, метки ПРОПИСНЫМИ --lazur-mid, основные кнопки --lazur-soft с тёмным
   текстом, вторичные — контур 2px --lazur-dark. ≥ 1100px: форма слева (380px, прилипает), карточки справа сеткой. */
body.tp { --logo-h: 30px; min-height: 100vh; background: var(--shell); }
body.tp [hidden] { display: none !important; }
body.tp.tp-noscroll { overflow: hidden; }

/* ---- шапка */
.tp-head { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; max-width: 1600px; margin: 0 auto; padding: 18px 24px 10px; }
.tp-brand { line-height: 0; text-decoration: none; flex: none; }
.tp-title { flex: 1 1 260px; min-width: 0; }
.tp-title h1 { margin: 0; font-size: clamp(22px, 2.4vw, 30px); font-weight: 800; color: var(--vasilek-dark); line-height: 1.15; letter-spacing: -.01em; }
.tp-sub { color: var(--lazur-dark); font-size: 14px; margin-top: 2px; }
.tp-nav { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- кнопки */
.tp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px;
  border: 2px solid transparent; border-radius: 999px; font: inherit; font-weight: 700; font-size: 15px; line-height: 1.2;
  cursor: pointer; text-decoration: none; text-align: center; transition: filter .15s, background-color .15s, transform .08s; }
.tp-btn:active { transform: translateY(1px); }
.tp-btn:focus-visible, .tp-step:focus-visible, .tp-textbtn:focus-visible, .tp-thumb:focus-visible, .tp-x:focus-visible { outline: 3px solid var(--vasilek-mid); outline-offset: 2px; }
.tp-btn.primary { background: var(--lazur-soft); color: var(--vasilek-dark); }
.tp-btn.primary:hover { filter: brightness(1.06); }
.tp-btn.outline { background: transparent; border-color: var(--lazur-dark); color: var(--lazur-dark); }
.tp-btn.outline:hover { background: var(--lazur-light); }
.tp-btn.danger { background: transparent; border-color: var(--bad-text); color: var(--bad-text); }
.tp-btn.danger:hover { background: var(--bad-bg); }
.tp-btn.danger-fill { background: var(--bad-dark); color: #fff; }
.tp-btn.danger-fill:hover { filter: brightness(1.08); }
.tp-btn.sm { min-height: 40px; padding: 7px 16px; font-size: 14px; }
.tp-btn.big { min-height: 58px; font-size: 19px; padding: 12px 24px; }
.tp-btn[disabled], .tp-btn.is-busy { opacity: .5; cursor: default; pointer-events: none; }

/* ---- раскладка */
.tp-main { max-width: 1600px; margin: 0 auto; padding: 8px 24px 48px; display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .tp-main { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
  /* Высота — чтобы и до прокрутки страницы (под шапкой ~91px) низ панели с кнопкой «Создать» был на экране. */
  .tp-side { position: sticky; top: 16px; max-height: calc(100vh - 107px); overflow-y: auto; border-radius: var(--card-radius); scrollbar-width: thin; }
}
.tp-card { background: var(--white); border-radius: var(--card-radius); border: 1px solid var(--line); }

/* ---- форма */
.tp-form { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.tp-field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.tp-label { font-weight: 700; font-size: 12px; line-height: 1.2; letter-spacing: .12em; text-transform: uppercase; color: var(--lazur-mid); padding: 0; }
.tp-note { margin: 0; font-size: 13px; line-height: 1.35; color: var(--lazur-dark); }
.tp-note.warn { color: var(--warn-text); font-weight: 600; }
.tp-link { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 8px; margin: -4px -8px; border: 0; border-radius: 10px; background: transparent;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--lazur-dark); white-space: nowrap; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.tp-link:hover { background: var(--lazur-light); }
.tp-link:focus-visible, .tp-chip:focus-visible { outline: 3px solid var(--vasilek-mid); outline-offset: 2px; }
.tp-link[disabled] { opacity: .4; cursor: default; background: transparent; }

/* Кабинеты (§6e.2): чипы по этажам, сетка 2–3 в ряд в колонке 380px; выбранный — заливка --lazur-soft с тёмным
   текстом и отметкой в углу (✓, в режиме маршрута — номер порядка выбора); перерыв/закрыт — пометка и приглушение. */
.tp-rooms-head { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.tp-rooms-head .tp-label { margin-right: auto; }
.tp-picked { font-size: 13px; font-weight: 700; color: var(--vasilek-dark); font-variant-numeric: tabular-nums; }
.tp-rooms { display: flex; flex-direction: column; gap: 12px; }
.tp-rooms-msg { padding: 14px; border-radius: 14px; background: var(--shell); color: var(--lazur-dark); font-size: 14px; }
.tp-rooms-msg.bad { background: var(--bad-bg); color: var(--bad-text); }
.tp-floor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.tp-floor-t { font-weight: 700; font-size: 14px; color: var(--vasilek-dark); }
/* 140px: в колонке 380px и на телефоне — по 2 в ряд, чтобы «Оториноларинголог» помещался без переноса посреди слова
   (hyphens: auto есть не во всех браузерах); на планшетной ширине формы — больше в ряд. */
.tp-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.tp-chip { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; min-width: 0; min-height: 50px;
  padding: 5px 8px 6px 10px; border: 2px solid var(--line); border-radius: 14px; background: var(--white); color: var(--vasilek-dark);
  font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s; }
.tp-chip:hover { border-color: var(--lazur-soft); }
.tp-chip-top { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; max-width: 100%; padding-right: 22px; }
.tp-chip-n { font-weight: 800; font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tp-chip.is-text .tp-chip-n { font-size: 14px; line-height: 1.3; min-width: 0; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.tp-chip-name { max-width: 100%; font-weight: 600; font-size: 12px; line-height: 1.2; color: var(--lazur-dark);
  overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.tp-chip-st { font-weight: 700; font-size: 11px; line-height: 1.3; padding: 1px 6px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); }
.tp-chip-st.closed { background: var(--bad-bg); color: var(--bad-text); }
.tp-chip-mark { position: absolute; top: 5px; right: 5px; display: none; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 11px; background: var(--white); color: var(--vasilek-dark); font-weight: 800; font-size: 12.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.tp-chip.on { background: var(--lazur-soft); border-color: var(--lazur-soft); }
.tp-chip.on .tp-chip-name { color: var(--vasilek-dark); }
.tp-chip.on .tp-chip-mark { display: inline-flex; }
.tp-chip.is-off:not(.on) { background: var(--shell); border-style: dashed; }
.tp-chip.is-off:not(.on) .tp-chip-n, .tp-chip.is-off:not(.on) .tp-chip-name { color: var(--muted); }

/* Режим: сегменты */
.tp-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--shell); border: 1px solid var(--line); }
.tp-seg-i { position: relative; display: block; min-width: 0; cursor: pointer; }
.tp-seg-i input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.tp-seg-i span { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 46px; padding: 6px 8px; border-radius: 12px;
  font-weight: 700; font-size: 14px; line-height: 1.2; text-align: center; color: var(--lazur-dark); transition: background-color .15s; }
.tp-seg-i:hover span { background: var(--lazur-light); }
.tp-seg-i input:checked + span { background: var(--lazur-soft); color: var(--vasilek-dark); }
.tp-seg-i input:focus-visible + span { outline: 3px solid var(--vasilek-mid); outline-offset: 2px; }

/* Итог и «Создать» прилипают к низу формы: чипов много, кнопка с итогом видна, пока выбираешь кабинеты. */
.tp-submit { position: sticky; bottom: 0; z-index: 2; display: flex; flex-direction: column; gap: 8px; margin: 0 -22px; padding: 12px 22px 12px;
  background: var(--white); border-top: 1px solid var(--line); }
.tp-create-hint { text-align: center; min-height: 1.35em; overflow-wrap: anywhere; }
.tp-result { margin: -6px 0 0; padding: 10px 12px; border-radius: 14px; background: var(--bad-bg); color: var(--bad-text); font-size: 13.5px; line-height: 1.4; }
.tp-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.tp-result .tp-link { color: var(--bad-text); margin: -6px -6px -6px 0; }
.tp-result .tp-link:hover { background: rgba(255, 255, 255, .5); }
.tp-result ul { margin: 0; padding-left: 18px; max-height: 180px; overflow-y: auto; overflow-wrap: anywhere; }
.tp-stepper { display: flex; align-items: center; gap: 10px; }
.tp-step { flex: none; width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--lazur-dark); background: transparent; color: var(--lazur-dark);
  font: inherit; font-size: 26px; font-weight: 700; line-height: 1; cursor: pointer; }
.tp-step:hover { background: var(--lazur-light); }
.tp-step[disabled] { opacity: .35; cursor: default; }
.tp-stepper input { flex: 1 1 auto; min-width: 0; width: 100%; height: 52px; text-align: center; font-size: 26px; font-weight: 800; color: var(--vasilek-dark);
  border: 2px solid var(--line); border-radius: 14px; padding: 0 8px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.tp-stepper input::-webkit-outer-spin-button, .tp-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tp-stepper input:focus { outline: none; border-color: var(--lazur-soft); }

.tp-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tp-tile { position: relative; display: block; cursor: pointer; min-width: 0; }
.tp-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.tp-tile-box { display: flex; flex-direction: column; justify-content: center; gap: 4px; height: 100%; min-height: 78px; padding: 12px 12px;
  border: 2px solid var(--line); border-radius: 16px; background: var(--white); transition: border-color .15s, background-color .15s; }
.tp-tile:hover .tp-tile-box { border-color: var(--lazur-soft); }
.tp-tile-t { font-weight: 700; font-size: 15px; line-height: 1.2; color: var(--vasilek-dark); }
.tp-tile-d { font-size: 12.5px; line-height: 1.25; color: var(--lazur-dark); }
.tp-tile input:checked + .tp-tile-box { background: var(--lazur-light); border-color: var(--lazur-soft); box-shadow: inset 0 0 0 1px var(--lazur-soft); }
.tp-tile input:focus-visible + .tp-tile-box { outline: 3px solid var(--vasilek-mid); outline-offset: 2px; }

.tp-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; position: relative; }
.tp-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tp-switch-ui { flex: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background-color .15s; }
.tp-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--white);
  box-shadow: 0 1px 3px rgba(0, 16, 69, .25); transition: transform .15s; }
.tp-switch input:checked + .tp-switch-ui { background: var(--lazur-soft); }
.tp-switch input:checked + .tp-switch-ui::after { transform: translateX(20px); }
.tp-switch input:focus-visible + .tp-switch-ui { outline: 3px solid var(--vasilek-mid); outline-offset: 2px; }
.tp-switch-t { font-weight: 600; font-size: 15px; color: var(--vasilek-dark); line-height: 1.3; }

.tp-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: -4px 0; }
.tp-or::before, .tp-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#preset { min-height: 56px; border-radius: 18px; }

/* ---- список */
.tp-list { min-width: 0; }
.tp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0 0 14px; }
.tp-toolbar-t { flex: 1 1 220px; min-width: 0; }
.tp-toolbar h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--vasilek-dark); }
.tp-count { color: var(--lazur-dark); font-size: 14px; margin-top: 2px; }
.tp-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--vasilek-dark); cursor: pointer; }
.tp-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--lazur-dark); }
.tp-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); align-items: stretch; }
.tp-empty { padding: 28px 24px; color: var(--lazur-dark); font-size: 16px; line-height: 1.45; }
.tp-empty b { color: var(--vasilek-dark); }

/* ---- карточка пациента */
.tp-pcard { background: var(--white); border-radius: var(--card-radius); border: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tp-pcard.is-ended { background: rgba(255, 255, 255, .6); }
.tp-pcard.is-ended .tp-pc-ticket, .tp-pcard.is-ended .tp-pc-name { color: var(--muted); }
.tp-pcard.is-busy { opacity: .7; }
.tp-pc-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.tp-pc-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tp-pc-ticket { font-weight: 800; font-size: 38px; line-height: 1.05; color: var(--vasilek-dark); letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tp-pc-name { font-weight: 700; font-size: 15px; line-height: 1.25; color: var(--vasilek-dark); overflow-wrap: anywhere; margin-top: 4px; }
.tp-pc-room { font-weight: 600; font-size: 14px; line-height: 1.25; color: var(--lazur-dark); overflow-wrap: anywhere; }
/* Маршрут визита режима route: пройденные с ✓ и приглушены, текущий жирно. */
.tp-pc-route { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-top: -4px; font-size: 14px; line-height: 1.3; color: var(--vasilek-dark); font-variant-numeric: tabular-nums; }
.tp-route-l { font-weight: 600; color: var(--lazur-dark); }
.tp-route-r { font-weight: 600; white-space: nowrap; }
.tp-route-r.done { color: var(--muted); }
.tp-route-r.cur { font-weight: 800; font-size: 15px; }
.tp-route-arr { color: var(--muted); }
.tp-route-extra { color: var(--lazur-dark); white-space: nowrap; }
.tp-route-extra b { color: var(--vasilek-dark); font-weight: 800; }
.tp-thumb { position: relative; flex: none; width: 120px; height: 120px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
  cursor: zoom-in; display: flex; align-items: center; justify-content: center; font: inherit; color: var(--muted); }
.tp-thumb:hover { border-color: var(--lazur-soft); }
.tp-thumb img { display: block; width: 110px; height: 110px; }
.tp-thumb .tp-thumb-t { font-size: 12px; line-height: 1.2; text-align: center; padding: 0 6px; }
.tp-thumb.loading img, .tp-thumb.error img { display: none; }
.tp-thumb.ok .tp-thumb-t { display: none; }
.tp-thumb.error { cursor: pointer; color: var(--bad-text); }
.tp-thumb.loading { background: var(--shell); }
.tp-pc-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.tp-pc-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.tp-pc-hint { font-size: 13px; line-height: 1.35; color: var(--lazur-dark); margin-top: -4px; }
.tp-pc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-pc-actions .tp-btn { flex: 1 1 auto; }
.tp-pc-links { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; margin: auto -6px -6px; }
.tp-textbtn { display: inline-flex; align-items: center; min-height: 36px; padding: 6px; border: 0; background: transparent; border-radius: 10px;
  font: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; color: var(--lazur-dark); text-decoration: none; cursor: pointer; }
.tp-textbtn:hover { background: var(--lazur-light); }
.tp-textbtn.bad { color: var(--bad-text); margin-left: auto; }
.tp-textbtn.bad:hover { background: var(--bad-bg); }
.tp-textbtn[disabled] { opacity: .45; pointer-events: none; }

/* Пилюли состояния: тёмный текст на светлых заливках (AA). */
.tp-pill { display: inline-block; max-width: 100%; padding: 5px 12px; border-radius: 14px; font-weight: 700; font-size: 13.5px; line-height: 1.3;
  background: var(--vasilek-light); color: var(--vasilek-dark); overflow-wrap: anywhere; }
.tp-pill.routed { background: var(--vasilek-light); color: var(--vasilek-dark); }
.tp-pill.present { background: var(--lazur-light); color: var(--ok-text); }
.tp-pill.called { background: var(--lazur-soft); color: var(--vasilek-dark); }
.tp-pill.in-service { background: var(--vasilek); color: var(--vasilek-dark); }
.tp-pill.paused, .tp-pill.hold { background: var(--warn-bg); color: var(--warn-text); }
.tp-pill.done { background: var(--shell); color: var(--lazur-dark); box-shadow: inset 0 0 0 1px var(--line); }
.tp-pill.cancelled { background: var(--bad-bg); color: var(--bad-text); }

/* ---- полноэкранный QR (светлый фон, как экран результата §6d) */
.tp-qr { position: fixed; inset: 0; z-index: 900; background: var(--white); overflow-y: auto; cursor: zoom-out;
  display: flex; align-items: center; justify-content: center; padding: 24px 16px; animation: q-fade-in .2s ease-out; }
.tp-qr-body { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 100%; }
.tp-qr-ticket { font-weight: 800; font-size: clamp(44px, 7vh, 72px); line-height: 1; color: var(--vasilek-dark); font-variant-numeric: tabular-nums; }
.tp-qr-who { font-weight: 600; font-size: 17px; color: var(--lazur-dark); overflow-wrap: anywhere; }
.tp-qr-frame { --qr: min(600px, calc(100vw - 32px), calc(100vh - 300px)); width: var(--qr); height: var(--qr); min-width: 220px; min-height: 220px; max-width: calc(100vw - 32px);
  margin: 8px 0 4px; display: flex; align-items: center; justify-content: center; background: #fff; }
.tp-qr-frame img { width: 100%; height: 100%; display: block; }
.tp-qr-wait { color: var(--muted); font-size: 16px; padding: 12px; }
.tp-qr-cap { font-weight: 700; font-size: clamp(18px, 2.4vh, 24px); color: var(--vasilek-dark); }
.tp-qr-hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tp-qr .tp-pill:empty { display: none; }
.tp-x { position: fixed; top: 14px; right: 14px; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--line); background: var(--white);
  color: var(--lazur-dark); font-size: 28px; line-height: 1; cursor: pointer; z-index: 1; }
.tp-x:hover { background: var(--lazur-light); }

/* ---- модалки: подтверждение и ключ */
.tp-overlay { position: fixed; inset: 0; z-index: 950; background: rgba(0, 16, 69, .32); display: flex; align-items: center; justify-content: center; padding: 16px; animation: q-fade-in .15s ease-out; }
.tp-dialog { width: 100%; max-width: 460px; padding: 26px 24px 22px; display: flex; flex-direction: column; gap: 12px; }
.tp-dialog h2 { margin: 0; font-size: 22px; font-weight: 800; color: var(--vasilek-dark); line-height: 1.2; }
.tp-dialog p { margin: 0; color: var(--lazur-dark); font-size: 15px; line-height: 1.45; }
.tp-dialog input { width: 100%; min-height: 50px; font-size: 17px; border: 2px solid var(--line); border-radius: 14px; }
.tp-dialog input:focus { outline: none; border-color: var(--lazur-soft); }
.tp-dialog-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.tp-dialog-btns .tp-btn { flex: 1 1 160px; }
.tp-dialog-sign { --logo-h: 26px; }
#keyScreen { background: var(--shell); }

/* Тост поверх модалок и полноэкранного QR. */
body.tp .q-toast { z-index: 1000; text-align: center; }

/* ---- узкий экран */
@media (max-width: 600px) {
  .tp-head { padding: 14px 16px 6px; }
  .tp-title { flex-basis: calc(100% - 80px); }
  .tp-nav { width: 100%; }
  .tp-nav .tp-btn { flex: 1 1 auto; }
  .tp-main { padding: 6px 16px 40px; gap: 20px; }
  .tp-form { padding: 18px 16px; gap: 16px; }
  .tp-submit { margin: 0 -16px; padding: 10px 16px; }
  .tp-seg-i span { font-size: 13.5px; padding: 6px; }
  .tp-tiles { gap: 8px; }
  .tp-tile-box { padding: 10px; min-height: 72px; }
  .tp-tile-t { font-size: 14px; }
  .tp-toolbar .tp-btn { width: 100%; }
  .tp-pcard { padding: 16px; }
  .tp-pc-ticket { font-size: 34px; }
  .tp-qr-frame { --qr: min(600px, calc(100vw - 32px), calc(100vh - 290px)); }
}
