:root {
  color-scheme: dark;

  --bg-base: #05060a;
  --bg-radial: radial-gradient(circle at 50% 0%, #12131c 0%, #05060a 60%);
  --blob-opacity: 0.55;

  --text-primary: #f5f5f7;
  --text-secondary: rgba(245, 245, 247, 0.6);
  --footer-color: rgba(245, 245, 247, 0.35);

  --heading-1: #ffffff;
  --heading-2: #d1497f;
  --heading-3: #f5add2;

  --brand-1: #7a1f52;
  --brand-2: #b83176;
  --brand-3: #f5add2;
  --brand-gradient: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 55%, var(--brand-3) 100%);

  --topbar-bg: transparent;
  --topbar-border: rgba(255, 255, 255, 0.08);

  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.16);
  --card-shadow: rgba(0, 0, 0, 0.45);

  --input-bg: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.18);
  --input-border-focus: rgba(255, 255, 255, 0.4);

  --dropdown-hover: rgba(255, 255, 255, 0.08);
  --divider: rgba(255, 255, 255, 0.12);

  --danger: #ff6b6b;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg-base: #eef0f7;
  --bg-radial: radial-gradient(circle at 50% 0%, #ffffff 0%, #eef0f7 60%);
  --blob-opacity: 0.32;

  --text-primary: #1d1d1f;
  --text-secondary: rgba(29, 29, 31, 0.62);
  --footer-color: rgba(29, 29, 31, 0.4);

  --heading-1: #1d1d1f;
  --heading-2: #b83176;
  --heading-3: #d1497f;

  --topbar-bg: transparent;
  --topbar-border: rgba(0, 0, 0, 0.08);

  --card-bg: rgba(255, 255, 255, 0.7);
  --card-border: rgba(0, 0, 0, 0.08);
  --card-shadow: rgba(20, 20, 40, 0.15);

  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: rgba(0, 0, 0, 0.14);
  --input-border-focus: rgba(0, 0, 0, 0.35);

  --dropdown-hover: rgba(0, 0, 0, 0.06);
  --divider: rgba(0, 0, 0, 0.08);

  --danger: #d9364a;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-base);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
  transition: background 0.4s ease, color 0.4s ease;
}

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

/* ---------- Aurora background ---------- */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-radial);
  transition: background 0.4s ease;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: var(--blob-opacity);
  will-change: transform;
  transition: opacity 0.4s ease;
}

.blob-1 {
  width: 55vmax;
  height: 55vmax;
  top: -20vmax;
  left: -15vmax;
  background: radial-gradient(circle, #7b5bff 0%, transparent 70%);
  animation: drift1 26s ease-in-out infinite;
}

.blob-2 {
  width: 50vmax;
  height: 50vmax;
  bottom: -22vmax;
  right: -12vmax;
  background: radial-gradient(circle, #ff5f8a 0%, transparent 70%);
  animation: drift2 30s ease-in-out infinite;
}

.blob-3 {
  width: 40vmax;
  height: 40vmax;
  top: 20vmax;
  right: 5vmax;
  background: radial-gradient(circle, #3ac6ff 0%, transparent 70%);
  animation: drift3 34s ease-in-out infinite;
}

.blob-4 {
  width: 35vmax;
  height: 35vmax;
  bottom: 5vmax;
  left: 10vmax;
  background: radial-gradient(circle, #f5add2 0%, transparent 70%);
  animation: drift1 22s ease-in-out infinite reverse;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 4vmax) scale(1.08); }
}

@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-5vmax, -6vmax) scale(1.1); }
}

@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-4vmax, 5vmax) scale(0.95); }
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: 3;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.6rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.brand-name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle .track {
  position: relative;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  background: rgba(120, 120, 140, 0.35);
  border: 1px solid var(--input-border);
  display: flex;
  align-items: center;
  padding: 0 6px;
  justify-content: space-between;
  font-size: 12px;
  transition: background 0.3s ease;
}

.theme-toggle .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.theme-toggle input:checked ~ .track .thumb {
  transform: translateX(24px);
}

.theme-toggle input:checked ~ .track {
  background: rgba(120, 120, 140, 0.5);
}

/* ---------- User menu ---------- */

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  border-radius: 999px;
  color: var(--text-primary);
  transition: background 0.2s ease;
  font-family: inherit;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--dropdown-hover);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--brand-gradient);
  flex-shrink: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  width: 14px;
  height: 14px;
  opacity: 0.6;
  transition: transform 0.25s ease;
}

