/* Общая основа: цвета двух тем, типографика, кнопки, поля, окна. */
:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f3eee6; --text: #1c1917; --muted: #78716c; --line: #e7e0d5;
  --accent: #c2410c; --on-accent: #ffffff; --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --ok: #15803d; --warn: #b45309; --danger: #b91c1c; --info: #1d4ed8;
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 12px 32px -12px rgba(28, 25, 23, .18);
  --radius: 14px; --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(.2, .7, .1, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12100e; --surface: #1c1917; --surface-2: #272321; --text: #f5f0e8; --muted: #a8a29e; --line: #37312d;
  --accent: #ea6a2e; --on-accent: #1a0f08;
  --ok: #4ade80; --warn: #fbbf24; --danger: #f87171; --info: #93c5fd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; transition: background-color .35s, color .35s;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .2s, border-color .2s, opacity .2s;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .btn.ok { color: #052e16; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.lg { min-height: 54px; padding: 0 26px; font-size: 17px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { width: 44px; padding: 0; }
.btn.icon.sm { width: 36px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.busy { pointer-events: none; opacity: .7; }
.ico { width: 20px; height: 20px; flex: none; display: inline-flex; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* поля */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); transition: border-color .2s, box-shadow .2s;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }

/* переключатель */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 46px; height: 28px; border-radius: 99px; background: var(--line); transition: background-color .25s; flex: none; position: relative; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .25s var(--ease); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* выбор из нескольких вариантов */
.seg { display: inline-flex; justify-self: start; padding: 4px; background: var(--surface-2); border-radius: 12px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* карточки, метки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.badge.info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.notice { padding: 12px 16px; border-radius: var(--radius-s); background: var(--surface-2); font-size: 14.5px; }
.notice.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.notice.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; }

/* всплывающие сообщения */
.toasts { position: fixed; z-index: 1000; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 13px 18px; border-radius: 12px; font-size: 15px; font-weight: 500; box-shadow: var(--shadow); animation: toast-in .35s var(--ease); text-align: center; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* окна */
.overlay { position: fixed; inset: 0; z-index: 900; background: rgba(12, 10, 9, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade .25s; overflow-y: auto; }
.modal { width: min(100%, var(--w, 480px)); background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); animation: pop .35s var(--ease); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0 24px; }
.modal-head h3 { font-size: 20px; }
.modal-body { padding: 18px 24px 24px; overflow-y: auto; }
.modal-foot { padding: 14px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.overlay.out { opacity: 0; transition: opacity .2s; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.97); } }
@media (max-width: 560px) {
  .overlay { padding: 0; align-items: end; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; max-height: 94dvh; animation-name: sheet; }
  @keyframes sheet { from { transform: translateY(100%); } }
}

/* таблицы */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; min-height: 40vh; }

/* текст документов */
.doc { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; }
.doc h1 { font: 600 clamp(28px, 5vw, 40px)/1.1 var(--font-display); margin-bottom: 20px; }
.doc h2 { font-size: 20px; margin: 32px 0 10px; }
.doc p { margin: 0 0 12px; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.doc ul { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 6px; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
