/* N86 / номер под ключ — по макетам design-references/01…06.
   Всегда тёмная тема: чёрный фон, белый текст, тёмно-серые карточки, белая основная кнопка. */

:root {
  --bg: #000;
  --surface: #161618;
  --surface-2: #1d1d20;
  --line: #2a2a2e;
  --line-strong: #3b3b40;
  --text: #fff;
  --muted: #9c9ca3;
  --dim: #6e6e76;
  --danger: #ff7b72;
  --ok: #8be0b0;
  --primary-bg: #f6f6f3;
  --primary-text: #000;
  --radius: 16px;
  --radius-sm: 12px;
  --gutter: 20px;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; display: block; }

/* --- каркас ------------------------------------------------------------- */

.app {
  min-height: var(--tg-viewport-stable-height, 100vh);
  min-height: var(--tg-viewport-stable-height, 100dvh);
  max-width: 560px;
  margin: 0 auto;
  padding: var(--safe-top) var(--gutter) 0;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0 15px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brand .slash { margin: 0 7px; }
.brand .sub { font-weight: 600; }
.top .spacer { flex: 1; }

/* Переключатель «Оператор / Клиент» — только у сотрудников */
.switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.switch button {
  border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
}
.switch button.on { background: var(--primary-bg); color: #000; }
@media (max-width: 430px) {
  .top.staff .brand .sub, .top.staff .brand .slash { display: none; }
  .top.staff .pill.test { padding: 4px 7px; }
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text); background: var(--surface);
}
.pill.test::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #f5c542; }

.screen { position: relative; flex: 1; padding: 22px 0 8px; display: flex; flex-direction: column; }
.screen > * { position: relative; z-index: 1; }
.screen > .wave-corner { position: absolute; z-index: 0; }

.step {
  font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim);
}
.step .slash { margin: 0 7px; }

h1 {
  font-size: 32px; line-height: 1.13; font-weight: 700; letter-spacing: -0.015em;
  margin: 34px 0 0; max-width: 88%;
  text-wrap: balance;
}
.lead { color: var(--muted); font-size: 17px; line-height: 1.42; margin: 18px 0 0; white-space: pre-line; }
.note { color: var(--muted); font-size: 14.5px; line-height: 1.45; white-space: pre-line; }
.small { font-size: 13px; color: var(--dim); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.gap-l { margin-top: 30px; }
.gap-m { margin-top: 20px; }
.gap-s { margin-top: 10px; }
.grow { flex: 1; min-height: 16px; }

.actions {
  position: sticky; bottom: 0; z-index: 2;
  padding: 16px 0 14px;
  margin-top: 16px;
  background: linear-gradient(to top, var(--bg) 78%, rgba(0, 0, 0, 0));
  display: flex; flex-direction: column; gap: 10px;
}

/* --- навигация ------------------------------------------------------------ */

.nav {
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 16px 16px calc(16px + var(--safe-bottom));
}
.nav a {
  text-decoration: none; color: var(--muted); font-size: 15px;
  padding: 2px 6px; min-width: 64px; text-align: center; position: relative;
}
.nav a.active { color: var(--text); font-weight: 600; }
.nav a .dot {
  position: absolute; top: -2px; right: -2px; width: 7px; height: 7px; border-radius: 50%; background: var(--text);
}

/* --- кнопки ------------------------------------------------------------- */

.btn {
  width: 100%; min-height: 58px; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 14px; border: 1px solid var(--line);
  font-size: 17px; font-weight: 600; letter-spacing: -0.005em;
  cursor: pointer; user-select: none;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--primary-bg); color: var(--primary-text); border-color: var(--primary-bg); }
.btn.secondary { background: var(--surface); color: var(--text); }
.btn[disabled] { opacity: 0.38; cursor: default; transform: none; }
.btn .spin { border-color: currentColor; border-right-color: transparent; }

