:root {
  color-scheme: light;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #eef2f7;
  --text: #111827;
  --muted: #667085;
  --line: #d9e0ea;
  --danger: #b42318;
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1117;
  --surface: #111a24;
  --surface-muted: #172231;
  --text: #eef4ff;
  --muted: #9aa8bd;
  --line: #243247;
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 38%),
    radial-gradient(circle at top right, color-mix(in srgb, #14b8a6 14%, transparent), transparent 32%),
    var(--bg);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-particles {
  display: none;
}

.login-shell {
  width: min(100%, 460px);
}

.login-panel {
  width: 100%;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-lg);
}

.brand-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-row h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-row p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.theme-select,
.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.theme-select {
  margin-bottom: 16px;
}

.theme-select select,
.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.password-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.password-control input {
  border: 0;
  box-shadow: none;
}

.password-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.password-toggle {
  min-height: 34px;
  margin-right: 4px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.theme-select select:focus,
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.password-control input:focus {
  box-shadow: none;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.login-form {
  display: grid;
  gap: 13px;
}

.login-form .primary,
.toast button {
  cursor: pointer;
}

.login-form .primary {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 24%, transparent);
}

.login-form .primary:hover {
  background: var(--accent-strong);
}

.login-assist {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.login-assist button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.login-box {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-muted) 70%, transparent);
}

.hidden {
  display: none !important;
}

.empty-state {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

.login-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 50;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
  color: var(--danger);
}

.toast button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
}

@media (max-width: 520px) {
  .login-page {
    align-items: stretch;
    padding: 14px;
  }

  .login-panel {
    padding: 20px;
    border-radius: 10px;
  }

  .brand-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .brand-row h1 {
    font-size: 24px;
  }
}
