:root {
  color-scheme: light;
  /* айдентика Военком.днр */
  --olive: #62664B;
  --olive-deep: #303728;
  --sand: #E8E3CD;
  --sage: #C2C5AC;
  --bg: #E8E3CD;
  --surface: #F4F1E3;
  --text: #303728;
  --muted: #5E624C;
  --line: #CFCBB0;
  --accent: #62664B;
  --accent-dark: #3F4430;
  --accent-soft: #DADCC3;
  --accent-text: #F7F4E8;
  --warn-bg: #F3E9C3;
  --warn-line: #D9C57A;
  --danger: #A8342B;
  --ok: #3F6B2F;
  --radius: 12px;
  --shadow: none;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 "Noto Sans Display", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; padding-top: 32px; padding-bottom: 48px; }
.quick { display: flex; gap: 8px; margin-top: 8px; }
.btn.small { padding: 6px 12px; font-size: .875rem; }
.q { margin-bottom: 8px; }
h1 { font-size: 2.2rem; line-height: 1.15; margin: 0 0 10px; letter-spacing: -.02em; font-weight: 500; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 32px 0 12px; font-weight: 500; }
h3 { font-weight: 500; }
p { margin: 0 0 14px; }
a { color: var(--accent-dark); }
.muted { color: var(--muted); }
.back { display: inline-block; margin-bottom: 16px; text-decoration: none; font-weight: 500; font-size: .9rem; color: var(--muted); }
.back:hover { color: var(--text); }

/* шапка */
.topbar { background: var(--olive); color: var(--sand); position: sticky; top: 0; z-index: 5; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; text-decoration: none; color: var(--sand); }
.brand-mark { width: 34px; height: 34px; object-fit: contain; display: block; }
#nav { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.user-chip { color: var(--sand); padding: 6px 4px; font-size: .9rem; font-weight: 500; }
.footer { color: var(--sage); font-size: .85rem; padding-top: 22px; padding-bottom: 30px; max-width: none; background: var(--olive-deep); }
.footer > * { max-width: 920px; margin: 0 auto; }

/* карточки */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; margin-bottom: 16px;
}
.hero {
  background: var(--olive); color: var(--sand);
  border-radius: 16px; padding: 32px; margin-bottom: 16px;
}
.hero small { display: block; font-size: .8125rem; color: var(--sage); margin-bottom: 8px; }
.hero h1 { margin: 0 0 12px; font-size: 1.75rem; line-height: 1.2; max-width: 36rem; }
.hero p { margin: 0; color: var(--sand); opacity: .85; font-size: .9375rem; }
.hero p.note { margin-top: 12px; font-size: .8125rem; color: var(--sage); opacity: 1; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.fine { font-size: .8125rem; margin-top: 24px; }
.num { font-variant-numeric: tabular-nums; }
.tile {
  display: block; text-decoration: none; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
a.tile:hover, a.tile:focus-visible { border-color: var(--olive); background: #FAF8EE; }
.tile h3 { margin: 16px 0 4px; font-size: 1rem; }
.tile p { margin: 0; font-size: .875rem; }
.tile.disabled { background: transparent; border-style: dashed; }
.tile.disabled h3, .tile.disabled p { opacity: .65; }
.icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-dark);
}
.tile.disabled .icon { background: var(--line); color: var(--muted); }

.notice {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px;
  padding: 12px 16px; margin: 16px 0; font-size: .875rem;
}

/* формы */
.auth { max-width: 560px; margin: 24px auto 0; }
.auth h1 { font-size: 1.9rem; }
form.stack { display: grid; gap: 18px; }
label.field { display: grid; gap: 6px; font-weight: 500; font-size: .9375rem; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  transition: border-color .15s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: #B3B08F; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--olive); outline-offset: 1px; border-color: var(--olive); }
textarea { min-height: 120px; resize: vertical; }
textarea.letter {
  min-height: 460px; font-family: "Times New Roman", Georgia, serif; font-size: 1.1rem; line-height: 1.55;
  background: #FBF9EE; padding: 24px 28px;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
.row2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--muted); }
.check input { margin-top: 5px; flex: none; width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 10px; padding: 11px 20px;
  border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-text);
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--accent-dark); border-color: var(--line); }
.btn.secondary:hover { background: rgba(48, 55, 40, .06); }
.btn.link { border: none; background: none; color: var(--muted); padding: 6px 10px; font-weight: 500; }
.btn.link:hover { background: rgba(48, 55, 40, .08); color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 22px; }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; margin: 0; }
.ok { color: var(--ok); font-weight: 500; }

/* опрос */
.options { display: grid; gap: 12px; }
.option {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.option:hover { border-color: #A9AC8A; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 5px; flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
button.option { width: 100%; text-align: left; font: inherit; color: inherit; }
button.option:active { background: var(--accent-soft); }
.option .t { font-weight: 500; }

/* частые вопросы: раскрывающиеся блоки */
.faq-list { display: grid; gap: 10px; margin-bottom: 8px; }
.faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.faq summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 18px; font-weight: 500; border-radius: var(--radius);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex: none; width: 9px; height: 9px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease);
}
.faq[open] summary::after { transform: rotate(-135deg); }
.faq summary:hover { background: var(--accent-soft); }
.faq-body { padding: 0 18px 16px; color: var(--muted); }
.faq-body p { margin: 0 0 10px; }
.faq-body .tips { margin: 0 0 10px; }

