:root {
  color-scheme: dark;
  --bg: #050e06;
  --bg2: #071209;
  --panel: #08150a;
  --panel-strong: #0b180e;
  --card: rgba(0, 255, 65, 0.035);
  --card-b: rgba(0, 255, 65, 0.14);
  --g: #00ff41;
  --g2: #00cc33;
  --gdim: rgba(0, 255, 65, 0.08);
  --text: #dff5e3;
  --sub: #8ebc97;
  --muted: #6f9b77;
  --input: #071209;
  --input-b: rgba(0, 255, 65, 0.24);
  --error: #ff8585;
  --error-bg: rgba(255, 107, 107, 0.1);
  --success: #00ff41;
  --success-bg: rgba(0, 255, 65, 0.08);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4fbf5;
  --bg2: #eaf6ed;
  --panel: #ffffff;
  --panel-strong: #f7fcf8;
  --card: rgba(0, 128, 40, 0.045);
  --card-b: rgba(0, 128, 40, 0.17);
  --g: #008f2c;
  --g2: #007a25;
  --gdim: rgba(0, 143, 44, 0.1);
  --text: #08240d;
  --sub: #315c39;
  --muted: #66856c;
  --input: #ffffff;
  --input-b: rgba(0, 128, 40, 0.22);
  --error: #b91c1c;
  --error-bg: rgba(185, 28, 28, 0.07);
  --success: #007a25;
  --success-bg: rgba(0, 122, 37, 0.08);
  --shadow: 0 24px 70px rgba(8, 36, 13, 0.12);
}

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

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button, a { touch-action: manipulation; }
svg { display: block; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  background: var(--g);
  color: #031003;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(520px, 1.14fr);
}

.auth-context {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  border-right: 1px solid var(--card-b);
  padding: clamp(2rem, 5vw, 4.5rem);
  background: var(--bg2);
}

.auth-context::before,
.auth-context::after {
  position: absolute;
  content: '';
  pointer-events: none;
  border-radius: 50%;
}
.auth-context::before {
  width: 420px;
  height: 420px;
  right: -220px;
  top: -190px;
  border: 1px solid var(--card-b);
  box-shadow: 0 0 0 70px rgba(0, 255, 65, 0.018), 0 0 0 140px rgba(0, 255, 65, 0.012);
}
.auth-context::after {
  width: 280px;
  height: 280px;
  left: -180px;
  bottom: -170px;
  background: var(--gdim);
  filter: blur(70px);
}

.brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: fit-content;
  min-height: 44px;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}
.brand img { width: 44px; height: 44px; filter: drop-shadow(0 0 12px rgba(0, 255, 65, 0.28)); }
.brand strong { display: block; font-family: 'Syne', sans-serif; font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }
.brand small { display: block; margin-top: 0.1rem; color: var(--muted); font-size: 0.55rem; font-weight: 600; letter-spacing: 0.28em; text-transform: uppercase; }

.context-copy { position: relative; z-index: 1; max-width: 600px; margin: 3.5rem 0; }
.context-label { display: inline-flex; align-items: center; gap: 0.55rem; margin: 0 0 1.5rem; color: var(--g2); font-size: 0.72rem; font-weight: 600; }
.context-label span { width: 7px; height: 7px; border-radius: 50%; background: var(--g); box-shadow: 0 0 10px rgba(0, 255, 65, 0.65); }
.context-copy h2 { max-width: 13ch; margin: 0 0 1.5rem; font-family: 'Syne', sans-serif; font-size: clamp(2.6rem, 4.2vw, 4.6rem); font-weight: 800; line-height: 0.98; letter-spacing: -0.045em; text-wrap: balance; }
.context-copy > p:last-child { max-width: 52ch; margin: 0; color: var(--sub); font-size: 1rem; line-height: 1.75; }

