/*
 * Зона niche-medical (SEO-волна 25.11.2026 (г)): /pay-clinic-turkey/, /pay-hospital-germany/, /pay-hospital-thailand/,
 * /pay-dentist-hungary/. Разметка — tools/r26/pages/_med-kit.mjs.
 * Только токены r26 (assets/r26.css): тёмная тема — без атрибута, светлая — html[data-theme="light"].
 * Приставка md-. Телефон: 1199 / 899 / 719 / 379 / 359 px, без боковой прокрутки на 320. RTL — логические свойства.
 */

.md .r-wrap :is(h1, h2) { text-wrap: balance; }
.md-top { padding-top: 12px; }
.md-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.md bdi { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }
.md .r-btn svg { flex: none; }

/* ══ Первый экран: макет счёта ════════════════════════════════════════════ */
.md-hero { grid-template-columns: 1.15fr 0.85fr; }
.md-answer { max-width: 680px; }
.md-chips { padding-top: 4px; }
.md-hero-art { min-width: 0; }
.md-bill {
  width: 100%; max-width: 350px; box-sizing: border-box; padding: 20px; border-radius: 28px;
  background: var(--r-surface-3); border: 1px solid var(--r-line-2); box-shadow: var(--r-pop-shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.md-bill-top { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.md-bill-ico {
  flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--r-brand-tint); color: var(--r-link);
}
.md-bill-tt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.md-bill-tt b { font-size: 15px; font-weight: 800; }
.md-bill-tt > span { font-size: 12px; color: var(--r-muted); }
.md-bill-f {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: 14px;
  background: var(--r-fill-2); border: 1px solid var(--r-line-3); min-width: 0;
}
.md-bill-f span { font-size: 11.5px; font-weight: 700; color: var(--r-muted); }
.md-bill-f b { font-size: 14.5px; font-weight: 800; color: var(--r-text); overflow: hidden; text-overflow: ellipsis; }
.md-bill-f bdi { text-align: start; }
.md-bill-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--r-muted); }
.md-bill-row b { color: var(--r-text); font-weight: 800; }
.md-bill-total { padding-top: 12px; border-top: 1px dashed var(--r-line-3); color: var(--r-text); font-weight: 700; }
.md-bill-total b { font-size: 18px; color: var(--r-green); }

/* ══ Факты ════════════════════════════════════════════════════════════════ */
.md-stats { margin: 0 0 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.md-stat {
  display: flex; flex-direction: column-reverse; gap: 6px; padding: 16px 18px; border-radius: 18px;
  background: var(--r-surface); border: 1px solid var(--r-line); min-width: 0;
}
.md-stat dt { font-size: 12.5px; font-weight: 700; color: var(--r-muted); line-height: 1.35; overflow-wrap: break-word; hyphens: auto; }
.md-stat dd { margin: 0; font-size: 24px; font-weight: 800; color: var(--r-accent); line-height: 1.1; }
.md-stat bdi { white-space: normal; }

.md-tbl-wrap {
  overflow-x: auto; border-radius: 24px; border: 1px solid var(--r-line); background: var(--r-surface);
  box-shadow: var(--r-block-shadow); -webkit-overflow-scrolling: touch;
}
.md-tbl-wrap:focus-visible { outline: 2px solid var(--r-accent); outline-offset: 2px; }
.md-tbl { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.55; }
.md-tbl :is(th, td) { padding: 15px 22px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--r-line); }
.md-tbl tbody tr:last-child :is(th, td) { border-bottom: 0; }
.md-tbl thead th { font-size: 14px; font-weight: 800; color: var(--r-muted); background: var(--r-fill-1); }
.md-tbl tbody th { font-size: 14px; font-weight: 800; color: var(--r-muted); }
.md-tbl td { color: var(--r-text-2); }
.md-tbl--kv tbody th { width: 30%; }
.md-tbl--kv td { color: var(--r-text); }
.md-tbl--cmp { min-width: 640px; }
.md-tbl--cmp tbody th { width: 22%; }
.md-tbl--cmp thead .md-th-on { color: var(--r-green); background: var(--r-green-tint); }
.md-tbl--cmp .md-td-on { color: var(--r-text); font-weight: 700; background: var(--r-green-tint); }
.md-tbl--num { min-width: 560px; }
.md-tbl--num td { white-space: nowrap; }
.md-tbl--num tbody th { color: var(--r-text); }
.md-tbl--num td:last-child { color: var(--r-green); font-weight: 800; }
.md-foot { margin: 10px 0 0; font-size: 13.5px; color: var(--r-faint); line-height: 1.6; max-width: 900px; }
.md-src-k { font-weight: 800; color: var(--r-muted); }

