/* ПризывникПро — интерфейс */

:root {
  --paper: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #efeeea;
  --ink: #16181c;
  --ink-2: #5b6270;
  --ink-3: #8b919c;
  --line: #e2e0da;
  --line-2: #cfccc4;
  --accent: #1b3a5c;
  --accent-ink: #ffffff;
  --accent-soft: #e9eef4;
  --ok: #2c6e49;
  --ok-soft: #e6f0ea;
  --warn: #9a6206;
  --warn-soft: #f7efe0;
  --danger: #97292b;
  --danger-soft: #f8eaea;
  --r: 8px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tap: rgba(0, 0, 0, .04);
}

html.pre-dark body, body.dark {
  --paper: #101216;
  --surface: #171a20;
  --surface-2: #1e222a;
  --ink: #e7e9ec;
  --ink-2: #99a0ac;
  --ink-3: #6d7480;
  --line: #262a32;
  --line-2: #333944;
  --accent: #8fb4d4;
  --accent-ink: #0e1319;
  --accent-soft: #1a2733;
  --ok: #63b98a;
  --ok-soft: #16261e;
  --warn: #d3a054;
  --warn-soft: #2a2317;
  --danger: #e0706f;
  --danger-soft: #2b1a1b;
  --tap: rgba(255, 255, 255, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}

#app { display: flex; flex-direction: column; height: 100%; }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }
svg { display: block; flex-shrink: 0; }
a { color: inherit; }

/* микро-заголовок над блоком */
.eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ─────────────── Экран входа ─────────────── */
.gate {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 100%; padding: 32px 24px calc(32px + var(--safe-b)); gap: 20px;
  max-width: 440px; margin: 0 auto; width: 100%;
}
.mark {
  width: 44px; height: 44px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: .04em;
}
.gate h1 { font-size: 26px; margin: 0; letter-spacing: -.025em; font-weight: 640; }
.gate .lede { color: var(--ink-2); margin: 0; font-size: 14.5px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.gate-label { font-size: 13px; color: var(--ink-2); }

.code-field {
  width: 100%; padding: 16px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 20px; letter-spacing: .22em; text-align: center;
  text-transform: uppercase; font-weight: 600; outline: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  transition: border-color .15s;
}
.code-field::placeholder { letter-spacing: .18em; color: var(--ink-3); font-weight: 400; }
.code-field:focus { border-color: var(--accent); }

.gate-foot {
  border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px;
  font-size: 13px; color: var(--ink-3); line-height: 1.6;
}

/* ─────────────── Кнопки ─────────────── */
.btn {
  padding: 14px 18px; border-radius: var(--r); font-weight: 600; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .12s;
}
.btn:active { opacity: .82; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 9px 14px; font-size: 13.5px; }
.btn.block { width: 100%; }

.notice {
  padding: 12px 14px; border-radius: var(--r); font-size: 13.5px;
  background: var(--danger-soft); color: var(--danger); border: 1px solid transparent;
}
.notice.info { background: var(--accent-soft); color: var(--accent); }

/* ─────────────── Шапка ─────────────── */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.topbar .mark { width: 30px; height: 30px; font-size: 11px; border-radius: 5px; }
.topbar h2 { margin: 0; font-size: 14.5px; font-weight: 640; letter-spacing: -.01em; }
.topbar .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.topbar .grow { flex: 1; }

.iconbtn {
  width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center;
  color: var(--ink-2); border: 1px solid var(--line);
}
.iconbtn:active { background: var(--tap); }
.sos-btn {
  padding: 8px 13px; border-radius: 6px; background: var(--danger); color: #fff;
  font-weight: 700; font-size: 12px; letter-spacing: .08em;
}

/* ─────────────── Полоса готовности ─────────────── */
.progress {
  padding: 8px 14px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.progress-top {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-bottom: 6px; text-align: left;
}
.progress-top .eyebrow { flex: 1; }
.progress-top .val { font-size: 14px; font-weight: 650; letter-spacing: -.02em; }
.progress-top .caret { color: var(--ink-3); display: flex; transition: transform .18s; }
.progress.open .progress-top .caret { transform: rotate(90deg); }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .45s cubic-bezier(.3,.8,.3,1); }
.bar.ok > i { background: var(--ok); }

/* Плашки этапов скрыты, пока полосу не развернут: на телефоне они съедали пол-экрана. */
.steps {
  display: none; gap: 5px; margin-top: 8px; flex-wrap: wrap;
}
.progress.open .steps { display: flex; }
.step {
  font-size: 11px; padding: 3px 7px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--ink-3); white-space: nowrap;
}
.step.done { border-color: transparent; background: var(--ok-soft); color: var(--ok); font-weight: 600; }

/* ─────────────── Область содержимого ─────────────── */
.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.pane { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.pane.col { display: flex; flex-direction: column; overflow: hidden; }

/* ─────────────── Чат ─────────────── */
.thread {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.m { max-width: 84%; display: flex; flex-direction: column; gap: 4px; }
.m.mine { align-self: flex-end; align-items: flex-end; }
.m-who {
  font-size: 11px; font-weight: 650; color: var(--ink-3);
  letter-spacing: .01em; padding: 0 2px;
  display: flex; align-items: center; gap: 5px;
}
.m-who .role {
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px; background: var(--surface-2); color: var(--ink-3);
}
.m-who .role.doctor { background: var(--ok-soft); color: var(--ok); }
.m-who .role.lawyer { background: var(--accent-soft); color: var(--accent); }
.m-who .role.manager { background: var(--warn-soft); color: var(--warn); }
.m-who .role.admin { background: var(--danger-soft); color: var(--danger); }

.bubble {
  background: var(--surface); border: 1px solid var(--line);
  padding: 11px 13px; border-radius: 10px 10px 10px 3px;
  white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px; line-height: 1.6;
}
.m.mine .bubble {
  background: var(--accent); color: var(--accent-ink);
  border-color: transparent; border-radius: 10px 10px 3px 10px;
}
.m.ai .bubble { background: var(--surface); border-left: 2px solid var(--accent); }
.m-time { font-size: 10.5px; color: var(--ink-3); padding: 0 3px; }

.m.sys { align-self: stretch; max-width: 100%; }
.m.sys .bubble {
  background: transparent; border: 0; border-top: 1px solid var(--line);
  border-radius: 0; padding: 9px 2px 0; text-align: center;
  font-size: 12.5px; color: var(--ink-3); line-height: 1.5;
}

.attach {
  display: flex; align-items: center; gap: 9px; margin-top: 9px;
  padding: 9px 10px; background: var(--surface-2); border-radius: 6px;
  font-size: 13px; text-decoration: none; color: inherit;
}
.m.mine .attach { background: rgba(255,255,255,.16); }
.attach .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .sz { font-size: 11px; color: var(--ink-3); }
.m.mine .attach .sz { color: inherit; opacity: .75; }
.shot { margin-top: 9px; max-width: 240px; border-radius: 6px; display: block; border: 1px solid var(--line); }

.composer {
  display: flex; gap: 8px; align-items: flex-end; padding: 9px 11px;
  padding-bottom: calc(9px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line); flex-shrink: 0;
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; padding: 10px 12px;
  border-radius: 18px; border: 1px solid var(--line-2);
  background: var(--paper); outline: none; font-size: 15px;
}
.composer textarea:focus { border-color: var(--accent); }
.send {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); display: grid; place-items: center; flex-shrink: 0;
}
.send[disabled] { opacity: .4; }
.hintbar {
  font-size: 12px; color: var(--ink-3); padding: 7px 14px;
  background: var(--surface); border-top: 1px solid var(--line); text-align: center;
}

/* ─────────────── Анкета ─────────────── */
.wrap { padding: 14px 14px calc(16px + var(--safe-b)); }
.wrap:has(.sticky-foot) { padding-bottom: 0; }
.head { margin-bottom: 12px; }
.head h3 { margin: 4px 0 5px; font-size: 20px; letter-spacing: -.02em; font-weight: 640; }
.head p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

.sec-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); font-weight: 700; margin: 18px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.q {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; margin-bottom: 7px;
}
.q.filled { border-left: 2px solid var(--ok); }
.q-n { font-size: 10.5px; color: var(--ink-3); font-weight: 700; letter-spacing: .06em; }
.q-t { font-weight: 540; margin: 3px 0 10px; font-size: 14.5px; line-height: 1.4; }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
  font-size: 14.5px; text-align: left; width: 100%;
}
.opt:active { background: var(--tap); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 550; }
.mk {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2);
  flex-shrink: 0; display: grid; place-items: center;
}
.opt.on .mk { border-color: var(--accent); }
.opt.on .mk::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.opt.multi .mk { border-radius: 3px; }
.opt.multi.on .mk::after { border-radius: 1px; }

