:root {
  color-scheme: light;
  --background: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #d8dee8;
  --border-strong: #bbc5d4;
  --accent: #356bd6;
  --accent-hover: #2857b8;
  --danger: #c8323e;
  --danger-soft: #fff0f1;
  --shadow: 0 16px 50px rgba(20, 35, 60, 0.08), 0 1px 2px rgba(20, 35, 60, 0.08);
  font-family: Nunito, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  padding: clamp(12px, 3vw, 28px);
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(53, 107, 214, 0.08), transparent 44%),
    var(--background);
  font-size: 15px;
  line-height: 1.5;
}

body.auth-page {
  display: grid;
  place-items: center;
}

.shell {
  display: grid;
  width: min(100%, 980px);
  min-height: min(760px, calc(100vh - 56px));
  margin: auto;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-page .shell {
  width: min(100%, 520px);
  min-height: 0;
  box-shadow: 0 24px 80px rgba(20, 35, 60, 0.16);
}

header {
  display: flex;
  min-height: 64px;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

.auth-page header {
  min-height: 82px;
  justify-content: center;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.brand {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.header-actions form {
  display: grid;
  place-items: center;
  margin: 0;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  border: 0;
  color: var(--text);
  background: var(--surface-muted);
  text-decoration: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

main {
  display: flex;
  width: min(100%, 760px);
  margin: auto;
  padding: clamp(28px, 6vw, 64px) clamp(22px, 6vw, 56px);
  flex-direction: column;
  gap: 20px;
}

.auth-page main {
  width: 100%;
  padding: 22px 32px 36px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-muted);
}

.nav-item:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.nav-item strong {
  display: block;
}

.nav-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 7px;
  color: var(--accent);
  background: var(--surface);
}

.nav-arrow {
  color: var(--muted);
  font-size: 1.25rem;
}

.back-link {
  align-self: flex-start;
  color: var(--muted);
  font-weight: 700;
}

.back-link svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.button-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
}

.button-link:hover {
  border-color: var(--accent-hover);
  color: #ffffff;
  background: var(--accent-hover);
  text-decoration: none;
}

.empty-state {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-muted);
}

.danger-button {
  border-color: var(--danger);
  background: var(--danger);
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 700;
}

label:has(input[type="radio"]),
label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  justify-self: start;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid rgba(53, 107, 214, 0.48);
  outline-offset: 2px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row input {
  min-width: 0;
  flex: 1;
}

ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

li {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.muted {
  color: var(--muted);
}

[role="alert"],
[role="status"] {
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.86rem;
}

[role="status"]:empty {
  display: none;
}

#ping-result[data-state="pending"],
#ping-result[data-state="success"] {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-muted);
}

@media (max-width: 520px) {
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-page main {
    padding: 22px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #0d1118;
    --surface: #151b25;
    --surface-muted: #1b2330;
    --text: #f2f5f9;
    --muted: #a8b3c4;
    --border: #303a49;
    --border-strong: #4a5668;
    --accent: #72a0ff;
    --accent-hover: #9bbcff;
    --danger: #ff7d88;
    --danger-soft: #3a1d25;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  }

  button {
    border-color: #456fae;
    background: #456fae;
  }

  button:hover {
    border-color: #3d65a5;
    background: #3d65a5;
  }
}