.link {
  background: none; border: 0; padding: 6px 0; cursor: pointer;
  color: var(--muted); font-size: 16px; text-align: left; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.link:active { opacity: 0.6; }
.link.strong { color: var(--text); }
.links { color: var(--muted); font-size: 14.5px; }
.links button { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; }
.links .sep { margin: 0 6px; }

/* --- карточки ------------------------------------------------------------ */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: block; width: 100%; text-align: left;
}
button.card { cursor: pointer; }
button.card:active { background: var(--surface-2); }
.card.selected { border: 2px solid var(--text); padding: 17px 19px; background: var(--surface-2); }
.card .title { font-size: 18px; font-weight: 600; letter-spacing: -0.005em; }
.card .sub { color: var(--muted); font-size: 15px; line-height: 1.45; margin-top: 8px; white-space: pre-line; }
.card .kicker { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.card .big { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; margin: 8px 0 6px; }
.card.row { display: flex; align-items: flex-start; gap: 18px; }
.card .num { color: var(--muted); font-weight: 600; font-size: 16px; min-width: 22px; padding-top: 1px; }
.card .chev { margin-left: auto; color: var(--muted); align-self: center; }
.card.plain { padding: 0; overflow: hidden; }

.option { font-size: 18px; font-weight: 600; min-height: 70px; display: flex; align-items: center; }

/* Строки «ключ — значение» (оплата, итог) */
.kv { border-top: 1px solid var(--line); padding: 16px 0; display: flex; align-items: baseline; gap: 12px; }
.kv:first-child { border-top: 0; }
.kv .k { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); min-width: 90px; }
.kv .v { flex: 1; font-size: 17px; }
.kv .v.strong { font-weight: 700; }
.kv .act { color: var(--muted); font-size: 15px; background: none; border: 0; cursor: pointer; padding: 0; }
.card .kv { padding: 13px 0; }

/* --- поля --------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 9px; }
.field > label:not(.drop), .label {
  font-size: 13px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.input, .select, .textarea {
  width: 100%; min-height: 58px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 18px; outline: none; appearance: none; -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--line-strong); background: var(--surface-2); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input[disabled], .select[disabled] { color: var(--text); opacity: 1; }
.textarea { padding: 16px; min-height: 150px; resize: vertical; line-height: 1.4; font-size: 17px; }
.select {
  padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M0 0h14L7 9z' fill='%23d8d8dc'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 18px center;
}
.select option { background: #111; color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.error { color: var(--danger); font-size: 14px; }
.hint { color: var(--dim); font-size: 13.5px; }

/* Загрузка фото */
.drop {
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  cursor: pointer; position: relative; overflow: hidden; width: 100%;
}
.drop .plus { font-size: 44px; line-height: 1; font-weight: 300; }
.drop .cap { font-size: 18px; font-weight: 600; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop img { width: 100%; max-height: 260px; object-fit: contain; background: #0c0c0d; }
.drop .over {
  position: absolute; left: 12px; bottom: 12px; font-size: 14px; font-weight: 600;
  background: rgba(0, 0, 0, 0.72); border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 12px;
}
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
button.thumb { padding: 0; cursor: pointer; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 14px; line-height: 22px; padding: 0; cursor: pointer;
}
.attach {
  display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 18px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); position: relative; cursor: pointer;
  font-size: 17px;
}
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Галочки */
.checks { display: flex; flex-direction: column; }
.check {
  display: flex; align-items: center; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line);
  cursor: pointer; font-size: 17px; user-select: none;
}
.check:last-child { border-bottom: 0; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 27px; height: 27px; border-radius: 7px; flex: none;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center;
}
.check input:checked + .box { background: var(--primary-bg); border-color: var(--primary-bg); }
.check .box svg { width: 16px; height: 16px; opacity: 0; }
.check input:checked + .box svg { opacity: 1; }
.check input:focus-visible + .box { outline: 2px solid var(--text); outline-offset: 2px; }

/* --- трекер ------------------------------------------------------------- */

