:root {
  --ink: var(--hmis-ink, #0b1f3a);
  --ink-soft: var(--hmis-ink-soft, #14345c);
  --teal: var(--hmis-teal, #1f5daa);
  --teal-deep: var(--hmis-teal-deep, #174a8a);
  --mint: var(--hmis-mint, #4a8fd4);
  --paper: var(--hmis-paper, #f3f6fa);
  --paper-elevated: var(--hmis-paper-elevated, #ffffff);
  --line: var(--hmis-line, rgba(11, 31, 58, 0.12));
  --muted: var(--hmis-muted, #5b6f86);
  --danger: var(--hmis-danger, #b42318);
  --shadow: 0 18px 40px rgba(11, 31, 58, 0.16);
  --vh: 100vh;
  --vh: 100dvh;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: var(--vh);
  overflow: hidden;
}

body.login-body {
  font-family: 'Source Sans 3', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--ink);
  overflow: hidden;
}

.login-shell {
  width: 100%;
  height: var(--vh);
  max-height: var(--vh);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  overflow: hidden;
}

.login-visual {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: clamp(0.7rem, 1.6vh, 1.6rem) clamp(0.9rem, 2vw, 2rem);
  color: #fff;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.28), transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(var(--hmis-primary-rgb, 31, 93, 170), 0.35), transparent 50%),
    linear-gradient(160deg, var(--hmis-ink, #0b1f3a) 0%, var(--hmis-ink-soft, #14345c) 48%, var(--hmis-teal-deep, #174a8a) 100%);
}

.login-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  pointer-events: none;
}

.login-visual-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.45rem, 1.2vh, 1rem);
  overflow: hidden;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(0.75rem, 1.6vh, 1.1rem);
  flex-shrink: 0;
  width: 100%;
  max-width: min(34rem, 100%);
  margin: 0 auto;
  padding: clamp(0.15rem, 0.6vh, 0.4rem) 0;
  animation: rise-in 0.55s ease both;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: min(20rem, 100%);
  padding: 0.35rem 0.4rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: clamp(96px, 14vh, 140px);
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
}

.brand-copy {
  width: 100%;
  max-width: 36rem;
  text-align: center;
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-family: 'Outfit', 'Source Sans 3', sans-serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: -0.02em;
  line-height: 1.08;
  text-align: center;
  color: #ffffff;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}

.brand-copy p {
  margin: 0.35rem auto 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(0.84rem, 1.55vh, 1rem);
  max-width: 42ch;
  line-height: 1.35;
  text-align: center;
  font-weight: 600;
}

.ecg-band {
  position: relative;
  height: clamp(40px, 6.5vh, 58px);
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(11, 31, 58, 0.75), rgba(11, 31, 58, 0.35));
  border: 1px solid rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.28);
  overflow: hidden;
  color: var(--mint);
  animation: rise-in 0.6s ease 0.05s both;
}

.ecg-band svg {
  width: 200%;
  height: 100%;
  display: block;
  animation: ecg-scroll 4.5s linear infinite;
}

.ecg-band .ecg-label {
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mint);
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
}

.theme-map {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(0.35rem, 1vh, 0.7rem);
  overflow: hidden;
  animation: rise-in 0.6s ease 0.12s both;
}

.theme-map-kicker {
  margin: 0;
  text-align: center;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(0.66rem, 1.2vh, 0.76rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.92);
  font-weight: 600;
  flex-shrink: 0;
}

.theme-row {
  display: grid;
  align-items: stretch;
  min-height: 0;
  gap: clamp(0.3rem, 0.8vw, 0.55rem);
}

.theme-row-primary {
  grid-template-columns: minmax(0, 1.15fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  flex: 1.15 1 auto;
}

.theme-row-branch {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  flex: 1 1 auto;
}

.theme-row-end {
  grid-template-columns: minmax(0, 1fr);
  flex: 0.85 1 auto;
}

.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.28rem;
  min-height: 0;
  padding: clamp(0.45rem, 1.2vh, 0.8rem) clamp(0.4rem, 1vw, 0.7rem);
  border-radius: clamp(12px, 1.5vh, 16px);
  background: linear-gradient(165deg, rgba(var(--hmis-primary-rgb, 31, 93, 170), 0.45), rgba(11, 31, 58, 0.9));
  border: 1px solid rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.28);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.theme-card-start {
  border-color: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.45);
  background: linear-gradient(165deg, rgba(var(--hmis-primary-rgb, 31, 93, 170), 0.55), rgba(11, 31, 58, 0.92));
}

.theme-card-end {
  flex-direction: row;
  justify-content: center;
  gap: clamp(0.7rem, 1.5vw, 1.1rem);
  text-align: left;
  padding: clamp(0.55rem, 1.4vh, 0.9rem) clamp(0.8rem, 2vw, 1.3rem);
  border-color: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.5);
  background: linear-gradient(120deg, rgba(var(--hmis-primary-rgb, 31, 93, 170), 0.55), rgba(11, 31, 58, 0.95));
}

.theme-end-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.theme-card img {
  width: clamp(40px, 6.8vh, 64px);
  height: clamp(40px, 6.8vh, 64px);
  border-radius: 14px;
  display: block;
  flex-shrink: 0;
}

.theme-card-end img {
  width: clamp(44px, 7vh, 68px);
  height: clamp(44px, 7vh, 68px);
}

.theme-card strong {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(0.72rem, 1.45vh, 0.92rem);
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.theme-card em {
  font-style: normal;
  font-size: clamp(0.62rem, 1.15vh, 0.74rem);
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.25;
}

.theme-step {
  position: absolute;
  top: 7px;
  left: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--hmis-mint-soft, #9bc4eb);
  background: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.16);
  border: 1px solid rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.35);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
}

.theme-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.15rem;
}

.theme-tags span {
  font-family: 'Outfit', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--hmis-mint-soft, #9bc4eb);
  border-radius: 999px;
  padding: 0.14rem 0.45rem;
}

.theme-connector {
  width: clamp(18px, 2.2vw, 28px);
  align-self: center;
  height: 2px;
  background: linear-gradient(90deg, rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.2), var(--mint), rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.2));
  position: relative;
  border-radius: 2px;
}

