:root {
  --bg: #0b0f1a;
  --surface: #111827;
  --surface2: #1a2235;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 179, 237, 0.5);
  --text: #f1f5f9;
  --muted: #64748b;
  --accent: #63b3ed;
  --accent2: #4fd1c5;
  --danger: #fc8181;
  --success: #68d391;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Background atmosphere */
body::before {
  content: "";
  position: fixed;
  width: 600px;
  height: 600px;
  background: radial-gradient(
    circle,
    rgba(99, 179, 237, 0.08) 0%,
    transparent 70%
  );
  top: -100px;
  left: -100px;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  width: 500px;
  height: 500px;
  background: radial-gradient(
    circle,
    rgba(79, 209, 197, 0.06) 0%,
    transparent 70%
  );
  bottom: -80px;
  right: -80px;
  pointer-events: none;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.4;
  z-index: 0;
}

.card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  margin: 1rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 24px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.logo-area {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(99, 179, 237, 0.25);
}

.logo-title {
  font-family: "DM Serif Display", serif;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.logo-sub {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

/* Form */
.fg {
  margin-bottom: 1rem;
}

.fg label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}

.fg input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  -webkit-text-fill-color: var(--text);
}
.fg input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
}
/* Supporto autofill (Google Password Manager) */
.fg input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 100px var(--surface2) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
}

.password-wrap {
  position: relative;
}
.password-wrap input {
  padding-right: 2.8rem;
}
.toggle-pw {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.toggle-pw:hover {
  color: var(--text);
}

.btn-login {
  width: 100%;
  padding: 0.85rem;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0b0f1a;
  font-family: "DM Sans", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}
.btn-login:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 179, 237, 0.3);
}
.btn-login:active {
  transform: translateY(0);
}
.btn-login:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-login.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* Messaggi */
.msg {
  display: none;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 1rem;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.msg.error {
  background: rgba(252, 129, 129, 0.1);
  border: 1px solid rgba(252, 129, 129, 0.25);
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.msg.success {
  background: rgba(104, 211, 145, 0.1);
  border: 1px solid rgba(104, 211, 145, 0.25);
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 440px) {
  .card {
    padding: 2rem 1.4rem;
    border-radius: 20px;
  }
  .logo-title {
    font-size: 1.4rem;
  }
}
