:root {
  --bg: #eef5fd;
  --surface: #ffffff;
  --surface-2: #e8f1fc;
  --ink: #0b1f3a;
  --ink-2: #4a5d78;
  --ink-3: #8798b0;
  --line: #d6e4f5;
  --accent: #1e6fe0;
  --accent-deep: #1557b8;
  --accent-soft: #dcebff;
  --exit: #00a651;
  --exit-deep: #007a3c;
  --warn: #e8590c;
  --warn-soft: #fff0e6;
  --danger: #d63031;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 8px 24px rgba(30, 111, 224, .08);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1424;
    --surface: #111e33;
    --surface-2: #172840;
    --ink: #e8f0fb;
    --ink-2: #a3b4cc;
    --ink-3: #6c7f9a;
    --line: #213450;
    --accent: #4d94ff;
    --accent-deep: #2f78e8;
    --accent-soft: #15305a;
    --exit: #1fc46c;
    --exit-deep: #0f9a50;
    --warn: #ff8a3d;
    --warn-soft: #3a2414;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
.tnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

/* ── Шапка ─────────────────────────────────────────── */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
}
.logo {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: var(--accent); display: grid; place-items: center;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}
.logo svg { width: 30px; height: 30px; }
.top h1 { font-size: 19px; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.top .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.top .grow { flex: 1; min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-deep); white-space: nowrap;
}
@media (prefers-color-scheme: dark) { .pill { color: var(--accent); } }
.pill.off { background: var(--surface-2); color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill:not(.off) .dot { animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ── Карточки ──────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.label { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

/* ── Выбор подразделения ───────────────────────────── */
.step-title { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin: 8px 0 4px; line-height: 1.15; }
.step-hint { color: var(--ink-2); margin: 0 0 16px; }

.search {
  position: sticky; top: 0; z-index: 5;
  padding: 8px 0 10px; background: var(--bg);
}
.search input {
  width: 100%; height: 52px; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--surface); padding: 0 16px 0 46px; font-size: 17px; outline: none;
  transition: border-color .15s;
}
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 15px; top: 50%; translate: 0 -50%; margin-top: -1px; width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }

.code {
  flex: none; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 750; font-size: 16px;
  background: var(--surface-2); color: var(--ink-2);
}
.chev { flex: none; width: 22px; height: 22px; color: var(--ink-3); transition: transform .2s; }
.radio { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink-3); display: grid; place-items: center; }
.row mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; }
.empty-search { text-align: center; color: var(--ink-2); padding: 30px 10px; }

