/* Единая палитра: светлая и тёмная темы через CSS-переменные. Только системные шрифты. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1b2430;
  --muted: #5a6677;
  --border: #d5dce6;
  --primary: #2e6b24;
  --primary-hover: #245a1c;
  --primary-text: #ffffff;
  --accent: #4e8a2b;
  --accent-soft: #e6f3d9;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --focus: #1a73e8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171e;
    --surface: #1a2029;
    --surface-2: #222a35;
    --text: #e6ebf2;
    --muted: #9aa7b8;
    --border: #323c4a;
    --primary: #85bb4f;
    --primary-hover: #a3d06b;
    --primary-text: #07110a;
    --accent: #bfe58f;
    --accent-soft: #1d2e14;
    --danger: #ff8a80;
    --danger-soft: #3b1e1c;
    --warn: #f2c14e;
    --warn-soft: #3a2f12;
    --focus: #8ab4f8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  min-width: 320px; overflow-x: hidden;
}
h1 { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.1rem); line-height: 1.2; margin: .4em 0 .3em; }
h2 { font-size: 1.1rem; margin: 0 0 .6em; }
p { margin: 0 0 .8em; }
a { color: var(--primary); }
img { max-width: 100%; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--primary-text); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Шапка */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-text { font-weight: 800; letter-spacing: .12em; font-size: 1.25rem; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-size: .9rem; }
main { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 18px 0; }
.crumbs { margin-bottom: 4px; font-size: .95rem; }

/* Главная */
.hero { padding: 12px 0 8px; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 70ch; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 20px 0; }
.choice {
  display: flex; flex-direction: column; gap: 8px; padding: 22px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.choice:hover { border-color: var(--primary); transform: translateY(-2px); }
.choice-tag { align-self: flex-start; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 2px 10px; border-radius: 999px; font-size: .85rem; }
.choice-title { font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.choice-text { color: var(--muted); }
.choice-go { margin-top: auto; color: var(--primary); font-weight: 600; }

.notice { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 14px 16px; color: var(--muted); font-size: .95rem; margin: 20px 0; }
.notice strong { color: var(--text); }

/* Формы */
.calc-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
input[type="text"], input[type="date"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
input:disabled { opacity: .5; }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.error-text { color: var(--danger); font-size: .9rem; margin: 6px 0 0; font-weight: 600; }
.has-error input[type="text"], .has-error input[type="date"], .has-error .file-drop { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.file-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--bg); border: 1px dashed var(--border); border-radius: 10px; padding: 12px; }
input[type="file"] { font: inherit; max-width: 100%; color: var(--text); }
.file-name { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.file-name.is-bad { color: var(--danger); font-weight: 600; }
.radio { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--primary); }
.period-from { margin: 4px 0 0 30px; max-width: 240px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600;
  min-height: 46px; padding: 10px 20px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; }
.btn-large { min-height: 52px; padding: 12px 26px; font-size: 1.05rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-busy { cursor: progress; }
[hidden] { display: none !important; }

/* Алерты */
.alert { border-radius: 10px; padding: 14px 16px; margin: 14px 0; border: 1px solid; }
.alert p { margin-bottom: .4em; }
.alert ul { margin: 0; padding-left: 20px; }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); }
.alert-warn h2 { color: var(--warn); font-size: 1rem; }
.problem-list { max-height: 260px; overflow: auto; }

/* Результат */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.debtor { margin: 14px 0; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 14px 0; }
.total-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.total-main { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.total-label { font-size: .9rem; opacity: .85; }
.total-value { font-size: clamp(1.35rem, 1rem + 1.6vw, 1.9rem); font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.meta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 14px 0; }
.chip { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 4px 14px; border-radius: 999px; }
.doc-type { font-size: 1.15rem; font-weight: 700; margin-bottom: .3em; }

.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.calc-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; min-width: 860px; }
.calc-table th, .calc-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
.calc-table thead th { position: sticky; background: var(--surface-2); z-index: 2; text-align: center; top: 0; }
.calc-table thead tr:nth-child(2) th { top: 34px; }
.calc-table .num { text-align: right; }
.calc-table .note { white-space: normal; min-width: 180px; }
.calc-table .month { background: var(--surface-2); text-align: center; font-weight: 600; }
.calc-table tbody td[rowspan] { text-align: center; }
.calc-table tr.repay td { color: var(--muted); font-style: italic; }
.calc-table tr.repay td.num { color: var(--accent); font-style: normal; }
.calc-table tbody:last-of-type tr:last-child > * { border-bottom: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 8px; }
.error-page { text-align: center; padding: 40px 0; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--muted); margin: 0; }

@media (max-width: 520px) {
  .calc-form { padding: 14px; }
  .actions .btn { width: 100%; }
  .brand-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { .choice { transition: none; } }

/* Шаги документа */
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 8px; }
.steps li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .9rem; }
.steps li:not(:last-child)::after { content: "\2192"; margin-left: 4px; color: var(--muted); }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: .8rem; }
.steps li.is-current { border-color: var(--primary); color: var(--text); font-weight: 600; }
.steps li.is-current .step-num { background: var(--primary); color: var(--primary-text); }
.steps li.is-done .step-num { background: var(--accent-soft); color: var(--accent); }

.court-doc { margin: 18px 0; display: grid; gap: 10px; }
.inline-form { display: grid; gap: 12px; }
.confirm-form { display: grid; gap: 10px; margin-top: 10px; }
.summary-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.summary-table th, .summary-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.summary-table .num { text-align: right; white-space: nowrap; }
.summary-facts { margin-top: 8px; }
@media (max-width: 520px) { .steps li { padding: 4px 8px; } .step-label { display: none; } .steps li.is-current .step-label { display: inline; } }
