*, *::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.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.container { width: min(100% - 40px, var(--container)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.grad-text { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hidden { display: none !important; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev-2); color: var(--text); font-weight: 600; font-size: 15px;
  cursor: pointer; transition: transform .15s var(--ease), background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #33435a; background: #1f2935; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--gradient); color: var(--accent-ink); border: 0; }
.btn-primary:hover { background: var(--gradient); filter: brightness(1.06); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 16px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }

/* Формы */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--text); transition: border-color .15s;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-2); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Карточки и бейджи */
.card { background: var(--bg-elev); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 22px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg-elev-2); color: var(--text-dim); border: 1px solid var(--line);
}
.badge-ok { color: var(--success); border-color: rgba(61, 220, 132, .35); }
.badge-err { color: var(--danger); border-color: rgba(255, 93, 108, .35); }
.badge-warn { color: var(--warning); border-color: rgba(255, 181, 71, .35); }
.zone-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.z1 { --zc: var(--z1); } .z2 { --zc: var(--z2); } .z3 { --zc: var(--z3); } .z4 { --zc: var(--z4); } .z5 { --zc: var(--z5); }
.zone-dot { background: var(--zc, var(--text-faint)); }

/* Тосты */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 1000; }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg-elev-2); border: 1px solid var(--line);
  box-shadow: var(--shadow); max-width: 380px; animation: toast-in .25s var(--ease);
}
.toast-error { border-color: rgba(255, 93, 108, .5); }
.toast-ok { border-color: rgba(61, 220, 132, .5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

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