/* ── Нижняя панель с кнопкой ───────────────────────── */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  transform: translateY(110%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.dock.show { transform: none; }
.dock-inner { max-width: 560px; margin: 0 auto; }
.chosen {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 10px;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); font-size: 14px;
}
.chosen .txt { flex: 1; min-width: 0; }
.chosen .c { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chosen .u { font-weight: 650; line-height: 1.2; }
.link { color: var(--accent-deep); font-weight: 600; font-size: 14px; padding: 6px 2px; }
@media (prefers-color-scheme: dark) { .link { color: var(--accent); } }

.big-btn {
  position: relative; width: 100%; height: 84px; border-radius: 24px;
  background: linear-gradient(180deg, var(--exit) 0%, var(--exit-deep) 100%);
  color: #fff; font-size: 22px; font-weight: 800; letter-spacing: .01em;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--exit) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
}
.big-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--exit) 60%, transparent);
  animation: ring 2.2s infinite;
}
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--exit) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 14px transparent; } }
.big-btn:active { transform: scale(.97); }
.big-btn svg { width: 34px; height: 34px; flex: none; }
.big-btn[disabled] { opacity: .7; }
.big-btn.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Экран «вы отмечены» ──────────────────────────── */
.done { text-align: center; padding-top: 12px; }
.check {
  width: 132px; height: 132px; margin: 12px auto 18px; border-radius: 50%;
  background: var(--exit); display: grid; place-items: center; color: #fff;
  box-shadow: 0 16px 40px color-mix(in srgb, var(--exit) 45%, transparent);
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.check svg { width: 70px; height: 70px; }
.check path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .45s .25s forwards ease-out; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h2 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.02em; }
.done .lead { color: var(--ink-2); margin: 0 0 20px; }
.where { text-align: left; margin-bottom: 14px; }
.where .c { color: var(--ink-2); font-size: 14px; }
.where .u { font-weight: 700; font-size: 18px; margin-top: 2px; line-height: 1.25; }
.where .t { color: var(--ink-3); font-size: 13px; margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stat { background: var(--surface); border-radius: 16px; padding: 14px 6px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat span { display: block; font-size: 12px; color: var(--ink-2); margin-top: 6px; line-height: 1.2; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.btn {
  height: 52px; border-radius: 16px; font-weight: 650; font-size: 16px;
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.danger { color: var(--danger); }
.btn svg { width: 20px; height: 20px; }

.notice { text-align: center; padding: 40px 10px; }
.notice .ico { width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.notice .ico svg { width: 42px; height: 42px; }
.notice h2 { margin: 0 0 8px; font-size: 24px; }
.notice p { color: var(--ink-2); margin: 0; }

.guest-banner {
  display: flex; gap: 10px; align-items: center; padding: 12px 14px; margin-bottom: 12px;
  background: var(--warn-soft); color: var(--warn); border-radius: 14px; font-weight: 600; font-size: 14px;
}
.guest-banner .grow { flex: 1; }

/* ── Тост ──────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px;
  font-weight: 600; font-size: 15px; max-width: calc(100% - 32px); text-align: center;
  transition: all .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 24px 0 8px; }

/* ── Шаги 1-2-3 ───────────────────────────────────── */
.steps { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 14px; padding: 0; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface); color: var(--ink-3); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); }
.steps b { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12.5px; }
.steps li.on { color: var(--accent-deep); background: var(--accent-soft); box-shadow: none; }
.steps li.on b { background: var(--accent); color: #fff; }
.steps li.past b { background: var(--accent-soft); color: var(--accent-deep); }
@media (prefers-color-scheme: dark) { .steps li.on { color: var(--ink); } }

.netbar { margin: 0 0 12px; padding: 10px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 14px; }

/* ── Быстрый выбор прошлого отдела ─────────────────── */
.quick-card { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.quick-card .qc { color: var(--ink-2); font-size: 14px; margin-top: 8px; }
.quick-card .qu { font-weight: 700; font-size: 18px; line-height: 1.25; margin: 2px 0 14px; }
.quick-card .btn { width: 100%; }

/* ── Списки ───────────────────────────────────────── */
.step-title.small { font-size: 22px; margin-top: 4px; margin-bottom: 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px; min-height: 64px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  font-size: 16px; font-weight: 600; line-height: 1.25; transition: transform .1s, background .15s;
}
.row:active { transform: scale(.985); }
.row .rt { flex: 1; min-width: 0; }
.row small { display: block; font-weight: 500; font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.unit small { margin: 0 0 3px; }
.row .arr { flex: none; width: 22px; height: 22px; color: var(--ink-3); }
.row.center.has-sel .code { background: var(--accent); color: #fff; }
.row.unit { font-weight: 550; }
.row.unit.sel { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.row.unit.sel .radio { border-color: var(--accent); background: var(--accent); }
.row.unit.sel .radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.code.on { background: var(--accent); color: #fff; }
.dock-space { height: 200px; }

.back { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px 8px 6px; margin: 0 0 10px -4px; border-radius: 12px; color: var(--accent-deep); font-weight: 650; font-size: 16px; }
.back svg { width: 22px; height: 22px; }
.back:active { background: var(--accent-soft); }
@media (prefers-color-scheme: dark) { .back { color: var(--accent); } }
.center-title { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 750; line-height: 1.2; margin-bottom: 14px; letter-spacing: -.01em; }

.chosen.hidden + .big-btn { margin-top: 0; }
.big-btn[disabled] { background: var(--surface-2); color: var(--ink-3); box-shadow: none; opacity: 1; }
.big-btn[disabled]::before { animation: none; }
.big-btn[disabled] svg { display: none; }

/* ── Статус отправки ──────────────────────────────── */
.sync { margin: -6px 0 16px; padding: 10px 14px; border-radius: 14px; font-weight: 600; font-size: 14px; }
.sync.ok { background: color-mix(in srgb, var(--exit) 14%, transparent); color: var(--exit-deep); }
.sync.wait { background: var(--warn-soft); color: var(--warn); }
@media (prefers-color-scheme: dark) { .sync.ok { color: var(--exit); } }
.wait-ico { width: 132px; height: 132px; margin: 12px auto 18px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; }
.wait-ico svg { width: 64px; height: 64px; animation: spin 3s linear infinite; }