.field {
  width: 100%; padding: 11px 12px; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--surface); outline: none;
}
.field:focus { border-color: var(--accent); }
textarea.field { resize: vertical; min-height: 74px; }

.sticky-foot {
  position: sticky; bottom: 0; z-index: 5;
  margin: 8px -14px 0; padding: 10px 14px calc(10px + var(--safe-b));
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, .35);
}

/* ─────────────── Карточки, списки ─────────────── */
.stack { padding: 14px; display: flex; flex-direction: column; gap: 10px; padding-bottom: calc(24px + var(--safe-b)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card h4 { margin: 0 0 4px; font-size: 15px; font-weight: 620; }
.card p { margin: 0 0 12px; color: var(--ink-2); font-size: 13.5px; }
.card p:last-child { margin-bottom: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.kv { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13.5px; align-items: baseline; }
.kv:first-of-type { border-top: 0; padding-top: 0; }
.kv .k { color: var(--ink-2); flex: 1; }
.kv .v { font-weight: 560; text-align: right; }

.listrow {
  display: flex; align-items: center; gap: 11px; padding: 11px 0;
  border-top: 1px solid var(--line); text-decoration: none; color: inherit; width: 100%; text-align: left;
}
.listrow:first-of-type { border-top: 0; }
.listrow .ic {
  width: 32px; height: 32px; border-radius: 6px; background: var(--surface-2);
  display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0;
}
.listrow .body { flex: 1; min-width: 0; }
.listrow .t { font-size: 14px; font-weight: 540; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listrow .s { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.listrow .chev { color: var(--ink-3); }

/* ─────────────── Метрики (кабинет сотрудника) ─────────────── */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 13px;
}
.metric .n { font-size: 25px; font-weight: 640; letter-spacing: -.03em; line-height: 1.1; }
.metric .l { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }
.metric.warn { border-color: var(--danger); }
.metric.warn .n { color: var(--danger); }

/* ─────────────── Дела ─────────────── */
.case {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px;
}
.case:active { background: var(--tap); }
.case.alert { border-color: var(--danger); }
.case-head { display: flex; align-items: center; gap: 8px; }
.case-name { font-size: 14.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-note { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); }
.case-foot .bar { flex: 1; }

.tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; padding: 3px 6px;
  border-radius: 3px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.tag.svo { background: var(--warn-soft); color: var(--warn); }
.tag.pr { background: var(--accent-soft); color: var(--accent); }
.tag.sos { background: var(--danger); color: #fff; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }

.seg { display: flex; gap: 0; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button {
  flex: 1; padding: 8px 6px; font-size: 13px; font-weight: 560;
  color: var(--ink-2); background: var(--surface); border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.searchbar { padding: 12px 14px 0; }
.searchbar input {
  width: 100%; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--line-2); background: var(--surface); outline: none; font-size: 14.5px;
}

/* ─────────────── Нижняя навигация ─────────────── */
.nav {
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); flex-shrink: 0;
}
.nav button {
  flex: 1; padding: 8px 2px 7px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; color: var(--ink-3); font-size: 10px; font-weight: 600;
  position: relative;
}
.nav button.on { color: var(--accent); }
.nav .dot {
  position: absolute; top: 5px; right: 50%; margin-right: -16px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center;
}

/* ─────────────── Шторка ─────────────── */
.veil {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .5); z-index: 100;
  display: flex; align-items: flex-end; animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  background: var(--paper); width: 100%; border-radius: 14px 14px 0 0;
  max-height: 90vh; overflow-y: auto; animation: rise .2s cubic-bezier(.2,.8,.3,1);
  padding-bottom: var(--safe-b);
}
@keyframes rise { from { transform: translateY(20px) } }
.sheet-head {
  position: sticky; top: 0; background: var(--paper); padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line); z-index: 2;
}
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 640; letter-spacing: -.02em; }
.sheet-head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.sheet-body { padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 7px;
  font-size: 13.5px; font-weight: 540; z-index: 120; max-width: 86vw; text-align: center;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 6px) } }

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 17px; font-weight: 700; letter-spacing: .14em;
  padding: 12px; background: var(--surface); border: 1px dashed var(--line-2);
  border-radius: 6px; text-align: center; display: block; width: 100%;
}