.tracker { display: flex; flex-direction: column; margin-top: 34px; }
.tstep { display: flex; gap: 20px; position: relative; padding-bottom: 32px; }
.tstep:last-child { padding-bottom: 0; }
.tstep::before {
  content: ""; position: absolute; left: 18px; top: 38px; bottom: 2px; width: 1px; background: var(--line-strong);
}
.tstep:last-child::before { display: none; }
.tstep .dot {
  width: 37px; height: 37px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted);
}
.tstep.done .dot, .tstep.active .dot { background: var(--primary-bg); border-color: var(--primary-bg); color: #000; }
.tstep.active .dot { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.1); }
.tstep .t { font-size: 20px; font-weight: 600; margin-top: 4px; }
.tstep .h { color: var(--muted); font-size: 15px; margin-top: 4px; }
.tstep.todo .t { color: var(--muted); }

/* --- номер ------------------------------------------------------------- */

.number { font-size: 22px; font-weight: 600; letter-spacing: 0.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }

/* --- поддержка ----------------------------------------------------------- */

.msg { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.msg.staff { background: var(--surface-2); border-color: var(--line-strong); }
.msg .who { font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }

/* --- состояния ----------------------------------------------------------- */

.banner {
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 15px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--line-strong);
}
.banner.warn { border-color: #6b5520; background: #1d180b; }
.banner.err { border-color: #6b2a26; background: #1f0f0e; color: #ffd0cc; }
.banner.test { border-color: #6b5520; background: #1d180b; }

.center { flex: 1; display: grid; place-items: center; min-height: 50vh; }
.spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--muted); border-right-color: transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 64px); transform: translateX(-50%);
  z-index: 50; max-width: calc(100% - 40px);
  background: #f6f6f3; color: #000; font-weight: 600; font-size: 15px;
  border-radius: 12px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.18s ease-out;
}
.toast.err { background: #ffd9d5; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* Нижний лист: тексты согласий, инструкции */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 40; animation: fade 0.15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86vh; overflow: auto;
  max-width: 560px; margin: 0 auto;
  background: #0f0f10; border-top: 1px solid var(--line-strong); border-radius: 20px 20px 0 0;
  padding: 22px var(--gutter) calc(22px + var(--safe-bottom));
  animation: sheet-in 0.2s ease-out;
}
.sheet h2 { font-size: 22px; margin: 0 0 14px; }
.sheet .text { white-space: pre-wrap; color: #d8d8dc; line-height: 1.55; font-size: 15.5px; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* --- волны ------------------------------------------------------------- */

.wave-corner { top: 30px; right: calc(var(--gutter) * -1); width: 60%; max-width: 260px; height: 230px; pointer-events: none; }
.wave-hero { width: calc(100% + var(--gutter) * 2); margin: 8px calc(var(--gutter) * -1) -14px; height: 215px; pointer-events: none; }
.wave-corner svg, .wave-hero svg { width: 100%; height: 100%; display: block; overflow: visible; }
.wave-corner { animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-8px, 6px, 0); } }
@media (prefers-reduced-motion: reduce) {
  .wave-corner { animation: none; }
  .btn, .toast, .sheet, .sheet-back { transition: none; animation: none; }
}

.hero-wrap { position: relative; }
.hero-wrap + h1 { margin-top: 10px; }
.hero-kicker { font-size: 13px; font-weight: 700; letter-spacing: 0.05em; color: #cfcfd4; position: absolute; top: 34px; left: 0; z-index: 2; }

/* --- оператор ----------------------------------------------------------- */

.app.wide { max-width: 880px; }
.frows { border-top: 1px solid var(--line); }
.frow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.frow > div { flex: 1; min-width: 0; }
.flabel { font-size: 12.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.fvalue { font-size: 18px; font-weight: 700; margin-top: 3px; word-break: break-word; font-variant-numeric: tabular-nums; }
.act { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 15px; padding: 8px 4px 8px 12px; }
.act:active { color: var(--text); }
.op-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--primary-bg); color: #000; border-color: var(--primary-bg); font-weight: 600; }
details.notes summary { cursor: pointer; list-style: none; }
details.notes summary::-webkit-details-marker { display: none; }
details.notes summary::after { content: " ▾"; color: var(--muted); }
details.notes[open] summary::after { content: " ▴"; }
@media (min-width: 820px) {
  .op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .op-grid > .card { height: 100%; }
}

@media (max-width: 360px) {
  :root { --gutter: 16px; }
  h1 { font-size: 28px; }
  .row2 { gap: 12px; }
}
