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

:root {
  --brand: #00aaff;
  --brand-dim: rgba(0,170,255,0.10);
  --brand-glow: rgba(0,170,255,0.30);
  --brand-dark: #0088cc;
  --success: #00c07a;
  --success-dim: rgba(0,192,122,0.10);
  --error: #e8334a;
  --error-dim: rgba(232,51,74,0.10);
  --warn: #f59e0b;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f3f8ff; --bg2: #e8f2ff;
  --surface: #ffffff; --surface2: #f7faff;
  --border: rgba(0,100,200,0.10); --border-focus: rgba(0,170,255,0.55);
  --text: #0d1a2e; --text-muted: #8096b8; --text-sub: #4d6480;
  --shadow: rgba(0,80,180,0.10); --grid-color: rgba(0,120,255,0.06);
}
[data-theme="dark"] {
  --bg: #080c12; --bg2: #0d1117;
  --surface: #111820; --surface2: #161e2a;
  --border: rgba(255,255,255,0.07); --border-focus: rgba(0,170,255,0.5);
  --text: #eef2ff; --text-muted: #6b7a99; --text-sub: #8896b3;
  --shadow: rgba(0,0,0,0.6); --grid-color: rgba(255,255,255,0.04);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* BG */
.bg-grid {
  position: fixed; inset: 0;
  background-image: linear-gradient(var(--grid-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
}
.bg-orb { position: fixed; border-radius: 50%; filter: blur(120px); pointer-events: none; z-index: 0; }
.bg-orb-1 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(0,170,255,0.12), transparent 70%); top: -150px; right: -100px; animation: orbFloat 8s ease-in-out infinite; }
.bg-orb-2 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(0,170,255,0.07), transparent 70%); bottom: -100px; left: -100px; animation: orbFloat 10s ease-in-out infinite reverse; }
@keyframes orbFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-30px) scale(1.05); } }

/* THEME TOGGLE */
.theme-toggle {
  position: fixed; top: 20px; right: 20px; z-index: 100;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); box-shadow: 0 4px 20px var(--shadow);
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-dim); transform: scale(1.08); }
.theme-toggle svg { width: 18px; height: 18px; }

/* WRAPPER */
.wrapper { position: relative; z-index: 1; width: 100%; max-width: 480px; }

/* LOGO */
.logo-wrap { text-align: center; margin-bottom: 28px; animation: fadeUp 0.6s ease both; }
.logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-img { width: 44px; height: 44px; border-radius: 12px; object-fit: contain; box-shadow: 0 6px 24px var(--brand-glow); background: var(--surface); padding: 4px; border: 1.5px solid var(--border); }
.logo-icon-fallback { width: 44px; height: 44px; background: linear-gradient(135deg, var(--brand), #0066cc); border-radius: 12px; display: none; align-items: center; justify-content: center; box-shadow: 0 6px 24px var(--brand-glow); }
.logo-icon-fallback svg { width: 24px; height: 24px; fill: white; }
.logo-text { font-size: 1.55rem; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.logo-text span { color: var(--brand); }
.logo-sub { margin-top: 8px; font-size: 0.83rem; color: var(--text-muted); }

/* CARD */
.card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset, 0 20px 60px var(--shadow);
  position: relative; overflow: hidden;
  animation: fadeUp 0.7s ease 0.1s both;
}
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--brand), transparent); opacity: 0.6; }

.card-header { margin-bottom: 24px; }
.card-title { font-size: 1.35rem; font-weight: 800; color: var(--text); letter-spacing: -0.4px; margin-bottom: 4px; }
.card-sub { font-size: 0.82rem; color: var(--text-muted); }

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

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

label { font-size: 0.75rem; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.6px; }

/* INPUTS */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 13px; color: var(--text-muted); display: flex; align-items: center; pointer-events: none; transition: color var(--transition); }
.input-icon svg { width: 15px; height: 15px; stroke-width: 2; }

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px 12px 38px;
  font-family: var(--font-display); font-size: 0.88rem; font-weight: 500;
  color: var(--text); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
}
input::placeholder { color: var(--text-muted); font-weight: 400; opacity: 0.7; }
input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-dim); }
.input-wrap:focus-within .input-icon { color: var(--brand); }
input.invalid { border-color: var(--error) !important; box-shadow: 0 0 0 3px var(--error-dim) !important; }

/* PWD TOGGLE */
.pwd-toggle { position: absolute; right: 10px; background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; padding: 5px; border-radius: 6px; transition: color var(--transition), background var(--transition); }
.pwd-toggle:hover { color: var(--brand); background: var(--brand-dim); }
.pwd-toggle svg { width: 15px; height: 15px; stroke-width: 2; }

/* REMEMBER / FORGOT ROW */
.form-meta { display: flex; align-items: center; justify-content: space-between; }
.remember-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; user-select: none; }
.remember-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.forgot-btn { background: none; border: none; color: var(--brand); font-size: 0.8rem; font-weight: 700; cursor: pointer; font-family: var(--font-display); padding: 0; transition: opacity var(--transition); }
.forgot-btn:hover { opacity: 0.75; text-decoration: underline; }