/* ══ Как выставляют счёт: лента этапов ════════════════════════════════════ */
.md-flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.md-flow-i {
  display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: 22px;
  background: var(--r-surface); border: 1px solid var(--r-line); min-width: 0;
}
.md-flow-n {
  width: 36px; height: 36px; border-radius: 99px; display: grid; place-items: center; flex: none;
  background: var(--r-brand-tint); color: var(--r-link); font-weight: 800; font-size: 15px;
}
.md-flow-b { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.md-flow-tag { font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--r-accent); }
.md-flow-t { font-size: 18px; font-weight: 800; color: var(--r-text); line-height: 1.3; }
.md-flow-d { font-size: 14.5px; color: var(--r-muted); line-height: 1.6; }
.md-flow:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ══ Шаги ═════════════════════════════════════════════════════════════════ */
.md-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-radius: 24px; overflow: hidden; border: 1px solid var(--r-line); background: var(--r-surface); }
.md-step { padding: 24px; display: flex; flex-direction: column; gap: 10px; min-width: 0; border-inline-start: 1px solid var(--r-line); }
.md-step:first-child { border-inline-start: 0; }
.md-step-n { font-size: 34px; font-weight: 800; line-height: 1; color: var(--r-accent); }
.md-step-t { font-size: 17px; font-weight: 800; color: var(--r-text); }
.md-step-d { font-size: 14px; color: var(--r-muted); line-height: 1.55; }

/* ══ Калькулятор ══════════════════════════════════════════════════════════ */
.md-calc { display: grid; grid-template-columns: 1fr 1fr; padding: 0; overflow: hidden; }
.md-form { padding: 32px; display: flex; flex-direction: column; gap: 20px; justify-content: center; min-width: 0; }
.md-f { display: flex; flex-direction: column; gap: 8px; margin: 0; min-width: 0; }
.md-f-l { font-size: 13px; font-weight: 800; color: var(--r-text-2); line-height: 1.35; }
.md-in {
  width: 100%; box-sizing: border-box; height: 54px; padding: 0 16px; border-radius: 14px;
  background: var(--r-fill-2); border: 1px solid var(--r-line-3); color: var(--r-text);
  font: inherit; font-size: 19px; font-weight: 800; text-align: start; direction: ltr;
}
[dir="rtl"] .md-in { text-align: end; }
.md-in--big { height: 58px; font-size: 22px; }
.md-in:focus { outline: 2px solid var(--r-accent); outline-offset: 1px; border-color: transparent; }
.md-in[aria-invalid="true"] { border-color: var(--r-red); }
.md-out {
  padding: 32px; display: flex; flex-direction: column; gap: 12px; justify-content: center; min-width: 0;
  background: var(--r-fill-1); border-inline-start: 1px solid var(--r-line-2);
}
.md-out-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; color: var(--r-muted); }
.md-out-row > span { min-width: 0; }
.md-out-row b { color: var(--r-text); font-size: 17px; font-weight: 800; text-align: end; }
.md-out-sub { padding-bottom: 10px; border-bottom: 1px dashed var(--r-line-3); }
.md-out-sub b { color: var(--r-green); }
.md-out-total { padding-top: 4px; color: var(--r-text); font-weight: 700; }
.md-out-total b { font-size: clamp(19px, 1.6vw + 8px, 24px); color: var(--r-accent); }
.md-msg { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--r-muted); min-height: 2.9em; }
.md-msg.is-ok { color: var(--r-green); }
.md-msg.is-warn { color: var(--r-red); }
.md-out-btn { align-self: flex-start; margin-top: 4px; }

/* ══ Карточки ═════════════════════════════════════════════════════════════ */
.md-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.md-cards--2 .md-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.md-card { padding: 24px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.md-ico {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--r-brand-tint); color: var(--r-link);
}
.md-card-t { margin: 0; font-size: 19px; font-weight: 800; color: var(--r-text); line-height: 1.3; }
.md-card-d { margin: 0; font-size: 15px; color: var(--r-text-2); line-height: 1.6; }

