/* «Отмена приказа» — стили главной (из макетов v0.2/v0.3, docs/DESIGN.md). Спокойная страница: слева — ситуация человека, справа — расчёт срока; ниже путь после отмены. */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --band: #f5f7f9;

  --warn: #8f5508;
  --error: #b3261e;
  --font-sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --paper: var(--bg);
  --white: var(--bg);
  --muted: var(--ink-2);
  --gold: var(--warn);
  --field-border: #8791a0;
  --soft: var(--accent-soft);
  --danger: var(--error);
  --danger-bg: #fbe9e7;
  --sans: var(--font-sans);
  --serif: 'Times New Roman', Times, serif;
  --mfc-frame-width: 75rem;
  --mfc-frame-gutter: clamp(1rem, 4vw, 3rem);
  --site-shell-width: calc(min(100%, var(--mfc-frame-width)) - 2 * var(--mfc-frame-gutter));
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 1.125rem/1.55 var(--sans); overflow-wrap: break-word; }
h1, h2, h3, h4, p { margin: 0 0 .75em; }
h1, h2 { font: 500 clamp(1.75rem, 3vw, 2.5rem)/1.18 var(--sans); letter-spacing: -.025em; }
h3 { font-size: 1.25rem; line-height: 1.3; }
h4 { font-size: 1.125rem; line-height: 1.35; }
a, .inline-link { color: var(--accent); text-underline-offset: .18em; }
button, input, select, textarea { font: inherit; }
button, summary, label:has(input[type=checkbox]), label:has(input[type=radio]) { cursor: pointer; }
button { min-height: 48px; color: var(--ink); }
button:disabled { color: #657269; opacity: .72; cursor: default; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 5; background: white; padding: .75em; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
main, .rail, .field, .task-body, .task-panel { min-width: 0; }
button, summary { overflow-wrap: anywhere; }
main:focus, h2[tabindex="-1"]:focus { outline: none; }

.site-header { border-bottom: 1px solid var(--line); background: var(--white); }
.header-inner, .service-title, .workspace { max-width: var(--mfc-frame-width); padding-inline: var(--mfc-frame-gutter); margin: auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-block: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; min-height: 48px; color: var(--accent); text-decoration: none; font-size: 21px; font-weight: 600; line-height: 1.2; }
.brand svg { width: 28px; height: 28px; color: var(--accent); flex: none; }
.brand small, .file-action span { display: block; font: 400 1rem/1.35 var(--sans); color: var(--muted); }
.file-tools, .start-actions, .result-actions, .dialog-actions, .footer-links { display: flex; gap: .65rem; flex-wrap: wrap; align-items: stretch; }
.file-action { padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 5px; background: var(--white); font-size: 1rem; font-weight:600; text-align: left; }
.step:enabled:hover, .task-head:enabled:hover { background: var(--soft); }
.service-title { padding-top: 1.5rem; }
.service-title h1 { margin: 0; font-size: clamp(1.65rem, 3.6vw, 2.8rem); }
.workspace { display: grid; grid-template-columns: minmax(14rem, .75fr) minmax(0, 2.1fr); gap: clamp(1.5rem, 5vw, 4.5rem); padding-block: 1.5rem 3rem; }
.rail { align-self: start; grid-column: 1; grid-row: 1; }
.workspace > main { grid-column: 2; grid-row: 1; }
#steps { display: grid; border-top: 1px solid var(--line); }
.step { text-align: left; border: 0; border-bottom: 1px solid var(--line); padding: .7rem .5rem; background: transparent; display: flex; align-items: center; gap: .65rem; font-size: 1rem; }
.step .n { flex: 0 0 1.9rem; height: 1.9rem; display: grid; place-items: center; border: 1px solid var(--field-border); border-radius: 50%; font-variant-numeric: tabular-nums; }
.step.current, .step[aria-current=step] { font-weight: 600; }
.step.current .n, .step[aria-current=step] .n { background: var(--accent); border-color: var(--accent); color: white; }
.free-note { margin-top: 1.5rem; color: var(--muted); font-size: 1rem; }
.free-note strong { color: var(--ink); }
.free-note p { margin: .35rem 0; }
.inline-link, .back, .debt-actions button, .text-button { display: inline-flex; align-items: center; min-height: 48px; padding: .4rem .15rem; font-size: 1rem; background: none; border: 0; text-align: left; text-decoration: underline; }
.mobile-progress, .mobile-free, .mobile-stage-link { display: none; }
.kicker, .eyebrow, .caption, .task-status, .task-summary { color: var(--muted); font-size: 1rem; }
.kicker { margin-bottom: .4rem; }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 65ch; margin-bottom: 1.25rem; }