.theme-connector::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--mint);
  border-top: 2px solid var(--mint);
  transform: translateY(-50%) rotate(45deg);
}

.theme-fork {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.theme-fork-line {
  height: 1px;
  width: min(18%, 90px);
  background: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.35);
}

.theme-fork-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.8);
  font-weight: 600;
}

.theme-or {
  display: grid;
  place-items: center;
  align-self: center;
}

.theme-or span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: 'Outfit', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hmis-mint-soft, #9bc4eb);
  border: 1px solid rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.45);
  background: rgba(11, 31, 58, 0.65);
}

.theme-merge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: clamp(14px, 2.2vh, 22px);
  flex-shrink: 0;
}

.theme-merge-arms {
  width: min(58%, 280px);
  height: 10px;
  border: 1.5px solid rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.4);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}

.theme-merge-stem {
  width: 1.5px;
  flex: 1;
  background: rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.45);
}

.visual-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.8rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: clamp(0.72rem, 1.3vh, 0.84rem);
  flex-shrink: 0;
  text-align: center;
  animation: rise-in 0.6s ease 0.3s both;
}

.visual-footer strong {
  color: #fff;
  font-weight: 600;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: clamp(0.75rem, 2vh, 1.75rem) clamp(0.85rem, 2.5vw, 2rem);
  background: linear-gradient(180deg, #eef5f6 0%, #f7fbfc 40%, #e8f1f3 100%);
  position: relative;
  overflow: hidden;
}

.login-panel::before {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--hmis-mint-rgb, 74, 143, 212), 0.18), transparent 70%);
  top: -50px;
  right: -30px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: min(420px, 100%);
  max-height: 100%;
  background: var(--paper-elevated);
  border: 1px solid rgba(4, 36, 51, 0.08);
  border-radius: clamp(14px, 2vh, 22px);
  padding: clamp(1rem, 2.4vh, 1.85rem) clamp(1rem, 2vw, 1.85rem);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  overflow: hidden;
  animation: panel-in 0.55s ease 0.1s both;
}

.login-card-brand {
  display: none;
  align-items: center;
  justify-content: center;
  margin: 0 auto clamp(0.85rem, 1.8vh, 1.15rem);
  padding: 0.3rem 0.35rem;
  max-width: min(14rem, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(4, 36, 51, 0.08);
  box-shadow: 0 8px 18px rgba(4, 36, 51, 0.08);
}

.login-card-brand img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 88px;
  object-fit: contain;
}

.login-card-kicker {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(0.65rem, 1.2vh, 0.74rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.login-card h2 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.25rem, 2.4vh, 1.75rem);
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-card .lead {
  margin: 0.35rem 0 clamp(0.75rem, 1.8vh, 1.2rem);
  color: var(--muted);
  font-size: clamp(0.82rem, 1.6vh, 0.95rem);
  line-height: 1.4;
}

.alert-login {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: var(--danger);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.86rem;
}

.field {
  margin-bottom: clamp(0.55rem, 1.4vh, 0.9rem);
}

.field label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: clamp(0.8rem, 1.4vh, 0.9rem);
  color: var(--ink-soft);
}

.field input[type='text'],
.field input[type='password'] {
  width: 100%;
  height: clamp(42px, 5.5vh, 48px);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 0.9rem;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 122, 134, 0.15);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 3rem;
}

