/* ============================================================
   MailMx — Login (modern split screen) — PREVIEW
   Loaded only via ?preview=modern while we validate it.
   Accent driven by --blue-60/70/80 (per-tenant override).
   ============================================================ */

:root {
  --blue-60: #161e41;  /* MailMx brand navy */
  --blue-70: #111735;
  --blue-80: #0b0f26;
  --red-60:  #e5484d;
  --green-50:#1f9d57;

  --bg:        #f3f5fa;
  --card:      #ffffff;
  --layer-01:  #f1f4f9;
  --field:     #fbfcfe;
  --border-subtle: #e4e8f0;
  --field-line: #cbd3e0;
  --text-primary:   #141a28;
  --text-secondary: #5a6678;
  --text-placeholder:#9aa6b8;
  --text-on-color:  #ffffff;

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --display: 'Sora', var(--sans);
}
html[data-theme="dark"] {
  --bg:        #0b0f1a;
  --card:      #121828;
  --layer-01:  rgba(255,255,255,.04);
  --field:     rgba(255,255,255,.04);
  --border-subtle: rgba(255,255,255,.1);
  --field-line: rgba(255,255,255,.15);
  --text-primary:   #eaeef8;
  --text-secondary: #9aa5bb;
  --text-placeholder:#6b7689;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  min-height: 100vh;
}

.brand-scenery, .mobile-decor-grid, .mobile-tagline, .brand-footer { display: none !important; }

