/* Sorbet Analytics : Login.
   Ported 1:1 from the CSI Workspace v2 "Editorial Calm" system
   (csi/dashboard/client/src/v2/styles.css, the deployed csi.sorbetagency.com
   source). Self-contained: no Tailwind, scoped under .v2-root so it can drop
   into the Flask SSR app without touching the legacy ui.py BASE_CSS.
   Brand book: csi/dashboard/csi-dashboard-brandbook.md (latest, v2). */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&family=IBM+Plex+Mono:wght@300;400;500;600&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

.v2-root {
  /* — Tokens (mirror of the v2 brand book section 2) — */
  --ink:           #101D42;
  --ink-2:         #4D4738;
  --ink-3:         #6F6757;
  --bg:            #F6F2EC;
  --paper:         #FBF8F2;
  --rule:          #E2DCD0;
  --rule-strong:   #C9C0AE;
  --surface:       #FFFFFF;

  --pink:          #C4306B;
  --pink-hover:    #A82659;
  --pink-light:    #FBEAF1;
  --teal:          #0B7FA2;
  --success:       #1E8E5A;
  --warn:          #D9913A;
  --warn-light:    #FBEFE0;
  --danger:        #C0392B;
  --danger-light:  #F8E5E2;

  --f-sans: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --tnum: "tnum" 1, "zero" 1;

  font-family: var(--f-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.v2-root *, .v2-root *::before, .v2-root *::after { box-sizing: border-box; }
.v2-root button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; padding: 0; }
.v2-root a { color: inherit; text-decoration: none; }
.v2-mono { font-family: var(--f-mono); font-feature-settings: var(--tnum); }

/* Step show/hide: [hidden] must beat the flex display set below. */
.v2-login-page [hidden] { display: none !important; }

/* ============================================================
   Login : two-column editorial split
   ============================================================ */
.v2-login-page {
  /* Login surface uses the airier secondary inks per the design. */
  --ink-2: #7F7869;
  --ink-3: #B5AC9C;

  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--bg);
  color: var(--ink);
}