.trust-list { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.trust-list li { display: grid; min-width: 0; grid-template-columns: 28px 1fr; gap: 0.65rem; border-top: 1px solid var(--card-b); padding-top: 1rem; color: var(--sub); font-size: 0.8rem; line-height: 1.5; }
.trust-list svg { width: 22px; height: 22px; color: var(--g2); }
.trust-list strong { display: block; margin-bottom: 0.2rem; color: var(--text); font-size: 0.82rem; }

.auth-main {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(3rem, 5vw, 5rem) clamp(1.5rem, 6vw, 6rem);
  background: var(--bg);
}
.auth-main::before { position: absolute; inset: 0; content: ''; pointer-events: none; opacity: 0.35; background-image: linear-gradient(var(--card-b) 1px, transparent 1px), linear-gradient(90deg, var(--card-b) 1px, transparent 1px); background-size: 64px 64px; mask-image: linear-gradient(to bottom, transparent, #000 35%, transparent); }

.theme-toggle {
  position: absolute;
  z-index: 2;
  top: max(2rem, env(safe-area-inset-top));
  right: max(2rem, env(safe-area-inset-right));
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--card-b);
  border-radius: 50%;
  background: var(--card);
  color: var(--g);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.theme-toggle:hover { border-color: var(--g2); background: var(--gdim); transform: translateY(-1px); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-sun { display: none; }
html[data-theme="light"] .theme-moon { display: none; }
html[data-theme="light"] .theme-sun { display: block; }

.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
  border: 1px solid var(--card-b);
  border-radius: 24px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  box-shadow: var(--shadow);
}
.portal-mark { display: inline-flex; align-items: center; gap: 0.55rem; margin-bottom: 1.15rem; border: 1px solid var(--card-b); border-radius: 999px; padding: 0.35rem 0.75rem; color: var(--g2); background: var(--gdim); font-size: 0.7rem; font-weight: 600; }
.portal-mark span { width: 6px; height: 6px; border-radius: 50%; background: var(--g); box-shadow: 0 0 7px var(--g); }
.login-card h1 { margin: 0; font-family: 'Syne', sans-serif; font-size: clamp(2.1rem, 5vw, 3.25rem); font-weight: 800; line-height: 1; letter-spacing: -0.04em; text-wrap: balance; }
.login-intro { margin: 0.8rem 0 1.25rem; color: var(--sub); font-size: 0.95rem; line-height: 1.6; }

.login-status { margin-bottom: 1rem; border: 1px solid var(--card-b); border-radius: 12px; padding: 0.8rem 0.9rem; color: var(--sub); background: var(--card); font-size: 0.85rem; line-height: 1.5; }
.login-status[data-state="error"] { border-color: color-mix(in srgb, var(--error) 38%, transparent); color: var(--error); background: var(--error-bg); }
.login-status[data-state="success"] { border-color: color-mix(in srgb, var(--success) 34%, transparent); color: var(--success); background: var(--success-bg); }
.login-status[data-state="loading"] { color: var(--text); }

#login-form { display: grid; gap: 0.8rem; }
.field { display: grid; gap: 0.45rem; }
.field label { color: var(--text); font-size: 0.82rem; font-weight: 600; }
.label-row { display: flex; min-height: 28px; align-items: center; justify-content: space-between; gap: 1rem; }
.text-action { min-height: 44px; margin: -8px -8px -8px 0; border: 0; padding: 8px; background: transparent; color: var(--g2); font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.text-action:hover { color: var(--g); }
.field input:not([type="checkbox"]) { width: 100%; min-height: 52px; border: 1px solid var(--input-b); border-radius: 12px; padding: 0.85rem 1rem; outline: none; background: var(--input); color: var(--text); font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s; }
.field input::placeholder { color: var(--muted); opacity: 1; }
.field input:hover { border-color: color-mix(in srgb, var(--g2) 45%, transparent); }
.field input:focus { border-color: var(--g2); box-shadow: 0 0 0 3px var(--gdim); }
.field[data-invalid="true"] input { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-bg); }
.field-error { min-height: 1.1em; margin: 0; color: var(--error); font-size: 0.75rem; line-height: 1.4; }
.password-control { position: relative; }
.password-control input { padding-right: 3.5rem !important; }
.password-toggle { position: absolute; top: 4px; right: 4px; display: inline-grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--g); background: var(--gdim); }
.password-toggle svg { width: 20px; height: 20px; }
.eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

.remember-control { display: inline-flex; width: fit-content; min-height: 44px; align-items: center; gap: 0.65rem; color: var(--sub); font-size: 0.82rem; cursor: pointer; }
.remember-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.remember-control > span { display: inline-grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--input-b); border-radius: 6px; background: var(--input); }
.remember-control > span::after { width: 9px; height: 5px; border-bottom: 2px solid #031003; border-left: 2px solid #031003; content: ''; opacity: 0; transform: rotate(-45deg) translateY(-1px); }
.remember-control input:checked + span { border-color: var(--g); background: var(--g); }
.remember-control input:checked + span::after { opacity: 1; }
.remember-control input:focus-visible + span { outline: 2px solid var(--g); outline-offset: 3px; }

.submit-button { position: relative; display: inline-flex; width: 100%; min-height: 50px; align-items: center; justify-content: center; gap: 0.65rem; border: 1px solid var(--g); border-radius: 999px; padding: 0.85rem 1.25rem; background: var(--g); color: #031003; font-size: 0.88rem; font-weight: 700; cursor: pointer; box-shadow: 0 0 22px rgba(0, 255, 65, 0.16); transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s; }
.submit-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 32px rgba(0, 255, 65, 0.26); }
.submit-button:disabled { cursor: wait; opacity: 0.66; }
.button-spinner { display: none; width: 17px; height: 17px; border: 2px solid rgba(3, 16, 3, 0.28); border-top-color: #031003; border-radius: 50%; animation: spin 0.75s linear infinite; }
.submit-button[data-loading="true"] .button-spinner { display: block; }

.access-help { display: flex; align-items: center; justify-content: center; gap: 0.4rem; margin: 1rem 0 0; color: var(--sub); font-size: 0.8rem; text-align: center; }
.access-help p { margin: 0; }
.access-help a { min-height: 44px; display: inline-flex; align-items: center; color: var(--g2); font-weight: 600; text-decoration: none; }
.access-help a:hover { color: var(--g); text-decoration: underline; text-underline-offset: 3px; }
.security-note { display: grid; grid-template-columns: 22px 1fr; gap: 0.7rem; margin-top: 0.75rem; border-top: 1px solid var(--card-b); padding-top: 0.75rem; color: var(--muted); }
.security-note svg { width: 20px; height: 20px; color: var(--g2); }
.security-note p { margin: 0; font-size: 0.75rem; line-height: 1.5; }
.back-link { display: inline-flex; min-height: 44px; align-items: center; gap: 0.35rem; margin-top: 0.5rem; color: var(--sub); font-size: 0.8rem; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--g); }
.back-link svg { width: 18px; height: 18px; }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--g); outline-offset: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1350px) {
  .context-copy { margin: 2.75rem 0; }
  .trust-list { grid-template-columns: 1fr; }
  .trust-list li { grid-template-columns: 25px 1fr; padding-top: 0.7rem; }
}