/* FIELD ERROR */
.field-error { font-size: 0.72rem; color: var(--error); font-weight: 500; display: none; align-items: center; gap: 4px; }
.field-error.show { display: flex; }
.field-error svg { width: 12px; height: 12px; flex-shrink: 0; }

/* SUBMIT */
.btn-submit {
  position: relative; width: 100%; padding: 14px 24px;
  background: linear-gradient(135deg, var(--brand), #0070cc);
  border: none; border-radius: var(--radius-sm); color: white;
  font-family: var(--font-display); font-size: 0.92rem; font-weight: 700;
  cursor: pointer; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 6px 24px var(--brand-glow);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.btn-submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 36px var(--brand-glow); }
.btn-submit:active:not(:disabled) { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-submit .btn-spinner { width: 17px; height: 17px; border: 2.5px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; display: none; }
.btn-submit.loading .btn-text { display: none; }
.btn-submit.loading .btn-spinner { display: block; }
.btn-submit svg { width: 17px; height: 17px; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* SIGNUP LINK */
.signin-link { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin-top: 20px; }
.signin-link a { color: var(--brand); font-weight: 700; text-decoration: none; transition: opacity var(--transition); }
.signin-link a:hover { opacity: 0.8; text-decoration: underline; }

/* FORGOT MODAL OVERLAY */
.modal-ov {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-ov.show { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 32px 28px; width: 100%; max-width: 420px;
  box-shadow: 0 24px 80px var(--shadow);
  animation: slideUp .28s cubic-bezier(.34,1.25,.64,1);
  position: relative;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { border-color: var(--error); color: var(--error); }

.modal-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-dim); border: 1.5px solid var(--border-focus); margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; }
.modal-ico svg { width: 24px; height: 24px; stroke: var(--brand); stroke-width: 2; }
.modal-title { font-size: 1.2rem; font-weight: 800; text-align: center; margin-bottom: 6px; letter-spacing: -0.3px; }
.modal-sub { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin-bottom: 24px; line-height: 1.5; }

.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.modal-field .input-wrap input { padding-left: 38px; }

.modal-err { font-size: 0.75rem; color: var(--error); font-weight: 500; margin-bottom: 10px; min-height: 18px; }
.modal-success { display: none; align-items: center; gap: 10px; padding: 12px; background: var(--success-dim); border: 1px solid rgba(0,192,122,0.2); border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 0.82rem; color: var(--success); font-weight: 600; }
.modal-success svg { width: 18px; height: 18px; flex-shrink: 0; }

/* TOAST */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; width: 100%; max-width: 400px; padding: 0 16px; }
.toast { display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-radius: 14px; backdrop-filter: blur(20px); box-shadow: 0 8px 32px rgba(0,0,0,0.15); width: 100%; pointer-events: all; cursor: pointer; animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both; position: relative; overflow: hidden; }
.toast.hiding { animation: toastOut 0.3s ease forwards; }
.toast.success { background: rgba(240,255,248,0.97); border: 1.5px solid rgba(0,192,122,0.2); }
.toast.error   { background: rgba(255,242,244,0.97); border: 1.5px solid rgba(232,51,74,0.2); }
.toast.info    { background: rgba(235,248,255,0.97); border: 1.5px solid rgba(0,170,255,0.2); }
[data-theme="dark"] .toast.success { background: rgba(0,20,12,0.95); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast.error   { background: rgba(20,0,8,0.95);  box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast.info    { background: rgba(0,10,20,0.95); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; border-radius: 2px; animation: toastProgress linear forwards; }
.toast.success .toast-progress { background: var(--success); }
.toast.error   .toast-progress { background: var(--error); }
.toast.info    .toast-progress { background: var(--brand); }
.toast-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-icon svg { width: 17px; height: 17px; stroke-width: 2.5; }
.toast.success .toast-icon { background: var(--success-dim); color: var(--success); }
.toast.error   .toast-icon { background: var(--error-dim);   color: var(--error); }
.toast.info    .toast-icon { background: var(--brand-dim);   color: var(--brand); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 0.86rem; font-weight: 700; margin-bottom: 2px; }
.toast.success .toast-title { color: var(--success); }
.toast.error   .toast-title { color: var(--error); }
.toast.info    .toast-title { color: var(--brand); }
.toast-msg { font-size: 0.76rem; color: var(--text-sub); line-height: 1.4; }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; padding: 3px; border-radius: 4px; flex-shrink: 0; }
.toast-close svg { width: 13px; height: 13px; stroke-width: 2.5; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(0.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(0.96); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-6px); }
  40%,80%  { transform: translateX(6px); }
}

@media (max-width: 480px) { .card { padding: 26px 18px; } .modal-box { padding: 24px 18px; } }