/* ══ Ограничения ══════════════════════════════════════════════════════════ */
.md-risk { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.md-risk-i { display: flex; gap: 12px; align-items: flex-start; padding: 20px; border-radius: 20px; background: var(--r-surface); border: 1px solid var(--r-red-line); min-width: 0; }
.md-risk-ic { flex: none; color: var(--r-red); margin-top: 2px; }
.md-risk-i p { margin: 0; font-size: 14.5px; color: var(--r-muted); line-height: 1.55; }
.md-risk-i b { color: var(--r-text); }
.md-note { margin-top: 14px; }

/* ══ Вопросы ══════════════════════════════════════════════════════════════ */
.md-qa { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.md-qa-i { border-radius: 20px; background: var(--r-surface); border: 1px solid var(--r-line); }
.md-qa-i summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 22px; font-size: 16px; font-weight: 800; color: var(--r-text); line-height: 1.4;
}
.md-qa-i summary::-webkit-details-marker { display: none; }
.md-qa-i summary:focus-visible { outline: 2px solid var(--r-accent); outline-offset: -2px; border-radius: 20px; }
.md-qa-ic { flex: none; width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center; background: var(--r-fill-3); color: var(--r-text-2); transition: transform .2s ease; }
.md-qa-i[open] .md-qa-ic { transform: rotate(45deg); }
.md-qa-i p { margin: 0; padding: 0 22px 20px; font-size: 15px; color: var(--r-text-2); line-height: 1.65; max-width: 75ch; }

/* ══ Источники и ссылки ═══════════════════════════════════════════════════ */
.md-src { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.md-src li { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 18px; background: var(--r-surface); border: 1px solid var(--r-line); min-width: 0; }
.md-src a { display: inline-flex; align-items: center; gap: 6px; color: var(--r-link); font-weight: 800; font-size: 15px; text-decoration: none; overflow-wrap: anywhere; }
.md-src a:hover { color: var(--r-link-hover); text-decoration: underline; }
.md-src a svg { flex: none; }
.md-src span { font-size: 13.5px; color: var(--r-muted); line-height: 1.5; }
.md-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.md-link { position: relative; padding: 22px; padding-inline-end: 52px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--r-text); min-width: 0; transition: border-color .16s ease; }
.md-link:hover { border-color: var(--r-brand-2); }
.md-link b { font-size: 16px; font-weight: 800; line-height: 1.35; }
.md-link span { font-size: 14px; color: var(--r-muted); line-height: 1.5; }
.md-link .md-arr { position: absolute; inset-inline-end: 22px; top: 24px; color: var(--r-link); }
[dir="rtl"] .md-arr { transform: scaleX(-1); }

/* ══ Финальный призыв ═════════════════════════════════════════════════════ */
.md-final { padding: 40px 48px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.md-final-txt { position: relative; display: flex; flex-direction: column; gap: 12px; max-width: 640px; min-width: 0; }
.md-final .r-btns { position: relative; flex: none; }

/* ══ Планшет и телефон ════════════════════════════════════════════════════ */
@media (max-width: 1199px) {
  .md-flow, .md-flow:has(> :nth-child(3):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-step:nth-child(odd) { border-inline-start: 0; }
  .md-step:nth-child(n+3) { border-top: 1px solid var(--r-line); }
  .md-risk, .md-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .md-hero { grid-template-columns: 1fr; }
  .md-hero-art { justify-content: flex-start; }
  .md-calc { grid-template-columns: 1fr; }
  .md-out { border-inline-start: 0; border-top: 1px solid var(--r-line-2); }
  .md-links, .md-src { grid-template-columns: 1fr; }
  .md-final { flex-direction: column; align-items: flex-start; padding: 32px 28px; }
  .md-cards--2 .md-cards { grid-template-columns: 1fr; }
}
@media (max-width: 719px) {
  .md-bill { max-width: none; }
  .md-bill.r-float { animation: none; }
  .md-stat { padding: 12px 14px; }
  .md-stat dd { font-size: 20px; }
  .md-card { padding: 22px 20px; }
  .md-flow, .md-flow:has(> :nth-child(3):last-child) { grid-template-columns: 1fr; }
  .md-flow-i { flex-direction: row; padding: 18px; }
  .md-steps { grid-template-columns: 1fr; }
  .md-step { border-inline-start: 0 !important; border-top: 1px solid var(--r-line); padding: 20px; }
  .md-step:first-child { border-top: 0; }
  .md-risk, .md-cards { grid-template-columns: 1fr; }
  .md-form, .md-out { padding: 22px 20px; }
  .md-out-btn, .md-final .r-btns, .md-final .r-btn { align-self: stretch; width: 100%; }
  .md .r-hero-txt .r-btns .r-btn { flex: 1 1 100%; }
  .md-tbl :is(th, td) { padding: 13px 15px; font-size: 14px; }
  .md-tbl--kv tbody th { width: 38%; }
  /* Пример расчёта на телефоне — без боковой прокрутки: итоговая колонка видна сразу. */
  .md-tbl--num { min-width: 0; }
  .md-tbl--num :is(th, td) { padding: 12px 7px; font-size: 12.5px; }
  .md-tbl--num :is(th, td):first-child { padding-inline-start: 12px; }
  .md-tbl--num thead th { white-space: normal; font-size: 11.5px; }
  .md-tbl--num td { white-space: normal; }
  /* «База» на телефоне скрыта: база = «Спишется» − «Комиссия», а итоговая колонка должна влезать без прокрутки. */
  .md-tbl--num :is(th, td):nth-child(3) { display: none; }
  .md-final { padding: 28px 20px; }
  .md-qa-i summary { padding: 16px 18px; font-size: 15px; }
  .md-qa-i p { padding: 0 18px 18px; }
}
@media (max-width: 379px) {
  main .md .r-btn { white-space: normal; height: auto; min-height: 52px; padding-top: 10px; padding-bottom: 10px; line-height: 1.25; text-align: center; }
}
@media (max-width: 359px) {
  .md-bill { padding: 16px; }
  .md-bill-row { font-size: 13px; }
  .md-stats { grid-template-columns: 1fr; }
  .md-stat { flex-direction: row-reverse; justify-content: space-between; align-items: center; gap: 10px; }
  .md-form, .md-out { padding: 18px 16px; }
  .md-in, .md-in--big { font-size: 17px; }
  .md-tbl--kv :is(th, td) { display: block; width: auto; }
  .md-tbl--kv tbody th { padding-bottom: 2px; border-bottom: 0; }
  .md .r-chip { white-space: normal; height: auto; min-height: 34px; padding: 6px 12px; }
}