/* Left · editorial pane */
.v2-login-left {
  position: relative;
  background: var(--bg);
  padding: 40px 56px 48px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
}
.v2-login-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.v2-login-brand-logo {
  height: 26px;
  width: auto;
  display: block;
}
/* Analytics product tag beside the wordmark */
.v2-login-brand-tag {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-left: 11px;
  border-left: 1px solid var(--rule);
}
.v2-login-editorial {
  margin-top: auto;
  margin-bottom: auto;
}
.v2-login-headline {
  font-family: var(--f-sans);
  font-size: 64px;
  font-weight: 500;
  line-height: 1.0;
  letter-spacing: -0.028em;
  max-width: 560px;
  margin: 0;
  color: var(--ink);
}
.v2-login-headline em {
  font-style: italic;
  font-weight: 400;
  color: var(--pink);
}
.v2-login-foot {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Right · sign in pane */
.v2-login-right {
  background: var(--paper);
  padding: 40px 56px 48px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.v2-login-right-top {
  display: flex;
  align-items: center;
  gap: 14px;
}
.v2-login-right-top-spacer { flex: 1; }
.v2-login-help {
  font-size: 12.5px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .12s ease;
}
.v2-login-help:hover { color: var(--ink); }
.v2-login-help-arrow { color: var(--ink-3); }

.v2-login-shell {
  margin: auto 0;
  width: 100%;
  max-width: 420px;
  align-self: center;
}
.v2-login-eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.v2-login-title {
  font-family: var(--f-sans);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 14px 0 0;
  color: var(--ink);
}
.v2-login-page .v2-login-title em,
.v2-login-title em {
  font-style: italic;
  font-weight: 400;
  color: var(--pink);
}
.v2-login-sub {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* SSO buttons */
.v2-login-sso-stack {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
button.v2-login-sso-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 8px;
  font-family: var(--f-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s ease, transform .12s ease, background .12s ease;
}
button.v2-login-sso-btn:hover { border-color: var(--rule-strong); }
button.v2-login-sso-btn:active { transform: translateY(1px); }
button.v2-login-sso-btn:disabled { cursor: not-allowed; opacity: 0.6; }
.v2-login-sso-icon {
  width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.v2-login-sso-label { flex: 1; }
.v2-login-sso-arrow {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  transition: transform .15s ease, color .15s ease;
}
button.v2-login-sso-btn:hover .v2-login-sso-arrow {
  color: var(--ink-2);
  transform: translateX(2px);
}
.v2-login-sso-notice {
  margin-top: 10px;
  font-family: var(--f-sans);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
}

/* Divider */
.v2-login-or {
  margin: 24px 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.v2-login-or::before,
.v2-login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* Form */
.v2-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.v2-login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.v2-login-field-label {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.v2-login-forgot {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--f-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--pink);
  transition: color .12s ease;
  cursor: pointer;
}
.v2-login-forgot:hover { color: var(--pink-hover); }

.v2-login-input-wrap { position: relative; }
input.v2-login-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 8px;
  font-family: var(--f-sans);
  font-size: 14px;
  color: var(--ink);
  font-feature-settings: var(--tnum);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input.v2-login-input::placeholder { color: var(--ink-3); }
input.v2-login-input:hover { border-color: var(--rule-strong); }
input.v2-login-input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(16, 29, 66, 0.08);
}
input.v2-login-input:disabled {
  background: var(--paper);
  color: var(--ink-3);
  cursor: not-allowed;
}
input.v2-login-input.is-error { border-color: var(--danger); }
input.v2-login-input.is-error:focus { box-shadow: 0 0 0 3px rgba(192,57,43,0.10); }
input.v2-login-otp-input {
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

button.v2-login-show-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color .12s ease, background .12s ease;
}
button.v2-login-show-toggle:hover {
  color: var(--ink);
  background: var(--bg);
}

/* Remember row */
.v2-login-remember-row {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.v2-login-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.v2-login-checkbox:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.v2-login-checkbox.is-on {
  background: var(--ink);
  border-color: var(--ink);
}
.v2-login-checkbox.is-on::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
.v2-login-remember-days { color: var(--ink); }

/* Password-strength checklist (forgot / set new password) */
.v2-login-pwrules {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.v2-login-pwrules li {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(16,29,66,0.45);
}
.v2-login-pwrules li .mark { width: 14px; display: inline-block; text-align: center; }
.v2-login-pwrules li.is-ok   { color: var(--success); }
.v2-login-pwrules li.is-bad  { color: var(--danger); }
.v2-login-pwmatch { margin-top: 8px; font-size: 12px; }
.v2-login-pwmatch.is-ok  { color: var(--success); }
.v2-login-pwmatch.is-bad { color: var(--danger); }

/* Primary CTA */
button.v2-login-primary-btn {
  margin-top: 22px;
  width: 100%;
  padding: 14px 18px;
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-family: var(--f-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
button.v2-login-primary-btn:hover:not(:disabled) { background: #1c2a55; }
button.v2-login-primary-btn:active:not(:disabled) { transform: translateY(1px); }
button.v2-login-primary-btn:disabled { cursor: not-allowed; opacity: 0.6; }
.v2-login-primary-arrow { font-family: var(--f-mono); font-size: 13px; }
.v2-login-spinner { display: inline-flex; align-items: center; gap: 8px; }
.v2-login-spinner svg { animation: v2-spin 0.9s linear infinite; }
@keyframes v2-spin { to { transform: rotate(360deg); } }

/* Error banner */
.v2-login-error-banner {
  margin-top: 14px;
  padding: 11px 13px;
  background: var(--danger-light);
  border: 1px solid rgba(192,57,43,0.18);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--danger);
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.v2-login-error-banner strong { display: block; font-weight: 600; margin-bottom: 2px; }
.v2-login-error-x {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  font-weight: 600;
}

/* Secondary text link under the form (request access / different account) */
.v2-login-altline {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: center;
}
.v2-login-altline a { color: var(--pink); font-weight: 500; }
.v2-login-altline a:hover { color: var(--pink-hover); }

/* Responsive */
@media (max-width: 960px) {
  .v2-login-page { grid-template-columns: 1fr; }
  .v2-login-left {
    padding: 32px 28px 24px;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .v2-login-right { padding: 36px 28px 32px; }
  .v2-login-editorial { margin-top: 32px; margin-bottom: 32px; }
  .v2-login-headline { font-size: 40px; }
  .v2-login-pwrules { grid-template-columns: 1fr; }
}