@media (max-width: 1100px) {
  .auth-shell { grid-template-columns: minmax(320px, 0.72fr) minmax(500px, 1.28fr); }
  .trust-list { grid-template-columns: 1fr; }
  .trust-list li { grid-template-columns: 25px 1fr; }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-context { min-height: auto; border-right: 0; border-bottom: 1px solid var(--card-b); padding: 1.5rem clamp(1.25rem, 6vw, 3rem) 2rem; }
  .context-copy { margin: 3rem 0 0; }
  .context-copy h2 { max-width: 14ch; font-size: clamp(2.35rem, 9vw, 4rem); }
  .context-copy > p:last-child { max-width: 64ch; }
  .trust-list { display: none; }
  .auth-main { min-height: auto; padding: 5.5rem clamp(1.25rem, 6vw, 3rem) 3rem; }
}

@media (max-width: 520px) {
  .auth-context { padding: max(1rem, env(safe-area-inset-top)) 1rem 1.5rem; }
  .brand img { width: 40px; height: 40px; }
  .context-copy { margin: 1.25rem 0 0; }
  .context-label { display: none; }
  .context-copy h2 { max-width: 16ch; margin: 0; font-size: clamp(1.8rem, 8.5vw, 2.25rem); line-height: 1.03; }
  .context-copy > p:last-child { display: none; }
  .auth-main { padding: 4.25rem 1rem max(1.5rem, env(safe-area-inset-bottom)); }
  .theme-toggle { top: 1rem; right: 1rem; }
  .login-card { border-radius: 18px; padding: 1.35rem 1rem; }
  .login-card h1 { font-size: clamp(2rem, 12vw, 2.65rem); }
  .label-row { align-items: flex-start; }
  .text-action { max-width: 155px; min-height: 44px; margin-top: -8px; text-align: right; }
  .access-help { flex-direction: column; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