/* результат теста */
.bars { display: grid; gap: 18px; margin-bottom: 8px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.bar { height: 8px; background: #D2CFB4; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--olive); border-radius: 99px; }
.bar-row p { margin: 8px 0 0; }
.ai-line { margin: 0; }
.option .d { color: var(--muted); font-size: .875rem; }

.progress { height: 4px; background: #D2CFB4; border-radius: 99px; overflow: hidden; margin: 10px 0 24px; }
.progress > span { display: block; height: 100%; background: var(--olive); border-radius: 99px; transition: width .25s; }
.quiz-title { margin: 0 0 16px; font-size: 1.25rem; font-weight: 500; }

ol.steps { padding: 0; margin: 0; list-style: none; counter-reset: s; display: grid; gap: 14px; }
ol.steps li { counter-increment: s; position: relative; padding-left: 44px; min-height: 28px; }
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-dark); font-weight: 500; font-variant-numeric: tabular-nums;
}
ul.tips { margin: 0; padding-left: 22px; display: grid; gap: 10px; }

[hidden] { display: none !important; }

/* адрес с подсказками */
fieldset.addr { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 20px 20px; margin: 0; display: grid; gap: 16px; background: #F1EEDD; }
fieldset.addr legend { font-weight: 500; padding: 0 8px; font-size: 1rem; }
fieldset.addr > p { margin: 0; font-size: .92rem; }
.sg { position: relative; font-weight: 400; }
.sg input:disabled { background: #E3E0C9; cursor: not-allowed; }
.sg.picked input { border-color: var(--ok); padding-right: 40px; }
.sg.picked::after {
  content: "✓"; position: absolute; right: 14px; top: 9px; color: var(--ok); font-weight: 500;
}
.sg-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(48, 55, 40, .12);
  max-height: 300px; overflow-y: auto;
}
.sg-item { display: block; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.sg-item.active, .sg-item:hover { background: var(--accent-soft); }
.sg-main { display: block; font-weight: 500; }
.sg-sub { display: block; color: var(--muted); font-size: .85rem; }
.sg-msg { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.sg-msg:empty { display: none; }
.office-box {
  background: var(--accent-soft); border: 1px solid var(--sage); border-radius: 10px; padding: 12px 16px; display: grid; gap: 4px;
}
.office-box .hint { color: var(--muted); font-size: .85rem; }

/* оценка категории */
.notice.strong { background: #F3DDD6; border-color: #D9A89C; color: #6E221B; font-size: .875rem; }
.notice.strong strong { display: block; font-weight: 500; }
.file-input { padding: 10px; background: var(--surface); border: 1px dashed #A9AC8A; border-radius: 10px; width: 100%; font: inherit; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--accent-soft); border-radius: 10px; }
.file-name { font-weight: 600; flex: 1; overflow-wrap: anywhere; }
.busy { display: flex; align-items: center; gap: 16px; }
.busy p { margin: 0; }

/* помощь ИИ */
.ai-box { background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; display: grid; gap: 10px; }
.ai-box .error { min-height: 0; }
.ai-text { margin: 0; font-weight: 500; }
.ai-list { display: grid; gap: 10px; }
.ai-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.ai-item:first-child { border-top: 0; }
.ai-item p { margin: 4px 0 0; }
.ai-item .btn { flex: none; }
.ai-ask { margin-top: 16px; }
.quick.wrap { flex-wrap: wrap; }
textarea.letter.small { min-height: 280px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.quick { display: flex; gap: 8px; margin-top: 8px; }
.btn.small { padding: 6px 14px; font-size: .9rem; }
.cat-head { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.cat-badge { display: grid; place-items: center; min-width: 64px; height: 64px; padding: 0 12px; border-radius: 12px; background: var(--olive); color: var(--sand); font-size: 1.75rem; font-weight: 500; }
.cat-title { font-size: 1.25rem; font-weight: 500; line-height: 1.3; }
.chip { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 6px; background: #DDDAC0; color: var(--muted); font-size: .8125rem; font-weight: 400; }

#print-area { display: none; }
@media (max-width: 560px) {
  h1 { font-size: 1.6rem; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 1.4rem; }
  .card { padding: 20px; }
}
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; white-space: pre-wrap; font: 14pt/1.5 "Times New Roman", serif; color: #000; }
  body { background: var(--surface); }
}
.topbar .btn.link { color: var(--sage); }
.topbar .btn.link:hover { background: rgba(232,227,205,.12); color: var(--sand); }
.error:empty { display: none; }

/* ---------- мобильный интерфейс ---------- */
html { -webkit-tap-highlight-color: transparent; }
#tabbar { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#app > * { animation: rise .35s var(--ease) backwards; }
@media (prefers-reduced-motion: reduce) { #app > * { animation: none; } }

@media (max-width: 720px) {
  body { font-size: 16px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-sticky { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  main.wrap { padding-top: 16px; padding-bottom: 24px; }

  /* шапка: только бренд и имя, выход уходит в нижнюю панель */
  .topbar { padding-top: env(safe-area-inset-top); }
  .topbar-in { min-height: 52px; }
  #nav .btn.link { display: none; }
  .user-chip { font-size: .8125rem; opacity: .85; }

  /* нижняя панель */
  #tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--olive-deep); padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(232, 227, 205, .12);
  }
  #tabbar[hidden], body.has-sticky #tabbar { display: none; }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 56px; padding: 8px 4px; font: inherit; font-size: .6875rem; font-weight: 500;
    color: var(--sage); background: none; border: 0; text-decoration: none; cursor: pointer;
    transition: color .15s var(--ease);
  }
  .tab[aria-current="page"] { color: var(--sand); }
  .tab:active { color: var(--sand); }
  .footer { display: none; }

  /* заголовки */
  h1 { font-size: 1.5rem; }
  .back { display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 4px; }

  /* главная */
  .hero { padding: 24px 20px; border-radius: 16px; margin-bottom: 12px; }
  .hero h1 { font-size: 1.375rem; }
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .tile {
    display: grid; grid-template-columns: 40px 1fr; column-gap: 16px; align-items: center;
    padding: 16px; min-height: 72px;
  }
  .tile .icon { grid-row: span 2; width: 40px; height: 40px; }
  .tile h3 { margin: 0; font-size: 1rem; }
  .tile p { font-size: .875rem; }
  a.tile:active { background: #FAF8EE; border-color: var(--olive); }
  .fine { margin-top: 16px; }

  /* карточки и формы */
  .card { padding: 20px 16px; border-radius: 12px; }
  .auth { margin-top: 8px; }
  input[type=text], input[type=password], input[type=date], select, textarea { font-size: 16px; min-height: 48px; padding: 12px; }
  textarea { min-height: 120px; }
  textarea.letter { min-height: 60vh; min-height: 60dvh; font-size: 1rem; padding: 16px; }
  .row2 { grid-template-columns: 1fr; }
  fieldset.addr { padding: 8px 16px 16px; }
  .option { padding: 14px 16px; min-height: 56px; align-items: center; }
  .option input, .check input { width: 22px; height: 22px; margin-top: 0; }
  .check { align-items: flex-start; }
  .check input { margin-top: 2px; }
  .sg-list { max-height: 40vh; }
  .sg-item { padding: 12px; }

  /* кнопки: на всю ширину, высота под палец */
  .btn { min-height: 48px; padding: 12px 20px; }
  .btn.small { min-height: 40px; }
  .btn.link { min-height: 44px; }
  .actions { flex-direction: column; align-items: stretch; margin-top: 20px; }
  .actions > a { text-align: center; padding: 12px; }
  .actions .btn { width: 100%; }
  .actions .ok, .actions [role=status] { text-align: center; }

  /* липкая панель шагов */
  .actions.sticky {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; margin: 0; flex-direction: row;
    padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .actions.sticky .btn { width: auto; flex: 1; }
  .actions.sticky .btn:not(.secondary) { flex: 2; }

  /* прогресс шагов */
  .progress { margin: 8px 0 16px; }

  /* категория */
  .cat-head { gap: 12px; }
  .cat-badge { min-width: 56px; height: 56px; font-size: 1.5rem; }
  .file-row { flex-wrap: wrap; }
  .quick .btn { flex: 1; }
  .notice.strong { margin-top: 0; }
}
@media (max-width: 360px) {
  h1 { font-size: 1.375rem; }
  .hero h1 { font-size: 1.25rem; }
  .tab span { font-size: .625rem; }
}
.file-input::file-selector-button {
  font: inherit; font-weight: 500; margin-right: 12px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); color: var(--accent-dark);
}
.hero .tel { display: inline-block; margin-top: 8px; color: var(--sand); font-size: .9375rem; text-decoration: none; font-variant-numeric: tabular-nums; }
.hero .tel:hover { text-decoration: underline; }
@media (max-width: 720px) {
  .hero { padding: 16px; }
  .hero small { margin-bottom: 4px; font-size: .75rem; }
  .hero h1 { font-size: 1.0625rem; line-height: 1.3; margin-bottom: 8px; }
  .hero p { font-size: .875rem; line-height: 1.4; }
  .hero p.note { display: none; }
  .hero .tel { margin-top: 4px; }
}
.hero .contacts { margin: 0; display: grid; gap: 8px; }
.hero .contacts > div { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: baseline; }
.hero .contacts dt { font-size: .8125rem; color: var(--sage); }
.hero .contacts dd { margin: 0; font-size: .9375rem; line-height: 1.4; }
.hero .contacts .tel { margin: 0; font-size: 1rem; font-weight: 500; }
@media (max-width: 720px) {
  .hero .contacts > div { grid-template-columns: 64px 1fr; gap: 8px; }
  .hero .contacts dd { font-size: .875rem; }
  .hero .contacts .tel { font-size: .9375rem; }
}
