* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: var(--font-main);
  background: linear-gradient(180deg, var(--bg) 0%, #0c131d 58%, #080d13 100%);
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
.login-error:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.95);
  outline-offset: 3px;
}

.login-shell {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  width: min(100% - 32px, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
}

.login-card {
  width: 100%;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: rgba(59, 130, 246, 0.13);
  box-shadow: inset 0 0 24px rgba(59, 130, 246, 0.08);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.eyebrow {
  margin: 1px 0 5px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 6vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.login-intro {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 18px;
  padding-top: 24px;
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field label {
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 650;
}

.form-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  caret-color: var(--accent-strong);
  background: rgba(15, 23, 36, 0.86);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.form-field input:hover {
  border-color: rgba(148, 163, 184, 0.52);
}

.form-field input:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .eye-closed,
.password-toggle[aria-pressed="true"] .eye-open {
  display: none;
}

.password-toggle[aria-pressed="true"] .eye-closed {
  display: block;
}

.login-error {
  margin: -2px 0 0;
  padding: 11px 12px;
  border: 1px solid rgba(239, 68, 68, 0.34);
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: var(--danger-bg);
  font-size: 0.86rem;
  line-height: 1.5;
}

.login-error[hidden] {
  display: none;
}

.login-button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid rgba(96, 165, 250, 0.62);
  border-radius: var(--radius-sm);
  color: #eff6ff;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22);
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.login-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.login-button:active:not(:disabled) {
  transform: translateY(1px);
}

.login-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.session-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: -2px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.estimate-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
}

@media (max-width: 520px) {
  .login-shell {
    width: min(100% - 24px, 440px);
    align-content: center;
  }

  .login-card {
    padding: 22px 18px;
  }

  .login-header {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 13px;
  }

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

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