.user-menu-trigger[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px var(--card-shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 0.4rem;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.user-menu-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}

.dropdown-item svg {
  width: 17px;
  height: 17px;
  opacity: 0.75;
  flex-shrink: 0;
}

.dropdown-item:hover {
  background: var(--dropdown-hover);
}

.dropdown-item--danger {
  color: var(--danger);
}

.dropdown-item--danger svg {
  opacity: 0.9;
}

.dropdown-divider {
  height: 1px;
  margin: 0.3rem 0.4rem;
  background: var(--divider);
}

/* ---------- Layout ---------- */

.splash {
  position: relative;
  z-index: 1;
  width: min(920px, 92vw);
  padding: 3.5rem 1rem 3rem;
  text-align: center;
}

.splash-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--heading-1) 0%, var(--heading-2) 60%, var(--heading-3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.splash-header p {
  margin: 0.6rem 0 0;
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 400;
}

/* ---------- Icon grid ---------- */

.app-grid {
  margin-top: 3.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 2.2rem 1.4rem;
  justify-items: center;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  perspective: 600px;
}

.icon {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3),
              box-shadow 0.35s ease;
  overflow: hidden;
}

.icon svg {
  width: 42px;
  height: 42px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.icon::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 45%);
  z-index: 1;
}

.icon::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: translateX(-120%) rotate(20deg);
  transition: transform 0.7s ease;
  z-index: 2;
}

.app:hover .icon::after,
.app:focus-visible .icon::after {
  transform: translateX(340%) rotate(20deg);
}

.app:hover .icon,
.app:focus-visible .icon {
  box-shadow:
    0 18px 34px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.app:active .icon {
  transform: scale(0.94);
}

.label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  opacity: 0.85;
  letter-spacing: 0.01em;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.app:hover .label,
.app:focus-visible .label {
  opacity: 1;
  transform: translateY(1px);
}

.icon-ermes { background: linear-gradient(160deg, #6a5bff, #3d3ba8); }
.icon-eventi { background: linear-gradient(160deg, #ffffff, #d8d8dc); }
.icon-mbs { background: linear-gradient(160deg, #7a4bff, #4a2a9e); }
.icon-corsi { background: linear-gradient(160deg, #ff8a4c, #ff4d6d); }
.icon-time { background: linear-gradient(160deg, #33d1c4, #1f8f9e); }
.icon-osmanage { background: linear-gradient(160deg, #8b95a5, #4d5566); }
.icon-academy { background: linear-gradient(160deg, #b83176, #7a1f52); }

/* ---------- Footer ---------- */

.splash-footer {
  position: relative;
  z-index: 1;
  padding-bottom: 1.6rem;
  color: var(--footer-color);
  font-size: 0.8rem;
  margin-top: auto;
}

/* ---------- Login page ---------- */

.login-page {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-topbar {
  position: relative;
  z-index: 3;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1.2rem 1.6rem;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: 0 24px 60px var(--card-shadow);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  padding: 2.4rem 2rem 2rem;
  text-align: center;
}

.login-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(184, 49, 118, 0.35));
}

.login-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-card > p {
  margin: 0 0 1.8rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.field {
  text-align: left;
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}

.field input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--input-border-focus);
  box-shadow: 0 0 0 3px rgba(184, 49, 118, 0.25);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0 1.4rem;
  font-size: 0.82rem;
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
}

.remember-me input {
  accent-color: #b83176;
}

.forgot-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.forgot-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.login-submit {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 11px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.94rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(184, 49, 118, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(184, 49, 118, 0.45);
}

.login-submit:active {
  transform: translateY(0) scale(0.98);
}

.login-hint {
  margin-top: 1.3rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* ---------- Profile placeholder page ---------- */

.profile-page {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
}

.profile-card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: 0 24px 60px var(--card-shadow);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  padding: 2.4rem 2rem;
}

.profile-card .avatar {
  width: 64px;
  height: 64px;
  font-size: 1.3rem;
  margin: 0 auto 1rem;
}

.profile-card h1 {
  margin: 0 0 0.3rem;
  font-size: 1.3rem;
}

.profile-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0.3rem 0 1.6rem;
}

.back-link {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  opacity: 0.85;
}

.back-link:hover {
  opacity: 1;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
  }
  .icon svg {
    width: 34px;
    height: 34px;
  }
  .user-name {
    display: none;
  }
}