.empty { padding: 48px 24px; text-align: center; color: var(--ink-3); font-size: 13.5px; line-height: 1.6; }
.spin {
  width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: sp .65s linear infinite; margin: 32px auto;
}
@keyframes sp { to { transform: rotate(360deg) } }

.divider { height: 1px; background: var(--line); margin: 2px 0; }

@media (min-width: 760px) {
  .thread { padding-left: 22px; padding-right: 22px; }
  .m { max-width: 620px; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .stack, .wrap, .searchbar { max-width: 780px; margin: 0 auto; width: 100%; }
}

/* ─────────────── Просмотр документов ─────────────── */
.viewer { align-items: stretch; }
.vwrap {
  background: var(--paper); width: 100%; display: flex; flex-direction: column;
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
.vhead {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.vname {
  flex: 1; font-size: 14.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vbody {
  flex: 1; overflow: auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding-bottom: var(--safe-b); background: var(--paper);
}
.vbody img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.vbody iframe { width: 100%; flex: 1; border: 0; background: #fff; min-height: 60vh; }

/* Вложение в чате — теперь кнопка, а не ссылка */
button.attach { width: 100%; text-align: left; }
button.listrow { background: none; }

.callbar {
  padding: 9px 12px calc(9px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line); flex-shrink: 0;
}

/* ─────────────── Голосовые сообщения ─────────────── */
.recbar {
  display: flex; align-items: center; gap: 9px; flex-shrink: 0;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
}
.recdot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger);
  animation: pulse 1.1s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pulse { 50% { opacity: .25 } }
.rectime { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; }
/* Голосовое сообщение: кнопка, дорожка волны, обратный отсчёт */
.vm {
  --played: 0%;
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  min-width: 210px; max-width: 100%;
}
.vm-play {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.m.mine .vm-play { background: rgba(255, 255, 255, .22); color: #fff; }
.vm-wave {
  flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; min-width: 90px;
}
.vm-wave i {
  flex: 1; border-radius: 1px; min-height: 3px;
  background: var(--line-2); transition: height .25s;
}
.m.mine .vm-wave i { background: rgba(255, 255, 255, .38); }
/* Проигранная часть подсвечивается акцентом */
.vm-wave { position: relative; }
.vm-wave::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: var(--played);
  background: var(--accent); mix-blend-mode: color; pointer-events: none; opacity: .9;
}
.m.mine .vm-wave::after { background: #fff; }
.vm-time {
  font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: right;
}
.m.mine .vm-time { color: rgba(255, 255, 255, .8); }
.vm-load {
  width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; display: block; animation: sp .7s linear infinite;
}

/* ─────────────── Тариф обслуживания ─────────────── */
.tag.vip { background: #7a5c12; color: #fff; }
body.dark .tag.vip { background: #d3a054; color: #17130a; }
.tag.plan { background: var(--surface-2); color: var(--ink-2); }

.getdoc { margin-top: 8px; align-self: flex-start; }
.m.mine .getdoc { background: rgba(255,255,255,.18); color: #fff; border-color: transparent; }

/* ─────────────── Защита от горизонтального разъезда ─────────────── */
/* Длинные коды, адреса и монопространственные строки распирали вёрстку
   на узком экране — страница ездила вбок. Ограничиваем всё по ширине. */
html, body, #app { max-width: 100%; overflow-x: hidden; }
.main, .pane { max-width: 100%; overflow-x: hidden; }
.stack, .wrap, .card { min-width: 0; max-width: 100%; }

/* Ячейки «ключ — значение»: переносим длинные значения вместо распирания */
.kv { flex-wrap: wrap; }
.kv .k, .kv .v { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.kv .v { max-width: 100%; }

/* Переключатели ролей и тарифов сжимаются, а не вылезают */
.seg { max-width: 100%; }
.seg button { min-width: 0; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-inline: 4px; }

/* Код доступа переносится, если не влезает */
.mono { overflow-wrap: anywhere; word-break: break-all; letter-spacing: .08em; font-size: 16px; }

/* Строки списков и полей ввода не шире контейнера */
.listrow { min-width: 0; max-width: 100%; }
.listrow .body { min-width: 0; }
.field, .code-field, .searchbar input { max-width: 100%; }
.row { max-width: 100%; }
.row > .btn { min-width: 0; }

/* Заголовок дела и метки не выталкивают шапку */
.topbar { min-width: 0; }
.topbar > div { min-width: 0; }
.case-head { flex-wrap: wrap; min-width: 0; }
.metric { min-width: 0; overflow: hidden; }
.metric .n { overflow-wrap: anywhere; }

/* Длинные ссылки и слова в сообщениях */
.bubble { overflow-wrap: anywhere; }
.sheet, .sheet-body { max-width: 100%; overflow-x: hidden; }

/* ─────────────── Экран завершения дела ─────────────── */
.win {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 32px 26px calc(32px + var(--safe-b)); position: relative; overflow: hidden;
}
.win h1 { font-size: 28px; margin: 22px 0 6px; letter-spacing: -.03em; font-weight: 660; }
.win-sub { font-size: 17px; color: var(--accent); font-weight: 600; margin: 0 0 18px; }
.win-text { color: var(--ink-2); font-size: 15px; line-height: 1.6; max-width: 34ch; margin: 0; }
.win-foot {
  margin-top: 34px; font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 700;
}
.win-badge {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok); color: #fff; position: relative; z-index: 2;
  animation: badgeIn .6s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes badgeIn { from { transform: scale(.3); opacity: 0 } }

/* Лучи-искры вокруг значка */
.win-burst { position: absolute; top: 50%; left: 50%; width: 0; height: 0; z-index: 1; }
.win-burst i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0;
  transform: rotate(var(--a)) translateY(-46px);
  animation: spark 1.5s ease-out var(--d) infinite;
}
.win-burst i:nth-child(3n) { background: var(--ok); }
.win-burst i:nth-child(3n+1) { background: var(--warn); }
@keyframes spark {
  0% { opacity: 0; transform: rotate(var(--a)) translateY(-46px) scale(.4) }
  25% { opacity: 1 }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-140px) scale(1) }
}
@media (prefers-reduced-motion: reduce) {
  .win-burst { display: none }
  .win-badge { animation: none }
}

/* ─────────────── Приведи друга ─────────────── */
.refhead {
  border-radius: var(--r); padding: 22px 18px; text-align: center; color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #1f6feb 55%, #6d3ff0 100%);
  box-shadow: 0 8px 24px rgba(31, 111, 235, .22);
}
.refsum { font-size: 38px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; }
.refsub { font-size: 12.5px; opacity: .88; margin-top: 5px; }
.refnote {
  display: inline-block; margin-top: 10px; padding: 4px 11px; border-radius: 20px;
  background: rgba(255, 255, 255, .18); font-size: 11.5px; font-weight: 600;
}
.reflink {
  padding: 11px 12px; border-radius: 10px; border: 1px dashed var(--line);
  background: var(--bg); font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12.5px; color: var(--ink-2); word-break: break-all; line-height: 1.45;
}
.step { display: flex; gap: 11px; align-items: flex-start; padding: 8px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step .stepn {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; margin-top: 1px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.step .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.step .body .t { font-size: 13.5px; font-weight: 600; }
.step .body .s { font-size: 12px; color: var(--ink-3); line-height: 1.45; }

/* пять вкладок помещаются в узкий экран */
.nav button { min-width: 0; }
.nav button > span:last-child,
.nav button { white-space: nowrap; }
@media (max-width: 359px) { .nav button { font-size: 9px; } }

/* ─────────────── Выделение и ссылки ─────────────── */
/* Во встроенном браузере Telegram выделение по умолчанию отключено —
   возвращаем его там, где текст нужно копировать. */
.selectable,
.selectable *,
.bubble,
.bubble *,
.kv .v,
.mono {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.bubble .lnk {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.m.mine .bubble .lnk { color: var(--accent-ink); text-decoration-color: rgba(255, 255, 255, .55); }
.bubble .lnk:active { opacity: .6; }
.joinmeet { align-self: flex-start; margin-top: 2px; display: inline-flex; align-items: center; gap: 6px; }
.m.mine .joinmeet { align-self: flex-end; }