.panel, .task-panel, .debt-card, .paper-preview, .purchase, .action-card {
  margin-bottom: 1rem; padding: clamp(1rem, 2vw, 1.6rem); border: 1px solid var(--line); border-radius: 4px; background: var(--white);
}
.task-panel { padding: 0; }
.task-head { width: 100%; display: flex; gap: .75rem; align-items: baseline; justify-content: space-between; min-height: 56px; padding: 1rem 1.25rem; background: transparent; border: 0; border-radius: inherit; text-align: left; }
.task-head h3 { margin: 0; }
.task-status { font-weight: 500; }
.task-body { padding: .25rem 1.25rem 1.25rem; }
.task-body > :last-child, .panel > :last-child { margin-bottom: 0; }
.task-summary { margin: .25rem 0 .75rem; }
.panel-heading, .debt-card .top, .review-debt, .amount-summary { display: flex; gap: .75rem; justify-content: space-between; align-items: baseline; }
.badge { color: var(--gold); font-size: 1rem; }
.field { display: block; border: 0; padding: 0; margin: 0 0 1.1rem; }
.field > span:first-child, .field-label, .field legend { display: block; margin-bottom: .4rem; font-weight:600; }
.helper, .note, .date-hint, .preparation-note, .local-note, .small-total, .route-head small, .checkline small, .doc-link small, .debt-info, .prep-item p {
  color: var(--muted); font-size: 1rem; line-height: 1.5;
}
.helper, .date-hint { margin: .4rem 0 .9rem; }
.field input:not([type=radio]):not([type=checkbox]), select, textarea {
  display: block; width: 100%; min-width: 0; min-height: 48px; padding: .6rem .75rem; border: 1px solid var(--field-border); border-radius: 4px; background: var(--white); color: var(--ink); font-size: 1.125rem;
}
textarea { resize: vertical; min-height: 6rem; }
input::placeholder, textarea::placeholder { color: #535f6f; opacity: 1; }
input[readonly] { background: var(--band); }
.field-error, .modal-errors, .error-link { color: var(--danger); font-size: 1rem; }
.field-error { margin: .4rem 0 .6rem; font-weight: 600; }
.input-error, input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--danger) !important; }
.money-field { position: relative; }
.money-field input { padding-right: 2.5rem !important; font-variant-numeric: tabular-nums; }
.money-field b { position: absolute; right: .85rem; top: .55rem; font-weight: 400; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
#debt-form .grid2 .field { display: flex; flex-direction: column; }
#debt-form .grid2 .field input { margin-top: auto; }
.radio-row, .debt-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice, .route-head, .checkline { display: flex; gap: .65rem; align-items: flex-start; min-height: 48px; padding: .6rem .75rem; }
.choice { border: 1px solid var(--field-border); border-radius: 4px; font-size: 1rem; }
.choice:has(input:checked), .route-card:has(.route-check:checked) > .route-head { background: var(--soft); }
input[type=radio], input[type=checkbox] { width: 1.2rem; height: 1.2rem; margin: .2rem 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.route-card { margin: .65rem 0; border: 1px solid var(--line); border-radius: 4px; }
.route-head { padding: .8rem; }
.route-head small, .checkline small, .doc-link small { display: block; margin-top: .2rem; }
.route-body { padding: 1rem; border-top: 1px solid var(--line); }
.checkline { margin: .5rem 0; padding-inline: 0; }
#review-copies .review-copy-options { display: grid; grid-template-columns: 1fr; grid-auto-rows: 1fr; gap: .5rem; }
#review-copies .review-copy-options > .checkline, #review-copies > #confirmed {
  padding: .6rem .75rem;
  border-radius: 4px;
}
#review-copies .review-copy-options > .checkline { align-items: center; margin: 0; }
#review-copies .review-copy-options > .checkline input { align-self: center; margin-top: 0; }
.subtle-line { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.result-top, .route-result, .prep-item { display: flex; gap: .65rem; align-items: baseline; }
.route-result b, .prep-item > span { flex: 0 0 auto; }
.route-results { display: grid; gap: .5rem; margin-bottom: 1rem; }
.notice, .completion-banner, .preparation-note { background: var(--soft); border-left: 3px solid var(--accent); padding: 1rem; margin-bottom: 1rem; }
.notice p, .completion-banner p { margin: .4rem 0 0; }
.notice.warning { color: #634818; border-color: #956925; background: #fbf1dc; }
.notice.error { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.note { border-left: 2px solid var(--line); padding-left: .85rem; }
.amount-summary .big, .price { font: 500 clamp(1.6rem, 3.7vw, 2.4rem)/1.2 var(--sans); }
.amount-summary, .debt-info { margin-bottom: 1rem; }
.debt-info { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.debt-card, .paper-preview, .ip-entry, .review-debt { overflow-wrap: anywhere; }
.debt-card .kind { font-size: 1rem; color: var(--muted); }
.debt-money { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.debt-card.unsupported { border-left: 3px solid var(--gold); }
.ip-entry, .bank-entry { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.debt-actions .remove { color: var(--danger); }
details summary { min-height: 48px; padding-block: .65rem; color: var(--accent); font-size: 1rem; }
.review-sections details, details.review-sections, .review-debt { border-top: 1px solid var(--line); }
.review-debt { padding-block: .65rem; font-size: 1rem; }
.review-debt small, .paper-preview .sample-stamp, .purchase .price small { font: 400 1rem/1.5 var(--sans); }
.paper-preview { font-family: var(--serif); }
.paper-title { font-weight: 700; text-align: center; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 1rem; table-layout: fixed; }
.mini-table td, .mini-table th { overflow-wrap: anywhere; border: 1px solid var(--line); padding: .35rem; text-align: left; }
.purchase { background: var(--soft); }
.button, .add-button {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 48px; max-width: 100%; padding: .7rem 1.05rem; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: white; font-size: 1.0625rem; font-weight:600; line-height: 1.35; text-align: center; text-decoration: none;
}
.button:enabled:hover { filter: brightness(.92); }
.button.secondary, .add-button { color: var(--accent); background: var(--white); }
.add-button, .button.full { width: 100%; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .65rem; padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.page-actions:empty { display: none; }
.error-link, .doc-link { display: block; min-height: 48px; padding: .6rem 0; border: 0; background: transparent; text-align: left; text-decoration: underline; }
.local-note { margin-top: 1.35rem; }
.site-footer { padding: 1.5rem 1rem; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 1rem; }
.site-footer p { margin: .25rem 0; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
dialog { border: 1px solid var(--line); border-radius: 7px; padding: 2rem; max-width: 43rem; width: calc(100% - 2rem); max-height: 90vh; max-height: 90dvh; overflow-y: auto; color: var(--ink); background: var(--white); }
dialog::backdrop { background: #102446a8; }
dialog h2, dialog .kicker:first-child { padding-right: 2.5rem; }
#modal .modal-x {
  position: absolute;
  top: .3rem;
  right: .3rem;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
#modal .modal-x svg {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  background: var(--danger);
  color: #fff;
}
#modal .modal-x:hover svg { filter: brightness(.9); }
.dialog-actions { margin-top: 1rem; }
.toast { visibility: hidden; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 2rem); padding: .75rem 1rem; background: var(--ink); color: white; border-radius: 4px; font-size: 1rem; pointer-events: none; z-index: 9; }
.toast.shown { visibility: visible; }
.flash { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (max-width: 52rem) {
  .header-inner { align-items: flex-start; flex-wrap: wrap; gap: .65rem; }
  .workspace { grid-template-columns: 1fr; padding-top: 1rem; gap: 0; }
  .rail { grid-row: 2; margin-top: 1.5rem; }
  .workspace > main { grid-column: 1; }
  .mobile-stage-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: .45rem; font-size: 1rem; }
  .mobile-progress, .mobile-free { display: block; }
  .mobile-progress { color: var(--muted); font-size: 1rem; margin-bottom: .9rem; }
  .mobile-progress .meta { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; }
  .progress-track { display: flex; gap: .25rem; margin-top: .35rem; }
  .progress-track span { flex: 1; height: .25rem; background: var(--line); }
  .progress-track span.active { background: var(--accent); }
}
@media (max-width: 37rem) {
  .file-tools { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
  .file-action { padding: .4rem .55rem; line-height: 1.25; }
  .file-action[data-recover] { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .65rem; }
  .service-title { padding-top: 1.05rem; }
  .service-title h1 { font-size: 1.65rem; }
  .grid2 { grid-template-columns: 1fr; }
  .task-head { flex-wrap: wrap; gap: .2rem .6rem; padding: .8rem; }
  .task-body, .route-body { padding: .8rem; }
  .radio-row { display: grid; grid-template-columns: 1fr; }
  .panel-heading, .amount-summary, .debt-card .top, .review-debt { display: block; }
  .result-actions, .start-actions, .dialog-actions { display: grid; gap: .5rem; grid-template-columns: 1fr; }
  dialog { padding: 1.1rem; width: calc(100% - 1rem); max-height: calc(100dvh - 1rem); }
}
@media (max-width: 20rem) {
  .file-tools { grid-template-columns: 1fr; }
  .file-action[data-recover] { grid-column: auto; }
}
@media print {
  .site-header, .rail, .mobile-progress, .page-actions, .site-footer, .local-note, .file-tools, .purchase, .toast { display: none; }
  body { background: white; color: black; }
  .workspace { display: block; padding: 0; }
  .panel, .paper-preview { border: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

.start-actions { margin-bottom: 24px; }

@media (max-width: 37rem) {
  .file-tools { grid-template-columns: 1fr; gap: 8px; }
  .file-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; padding: 8px 16px; }
  .file-action[data-recover] { grid-column: auto; justify-content: center; gap: 4px 12px; }
}