.toggle-pass {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.toggle-pass:hover {
  background: rgba(13, 122, 134, 0.08);
  color: var(--teal-deep);
}

.visitor-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0 clamp(0.7rem, 1.6vh, 1.1rem);
  color: var(--muted);
  font-size: clamp(0.82rem, 1.5vh, 0.92rem);
}

.visitor-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  flex-shrink: 0;
}

.btn-signin {
  width: 100%;
  height: clamp(44px, 5.8vh, 50px);
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(8, 96, 106, 0.26);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-signin:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(8, 96, 106, 0.32);
}

.btn-signin:active {
  transform: translateY(0);
}

.login-meta {
  margin-top: clamp(0.7rem, 1.6vh, 1.1rem);
  text-align: center;
  color: var(--muted);
  font-size: clamp(0.72rem, 1.3vh, 0.82rem);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ecg-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Large / ultrawide desktops */
@media (min-width: 1600px) {
  .login-shell {
    grid-template-columns: minmax(0, 1.35fr) minmax(380px, 0.65fr);
  }

  .login-card {
    max-width: 460px;
  }
}

/* Tablet / narrow desktop */
@media (max-width: 1100px) and (min-width: 821px) {
  .login-shell {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.95fr);
  }

  .theme-card em,
  .visual-footer {
    display: none;
  }

  .brand-logo-wrap {
    max-width: min(17rem, 100%);
    padding: 0.3rem 0.35rem;
  }

  .brand-logo {
    max-height: clamp(88px, 12vh, 120px);
  }

  .theme-card img {
    width: clamp(36px, 5.8vh, 52px);
    height: clamp(36px, 5.8vh, 52px);
  }
}

/* Mobile & small tablets */
@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.48fr) minmax(0, 0.52fr);
  }

  .login-visual {
    padding: 0.5rem 0.65rem 0.35rem;
  }

  .brand-logo-wrap {
    max-width: min(14rem, 92%);
    padding: 0.25rem 0.3rem;
  }

  .brand-logo {
    max-height: clamp(72px, 10vh, 96px);
  }

  .login-card-brand {
    display: flex;
  }

  .brand-copy h1 {
    font-size: clamp(1.2rem, 4.5vw, 1.5rem);
    font-weight: 700;
  }

  .brand-copy p {
    font-size: 0.74rem;
    max-width: 34ch;
    font-weight: 600;
  }

  .ecg-band {
    height: 30px;
  }

  .ecg-band .ecg-label {
    font-size: 0.55rem;
    top: 4px;
  }

  .theme-map-kicker,
  .theme-fork,
  .theme-merge,
  .theme-card em,
  .theme-step,
  .visual-footer {
    display: none;
  }

  .theme-map {
    gap: 0.3rem;
  }

  .theme-row-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .theme-row-primary .theme-connector {
    display: none;
  }

  .theme-row-branch {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .theme-or span {
    width: 28px;
    height: 28px;
    font-size: 0.58rem;
  }

  .theme-card {
    padding: 0.3rem 0.25rem;
    gap: 0.15rem;
  }

  .theme-card img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .theme-card strong {
    font-size: 0.56rem;
  }

  .theme-tags span {
    font-size: 0.52rem;
    padding: 0.08rem 0.32rem;
  }

  .theme-card-end {
    padding: 0.4rem 0.55rem;
    gap: 0.45rem;
  }

  .theme-card-end .theme-end-copy em {
    display: none;
  }

  .login-panel {
    padding: 0.5rem 0.7rem 0.7rem;
    align-items: stretch;
  }

  .login-card {
    max-width: 100%;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 10px 24px rgba(4, 36, 51, 0.12);
  }

  .login-card .lead {
    display: none;
  }
}

/* Short viewports */
@media (max-height: 720px) {
  .visual-footer,
  .login-card .lead,
  .theme-map-kicker,
  .theme-card em,
  .theme-fork-label {
    display: none;
  }

  .brand-logo-wrap {
    max-width: min(14rem, 100%);
    padding: 0.25rem 0.3rem;
  }

  .brand-logo {
    max-height: clamp(68px, 10vh, 90px);
  }

  .brand-copy p {
    font-size: 0.76rem;
    font-weight: 600;
  }

  .ecg-band {
    height: 30px;
  }

  .theme-card img {
    width: clamp(34px, 5.5vh, 48px);
    height: clamp(34px, 5.5vh, 48px);
  }

  .theme-merge {
    height: 12px;
  }
}

@media (max-width: 820px) and (max-height: 700px) {
  .login-shell {
    grid-template-rows: minmax(0, 0.34fr) minmax(0, 0.66fr);
  }

  .ecg-band,
  .brand-copy p,
  .theme-tags {
    display: none;
  }

  .theme-card strong {
    font-size: 0.5rem;
  }
}

@media (max-width: 480px) {
  .login-shell {
    grid-template-rows: minmax(0, 0.42fr) minmax(0, 0.58fr);
  }

  .theme-row-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
