*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding-left: 1.15rem; }
h1 { font-size: 1.65rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 0.98rem; line-height: 1.35; }
small { font-size: 0.82rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
code, kbd, pre { font-family: var(--font-mono); }
code {
  padding: 0.12em 0.38em;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.88em;
  word-break: break-word;
}
pre {
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.82rem;
}
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}
.boot-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: var(--shadow-2);
}
.noscript { padding: 2rem; text-align: center; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.small { font-size: 0.84rem; }
.strong { font-weight: 650; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: grid; gap: 1rem; }
.stack-sm { display: grid; gap: 0.5rem; }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.35rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1.25rem; }
.mb-2 { margin-bottom: 0.75rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 65%, transparent);
  outline-offset: 2px;
}

label { display: block; font-size: 0.86rem; font-weight: 600; color: var(--text-muted); }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
input[readonly] { background: var(--bg-subtle); color: var(--text-muted); }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; accent-color: var(--primary); }
input[type="date"] { min-height: 42px; }

.field { display: grid; gap: 0.3rem; }
.field > .help { font-size: 0.8rem; color: var(--text-muted); }
.field > .error { font-size: 0.8rem; color: var(--danger); }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }

.form-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 40px;
  padding: 0.5rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 620;
  font-size: 0.88rem;
  line-height: 1.1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-faint); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 84%, #000); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { min-height: 32px; padding: 0.3rem 0.6rem; font-size: 0.8rem; border-radius: 7px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}
.link-button:hover { text-decoration: underline; }

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

.error { color: var(--danger); font-size: 0.84rem; margin: 0; min-height: 1.1em; }
.notice + .error:empty, .error:empty { min-height: 0; }
