/* ═══════════════════════════════════════════════════════════════
   OS42 Login Page — Full Custom CSS
   Light theme to match the OS42 ERP UI design system.
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #f5f7fa;
  --bg-card:    #ffffff;
  --bg-input:   #f9fafb;
  --bg-input-f: #ffffff;
  --border:     #e5e7eb;
  --border-f:   #1677ff;
  --text:       #111827;
  --text-sub:   #6b7280;
  --text-muted: #9ca3af;
  --accent:     #1677ff;
  --accent-h:   #0958d9;
  --accent-glow:rgba(22,119,255,0.12);
  --error:      #dc2626;
  --error-bg:   rgba(220,38,38,0.05);
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --transition: 0.18s ease;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Decorative background ─────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(22,119,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,119,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 8% 50%, rgba(22,119,255,0.04) 0%, transparent 65%),
    radial-gradient(ellipse 50% 40% at 92% 50%, rgba(124,92,252,0.03) 0%, transparent 65%);
}

/* ── Layout shell ──────────────────────────────────────────────────── */
.login-shell {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* ── Left brand panel ──────────────────────────────────────────────── */
.brand-panel {
  width: 320px; flex-shrink: 0;
  background: #0f172a;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 36px;
  position: relative; overflow: hidden;
}

/* subtle grid */
.brand-panel::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.06) 1px, transparent 1px);
  background-size: 36px 36px;
}

/* top-right glow */
.brand-panel::after {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.18) 0%, transparent 70%);
}

.brand-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: flex-start; gap: 16px;
}

.brand-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 4px;
}

.brand-icon { width: 34px; height: 34px; }

.brand-name {
  font-size: 22px; font-weight: 700; letter-spacing: -0.5px;
  color: #fff;
}

.brand-tagline {
  font-size: 11px; font-weight: 500; color: #93c5fd;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-top: -10px;
}

.brand-modules {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 24px; width: 100%;
}

.module-chip {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.80);
  transition: background 0.15s, border-color 0.15s;
}
.module-chip:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.12);
}

.module-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.module-dot.erp   { background: #60a5fa; box-shadow: 0 0 6px rgba(96,165,250,0.5); }
.module-dot.wms   { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.module-dot.plm   { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,0.5); }
.module-dot.scope { background: #a78bfa; box-shadow: 0 0 6px rgba(167,139,250,0.5); }

/* ── Login card (right pane) ───────────────────────────────────────── */
.login-card {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 60px 40px;
  background: #ffffff;
}

#step-login, #step-mfa {
  width: 100%; max-width: 400px;
}

.mobile-logo {
  display: none;
  align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.brand-icon.sm { width: 28px; height: 28px; }
.brand-name.sm { font-size: 22px; font-weight: 700; color: var(--text); }

/* ── Headings ──────────────────────────────────────────────────────── */
.card-heading {
  font-size: 26px; font-weight: 700; letter-spacing: -0.5px;
  color: var(--text); line-height: 1.2; margin-bottom: 6px;
}

.card-sub {
  font-size: 14px; color: var(--text-sub); margin-bottom: 32px;
}

/* ── Form fields ───────────────────────────────────────────────────── */
.field-group {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 18px;
}

label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 500; color: #374151;
}

.forgot-link {
  font-size: 12px; font-weight: 400; color: var(--accent);
  text-decoration: none; transition: color var(--transition);
}
.forgot-link:hover { color: var(--accent-h); text-decoration: underline; }

.input-wrap { position: relative; }

input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input[type="password"] { padding-right: 44px; }

input::placeholder { color: var(--text-muted); }

input:focus {
  border-color: var(--border-f);
  background: var(--bg-input-f);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input:invalid:not(:placeholder-shown):not(:focus) {
  border-color: rgba(220,38,38,0.4);
}

/* ── Company dropdown ──────────────────────────────────────────────── */
.select-wrap { position: relative; }

.select-wrap select {
  width: 100%; padding: 12px 36px 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 14px;
  outline: none; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.select-wrap select:focus {
  border-color: var(--border-f);
  background: var(--bg-input-f);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-wrap select option {
  background: #ffffff;
  color: var(--text);
}

.select-chevron {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; pointer-events: none;
  color: var(--text-sub);
}

/* ── Password eye toggle ───────────────────────────────────────────── */
.eye-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--text-sub); display: flex; align-items: center;
  transition: color var(--transition);
}
.eye-btn:hover { color: var(--text); }
.eye-btn svg { width: 18px; height: 18px; }

/* ── MFA code input ────────────────────────────────────────────────── */
#mfa-code {
  font-size: 24px; font-weight: 600; letter-spacing: 8px;
  text-align: center;
  padding: 14px;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%; padding: 13px;
  margin-top: 8px;
  background: linear-gradient(135deg, #1677ff 0%, #2563eb 100%);
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-family: inherit; font-size: 14px; font-weight: 600;
  letter-spacing: 0.15px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(22,119,255,0.25);
  transition: box-shadow var(--transition), transform var(--transition), opacity var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 22px rgba(22,119,255,0.38);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Back button ───────────────────────────────────────────────────── */
.back-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-sub); font-size: 13px; font-weight: 500;
  padding: 0; margin-bottom: 24px;
  transition: color var(--transition);
}
.back-btn:hover { color: var(--text); }

/* ── Error box ─────────────────────────────────────────────────────── */
.error-box {
  background: var(--error-bg);
  border: 1px solid rgba(220,38,38,0.20);
  border-radius: var(--radius-sm);
  color: #dc2626; font-size: 13px; padding: 11px 14px;
  margin-bottom: 14px; line-height: 1.4;
}

/* ── Loading spinner ───────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive: hide brand panel on small screens ─────────────────── */
@media (max-width: 768px) {
  .brand-panel { display: none; }
  .mobile-logo { display: flex; }
  .login-card { padding: 40px 24px; }
  .card-heading { font-size: 22px; }
}
