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

:root {
  --primary: #40739e;
  --primary-dark: #2e5c86;
  --primary-light: #e8f0f7;
  --text: #1a2535;
  --text-muted: #6b7c93;
  --border: #dde4ed;
  --bg: #f0f4f9;
  --white: #ffffff;
  --danger: #e74c3c;
  --success: #27ae60;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

body {
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 0 0 0;
  position: relative;
  overflow-x: hidden;
}

/* Background décoratif */
body::before {
  content: '';
  position: fixed;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(64,115,158,0.1) 0%, transparent 70%);
  top: -200px; right: -150px;
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46,92,134,0.08) 0%, transparent 70%);
  bottom: -150px; left: -100px;
  pointer-events: none;
}

/* ===== CARD ===== */
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 48px rgba(64,115,158,0.15);
  overflow: hidden;
  animation: fadeUp 0.6s ease both;
  position: relative;
  z-index: 1;
  margin-bottom: 24px;
}

/* Card header */
.card-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 32px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card-hero::before {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  top: -80px; right: -50px;
  pointer-events: none;
}

.brand-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 1.6rem;
  color: white;
}

.card-hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  color: white;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.card-hero p {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
}

/* Card body */
.card-body-custom {
  padding: 28px 36px 32px;
}

/* Year selector */
.year-selector {
  margin-bottom: 20px;
}

.year-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px;
  display: block;
}

.year-selector select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.year-selector select:focus { border-color: var(--primary); background: var(--white); box-shadow: 0 0 0 3px rgba(64,115,158,0.1); }

/* Divider */
.form-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Section title */
.section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Messages Django */
.messages-wrap { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.msg-alert { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 500; }
.msg-alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fca5a5; }
.msg-alert.success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.msg-alert i { font-size: 0.85rem; flex-shrink: 0; }

/* Form fields */
.form-section { display: flex; flex-direction: column; gap: 16px; }

.field-group { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.field-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon-left {
  position: absolute;
  left: 13px;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 1;
  transition: var(--transition);
}

.field-input-wrap input {
  width: 100%;
  padding: 11px 42px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: var(--transition);
}
.field-input-wrap input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(64,115,158,0.1);
}
.field-input-wrap input:focus + .field-icon-left { color: var(--primary); }

.toggle-password {
  position: absolute;
  right: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  z-index: 1;
}
.toggle-password:hover { color: var(--primary); }

/* Submit */
.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 9px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(64,115,158,0.35); }
.btn-login:active { transform: translateY(0); }

/* Forgot */
.forgot-link { text-align: center; margin-top: 14px; }
.forgot-link a { font-size: 0.8rem; color: var(--primary); text-decoration: none; font-weight: 500; transition: var(--transition); }
.forgot-link a:hover { color: var(--primary-dark); text-decoration: underline; }

/* Footer */
.login-footer { text-align: center; padding: 14px 36px; border-top: 1px solid var(--border); background: #fafbfc; font-size: 0.7rem; color: var(--text-muted); }

/* TOAST */
@keyframes slideInRight { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
.toast.slide-in { animation: slideInRight 0.4s ease forwards; }
.toast.slide-out { animation: slideOutRight 0.4s ease forwards; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

body, h1, h2, h3, h4, h5, h6, p, span, a, button, input, label, select {
  font-family: 'DM Sans', sans-serif !important;
}

@media (max-width: 480px) {
  .card-body-custom { padding: 22px 22px 26px; }
  .card-hero { padding: 24px 22px; }
  .login-footer { padding: 12px 22px; }
}