.brand-panel {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: 52px 56px;
  display: flex;
  flex-direction: column;
  background: #0a0f1c;
  background:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='520' height='760' viewBox='0 0 520 760'><g fill='none' stroke='white' stroke-opacity='0.06' stroke-width='1.4'><circle cx='15' cy='745' r='120'/><circle cx='15' cy='745' r='215'/><circle cx='15' cy='745' r='310'/><circle cx='15' cy='745' r='410'/><circle cx='15' cy='745' r='515'/></g><g fill='none' stroke='white' stroke-opacity='0.05' stroke-width='1.4'><circle cx='505' cy='30' r='95'/><circle cx='505' cy='30' r='180'/><circle cx='505' cy='30' r='270'/></g></svg>") center / cover no-repeat,
    linear-gradient(150deg, var(--blue-60) 0%, color-mix(in srgb, var(--blue-60) 62%, #0a0f1c) 55%, #0a0f1c 100%);
}
.brand-panel::before, .brand-panel::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; mix-blend-mode: screen; pointer-events: none; animation: drift 24s ease-in-out infinite;
}
.brand-panel::before { width: 40vw; height: 40vw; left: -8%; top: -10%; background: radial-gradient(circle, color-mix(in srgb, var(--blue-60) 50%, #ffffff), transparent 60%); }
.brand-panel::after  { width: 34vw; height: 34vw; right: -10%; bottom: -8%; background: radial-gradient(circle, color-mix(in srgb, var(--blue-60) 70%, #000000), transparent 60%); animation-delay: -12s; }
@keyframes drift { 0%,100%{transform:translate(0,0) scale(1)} 33%{transform:translate(7%,8%) scale(1.14)} 66%{transform:translate(-6%,-5%) scale(.9)} }
.grid-overlay {
  position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .12;
  background-image: linear-gradient(rgba(255,255,255,.7) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.7) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 30% 20%, #000, transparent 72%);
  mask-image: radial-gradient(ellipse at 30% 20%, #000, transparent 72%);
}
.brand-panel > * { position: relative; z-index: 1; }
.brand-header { display: flex; align-items: center; gap: 13px; }
.brand-bars { display: grid; grid-template-rows: repeat(4, 3px); gap: 3px; width: 30px; flex-shrink: 0; }
.brand-bars span { display: block; height: 3px; background: rgba(255,255,255,.9); border-radius: 2px; }
.brand-bars span:nth-child(1){width:100%}.brand-bars span:nth-child(2){width:68%}.brand-bars span:nth-child(3){width:100%}.brand-bars span:nth-child(4){width:46%}
.logo-text { font-family: var(--display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: #fff; font-synthesis: none; }
.logo-text span { color: rgba(255,255,255,.72); font-weight: 300; }
.brand-logo-img { height: 30px; width: auto; display: block; }
.brand-content { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 460px; padding: 28px 0; }
.brand-tagline { font-family: var(--sans); font-size: clamp(32px, 3.6vw, 46px); line-height: 1.18; font-weight: 300; letter-spacing: -.015em; margin: 0 0 16px; }
.brand-tagline strong { font-weight: 600; }
.brand-description { font-size: 15px; line-height: 1.6; color: rgba(255,255,255,.82); margin: 0 0 30px; max-width: 42ch; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 420px; }
.feature-card { display: flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 500; }
.feature-icon { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); }
.feature-icon svg { width: 17px; height: 17px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.feature-text { line-height: 1.25; }
.brand-footer { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12.5px; color: rgba(255,255,255,.82); }
.status-badge { display: inline-flex; align-items: center; gap: 7px; }
.status-dot, .status-svc-dot { width: 7px; height: 7px; border-radius: 50%; background: #49e08a; box-shadow: 0 0 0 3px rgba(73,224,138,.25); }
.status-dot.down, .status-svc-dot.down { background: #ff6b6b; box-shadow: 0 0 0 3px rgba(255,107,107,.25); }
.status-svc-dot.up { background: #49e08a; }
.separator-dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.5); }
.brand-footer svg { stroke: currentColor; }

.login-panel { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 6vw, 84px); background: var(--bg); background: radial-gradient(130% 100% at 100% 0%, color-mix(in srgb, var(--blue-60) 8%, var(--bg)), var(--bg) 58%); }
.mobile-login-logo { display: none; font-family: var(--display); font-size: 19px; font-weight: 700; color: var(--text-primary); margin-bottom: 20px; }
.mobile-login-logo span { color: var(--text-secondary); font-weight: 300; }
.login-header { max-width: 400px; margin: 0 auto 26px; width: 100%; }
.login-header h1 { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 7px; }
.login-header p { font-size: 14.5px; color: var(--text-secondary); margin: 0; }
#loginForm, .account-picker { max-width: 400px; margin: 0 auto; width: 100%; }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--text-secondary); margin-bottom: 7px; }
.form-input-wrapper { position: relative; }
.form-input { width: 100%; height: 52px; background: var(--field); border: 1.5px solid var(--field-line); border-radius: 13px; color: var(--text-primary); font-family: inherit; font-size: 15px; padding: 0 16px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.form-input::placeholder { color: var(--text-placeholder); }
.form-input:focus { border-color: var(--blue-60); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-60) 15%, transparent); }
.form-input.error { border-color: var(--red-60); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red-60) 14%, transparent); }
.form-input-wrapper .form-input { padding-right: 50px; }
.toggle-password { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); height: 40px; width: 40px; border-radius: 50%; background: none; border: none; cursor: pointer; color: var(--text-secondary); display: grid; place-items: center; }
.toggle-password:hover { color: var(--text-primary); background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.toggle-password svg { width: 17px; height: 17px; }
.form-error { display: none; align-items: center; gap: 6px; color: var(--red-60); font-size: 12px; margin-top: 7px; }
.form-error.visible { display: flex; }
.form-error svg { width: 14px; height: 14px; flex-shrink: 0; }
.caps-hint { display: none; align-items: center; gap: 6px; color: #d9a406; font-size: 12px; margin-top: 7px; }
.caps-hint.visible { display: flex; }
.caps-hint svg { width: 13px; height: 13px; flex-shrink: 0; }
.form-options { margin-bottom: 22px; }
.checkbox-wrapper { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-wrapper input { width: 18px; height: 18px; accent-color: var(--blue-60); }
.checkbox-label { font-size: 14px; color: var(--text-secondary); }

.btn-primary {
  position: relative; overflow: hidden; width: 100%; height: 52px;
  background: var(--blue-60);
  background: linear-gradient(135deg, var(--blue-60), var(--blue-80));
  color: var(--text-on-color); border: none; border-radius: 13px; cursor: pointer;
  font-family: var(--display); font-size: 15.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 14px 30px -12px color-mix(in srgb, var(--blue-60) 80%, transparent);
  transition: transform .14s, filter .14s;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn-primary:active { transform: none; }
.btn-primary:disabled { cursor: default; opacity: .9; }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 32%, rgba(255,255,255,.4) 50%, transparent 68%); transform: translateX(-120%); transition: transform .6s; }
.btn-primary:hover::after { transform: translateX(120%); }
.btn-primary .btn-icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary .spinner, .btn-primary .btn-check, .btn-primary .btn-x { display: none; width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary.loading .btn-icon { display: none; }
.btn-primary.loading .spinner { display: inline-block; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: btnspin .6s linear infinite; }
.btn-primary.success { background: var(--green-50); }
.btn-primary.success::after { display: none; }
.btn-primary.success .btn-icon, .btn-primary.success .spinner { display: none; }
.btn-primary.success .btn-check { display: inline-block; }
.btn-primary.error { background: var(--red-60); }
.btn-primary.error::after { display: none; }
.btn-primary.error .btn-icon, .btn-primary.error .spinner { display: none; }
.btn-primary.error .btn-x { display: inline-block; }
@keyframes btnspin { to { transform: rotate(360deg); } }

.error-banner, .logout-banner, .session-banner { display: flex; align-items: flex-start; gap: 10px; border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.4; margin: 0 auto 20px; max-width: 400px; width: 100%; color: var(--text-primary); }
.error-banner { display: none; border: 1px solid color-mix(in srgb, var(--red-60) 55%, transparent); background: color-mix(in srgb, var(--red-60) 16%, var(--card)); }
.error-banner.visible { display: flex; }
.error-banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; stroke: var(--red-60); fill: none; }
.session-banner { border: 1px solid color-mix(in srgb, var(--blue-60) 50%, transparent); background: color-mix(in srgb, var(--blue-60) 15%, var(--card)); }
.logout-banner { border: 1px solid color-mix(in srgb, var(--green-50) 55%, transparent); background: color-mix(in srgb, var(--green-50) 15%, var(--card)); }
.logout-banner svg, .session-banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 2; }
.logout-banner svg { stroke: var(--green-50); }
.session-banner svg { stroke: var(--blue-60); }
.security-note { display: flex; align-items: flex-start; gap: 8px; max-width: 400px; margin: 30px auto 0; width: 100%; padding-top: 18px; border-top: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.security-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; stroke: var(--text-secondary); fill: none; stroke-width: 2; }
.back-to-picker { max-width: 400px; margin: 18px auto 0; width: 100%; }
.back-to-picker a { color: var(--blue-60); text-decoration: none; font-size: 14px; font-weight: 500; }
.back-to-picker a:hover { text-decoration: underline; }
.account-picker-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border-subtle); border-radius: 13px; margin-bottom: 10px; text-decoration: none; color: var(--text-primary); transition: border-color .12s, transform .12s, box-shadow .12s; }
.account-picker-item:hover { border-color: var(--blue-60); transform: translateY(-1px); box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--blue-60) 70%, transparent); }
.account-picker-avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; background: var(--blue-60); background: linear-gradient(135deg, var(--blue-60), var(--blue-80)); color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 600; }
.account-picker-info { flex: 1; min-width: 0; }
.account-picker-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-picker-email { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-picker-item svg { width: 16px; height: 16px; flex-shrink: 0; stroke: var(--text-secondary); fill: none; }
.account-picker-add { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 13px 16px; color: var(--blue-60); text-decoration: none; font-size: 14px; font-weight: 500; border: 1px dashed var(--border-subtle); border-radius: 13px; }
.account-picker-add:hover { background: var(--layer-01); }
.account-picker-add svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.theme-btn { position: absolute; top: 22px; right: 22px; width: 40px; height: 40px; border: 1px solid var(--border-subtle); border-radius: 11px; background: var(--card); color: var(--text-secondary); cursor: pointer; display: grid; place-items: center; z-index: 5; }
.theme-btn:hover { background: var(--layer-01); color: var(--text-primary); }
.theme-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: none; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text-primary); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left: 3px solid var(--red-60); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .login-panel { padding: 56px 24px 48px; justify-content: flex-start; }
  .mobile-login-logo { display: block; max-width: 400px; margin-left: auto; margin-right: auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .brand-panel::before, .brand-panel::after { animation: none; } .btn-primary::after { display: none; } }
