:root {
  color-scheme: light;
  --auth-ink: #111827;
  --auth-muted: #64748b;
  --auth-line: #d8dee8;
  --auth-field: #f8fafc;
  --auth-primary: #2563eb;
  --auth-primary-dark: #1d4ed8;
  --auth-danger: #c4322b;
  --auth-danger-bg: #fff5f4;
  --auth-focus: 0 0 0 4px rgba(37, 99, 235, .12);
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  color: var(--auth-ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 13.5px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .35), rgba(241, 245, 249, .52)),
    url("../background.webp") center / cover no-repeat fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input { font: inherit; }

.login-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 26px 18px;
}

.login-panel {
  width: min(410px, 100%);
  padding: 32px 34px;
  border: 1px solid rgba(216, 222, 232, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 20px 48px rgba(15, 23, 42, .13);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  color: #0f172a;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.015em;
  text-align: center;
}

.brand-mark {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .08);
}

.brand-mark img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.login-heading {
  margin: 0 0 22px;
  text-align: center;
}

.login-heading h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.form-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #f1c2be;
  border-radius: 10px;
  color: var(--auth-danger);
  background: var(--auth-danger-bg);
  font-size: 13px;
  line-height: 1.45;
}

.form-error.is-hidden { display: none; }

.auth-field { margin-bottom: 13px; }

.auth-field label {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 12.5px;
  font-weight: 700;
}

.field-wrap { position: relative; }

.field-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.field-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-field input {
  width: 100%;
  min-height: 47px;
  padding: 0 14px 0 44px;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  outline: 0;
  color: var(--auth-ink);
  background: var(--auth-field);
  font-size: 13.5px;
  font-weight: 500;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

@media (max-width: 767px) {
  .auth-field input {
    font-size: 16px;
  }
}

.auth-field input:hover { border-color: #c3cad5; }

.auth-field input:focus {
  border-color: var(--auth-primary);
  background: #fff;
  box-shadow: var(--auth-focus);
}

.auth-field input.is-invalid {
  border-color: var(--auth-danger);
  box-shadow: 0 0 0 4px rgba(196, 50, 43, .1);
}

.password-field input { padding-right: 52px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #64748b;
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background .18s ease, color .18s ease;
}

.password-toggle:hover,
.password-toggle:focus {
  color: #111827;
  background: #e5e7eb;
}

.password-toggle:focus-visible {
  outline: 0;
  box-shadow: var(--auth-focus);
}

.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle .eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

.field-error {
  min-height: 14px;
  padding-top: 4px;
  color: var(--auth-danger);
  font-size: 12px;
  line-height: 1.35;
}

.submit-button {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 2px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--auth-primary);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .2);
  font-size: 13.5px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.submit-button:hover,
.submit-button:focus {
  color: #fff;
  background: var(--auth-primary-dark);
  box-shadow: 0 16px 28px rgba(37, 99, 235, .24);
  transform: translateY(-1px);
}

.submit-button:disabled {
  cursor: wait;
  opacity: .78;
  box-shadow: none;
  transform: none;
}

.button-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}

.submit-button.is-loading .button-spinner { display: block; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

.powered-by {
  position: fixed;
  bottom: 14px;
  left: 50%;
  z-index: 2;
  margin: 0;
  padding: 5px 10px;
  color: #64748b;
  background: rgba(255, 255, 255, .68);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.powered-by a {
  color: #334155;
  font-weight: 700;
  text-decoration: none;
}

.powered-by a:hover,
.powered-by a:focus {
  color: var(--auth-primary);
  text-decoration: underline;
}

.company-shell {
  padding-bottom: 46px;
}

.company-panel {
  width: min(520px, 100%);
}

.company-heading {
  margin-bottom: 20px;
}

.company-heading p {
  margin: 7px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  font-weight: 500;
}

.company-messages {
  margin-bottom: 10px;
}

.company-message {
  margin-bottom: 10px;
}

.company-list {
  display: grid;
  gap: 9px;
  max-height: min(46vh, 370px);
  margin-bottom: 15px;
  padding-right: 2px;
  overflow: auto;
}

.company-option {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid rgba(216, 222, 232, .95);
  border-radius: 13px;
  background: rgba(248, 250, 252, .9);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.company-option:hover {
  border-color: #bfccdc;
  background: rgba(255, 255, 255, .95);
  transform: translateY(-1px);
}

.company-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.company-option:has(input:focus-visible) {
  box-shadow: var(--auth-focus);
}

.company-option:has(input:checked) {
  border-color: rgba(37, 99, 235, .58);
  background: rgba(239, 246, 255, .96);
  box-shadow: 0 12px 26px rgba(37, 99, 235, .1);
}

.company-option__mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 15px;
  font-weight: 800;
}

.company-option__body {
  min-width: 0;
}

.company-option__name {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-option__meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--auth-muted);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-option__check {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: transparent;
  background: #fff;
}

.company-option__check svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.company-option:has(input:checked) .company-option__check {
  border-color: var(--auth-primary);
  color: #fff;
  background: var(--auth-primary);
}

.company-submit {
  margin-top: 0;
}

.company-actions {
  margin-top: 16px;
  text-align: center;
}

.company-actions a {
  color: var(--auth-muted);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.company-actions a:hover,
.company-actions a:focus {
  color: var(--auth-primary);
  text-decoration: underline;
}

.empty-company-state {
  padding: 14px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  color: #9a3412;
  background: #fff7ed;
  font-size: 13px;
  text-align: center;
}

.offline-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background: var(--auth-field);
}

.offline-panel {
  width: min(100%, 390px);
  text-align: center;
}

.offline-panel h1 {
  margin: 0 0 10px;
  font-size: 30px;
  letter-spacing: -.035em;
}

.offline-panel p {
  margin: 0 0 26px;
  color: var(--auth-muted);
  line-height: 1.55;
}

.offline-status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--auth-danger);
  font-size: 13px;
}

@media (max-width: 520px) {
  body {
    background:
      linear-gradient(160deg, rgba(255, 255, 255, .38), rgba(241, 245, 249, .56)),
      url("../mobilebg.webp") center / cover no-repeat;
  }

  .login-shell { padding: 20px 14px; }

  .login-panel {
    padding: 28px 22px;
    border-radius: 16px;
  }

  .company-panel {
    padding: 26px 18px;
  }

  .company-option {
    grid-template-columns: 34px minmax(0, 1fr) 22px;
    min-height: 58px;
    padding: 10px;
  }

  .company-option__mark {
    width: 34px;
    height: 34px;
  }

  .brand-mark {
    width: 60px;
    height: 60px;
    border-radius: 15px;
  }

  .login-heading h1 { font-size: 25px; }
}

@media (max-height: 700px) {
  .login-shell {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .login-panel {
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .brand-lockup,
  .login-heading {
    margin-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
