:root {
  --navy-900: #0a2a5e; --navy-800: #0f3a7d; --navy-700: #14498f;
  --blue-500: #1677ff; --blue-100: #e6f0ff; --bg-right: #eaf3ff;
  --ink: #0b1b33; --muted: #55657d; --line: #c9d6ea;
  --danger: #d93025; --ok: #1a9d5b;
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg-right); }
.page { display: grid; grid-template-columns: 35% 1fr; min-height: 100vh; }

/* ---------- Left brand panel ---------- */
.brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2.5rem;
  padding: 2.5rem 2rem 8rem 2.25rem; color: #fff;
  background: linear-gradient(170deg, var(--navy-700) 0%, var(--navy-800) 40%, var(--navy-900) 100%);
}
.brand-title { font-size: 2.4rem; font-weight: 800; line-height: 1; letter-spacing: .01em; }
.brand-school { font-size: .72rem; font-weight: 700; margin-top: .1rem; }
.brand-app { font-size: .86rem; font-weight: 600; }
.brand-rule { display: block; height: 4px; width: 100%; max-width: 330px; margin: .4rem 0 .35rem; border-radius: 2px; background: var(--blue-500); }
.brand-tag { font-size: .72rem; color: #cfe0ff; }
.brand-headline { font-size: 2rem; font-weight: 700; line-height: 1.15; max-width: 11ch; }
.brand-sub { margin-top: .8rem; font-size: .92rem; line-height: 1.5; color: #dbe7ff; max-width: 30ch; }
.features { list-style: none; margin-top: 1.75rem; display: grid; gap: .5rem; }
.features li { display: flex; align-items: center; gap: .9rem; padding: .5rem .6rem; margin: 0 -.6rem; border-radius: 12px; transition: background .2s, transform .2s; }
.features li:hover { background: rgba(255,255,255,.08); transform: translateX(4px); }
.feature-icon { flex: none; width: 3.1rem; height: 3.1rem; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.1); transition: background .2s, color .2s; }
.features li:hover .feature-icon { background: #fff; color: var(--navy-800); }
.feature-icon svg { width: 1.5rem; height: 1.5rem; }
.features h3 { font-size: .92rem; font-weight: 600; }
.features p { font-size: .76rem; color: #cfe0ff; line-height: 1.4; max-width: 26ch; }

/* Heartbeat line */
.ecg {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 150px; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.ecg use { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ecg-trace use { stroke: #7db8ff; opacity: .48; }
.ecg-run { animation: ecg 7s linear infinite; will-change: transform; }
.ecg-pulse { animation: ecg 7s linear infinite, ecg-pulse 2.6s linear infinite; }
.ecg-pulse use {
  stroke: #c4ffe8; stroke-width: 3; stroke-dasharray: 18 250;
  filter: drop-shadow(0 0 5px rgba(151, 255, 213, .95));
}
.ecg.beat { animation: glow .6s ease-out; }
@keyframes ecg { to { transform: translateX(-800px); } }
@keyframes ecg-pulse { to { stroke-dashoffset: -268; } }
@keyframes glow { 0% { filter: drop-shadow(0 0 7px #b8d9ff) brightness(1.8); } 100% { filter: none; } }

/* ---------- Right side ---------- */
.login-side {
  position: relative; overflow: hidden; display: grid; place-items: center; padding: 2rem 1.25rem;
  background:
    radial-gradient(circle at 100% 0, #d3e5ff 0 14rem, transparent 14.1rem),
    radial-gradient(circle at 100% 85%, #d9e9ff 0 11rem, transparent 11.1rem),
    var(--bg-right);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 410px; padding: 1.75rem 1.75rem 1.5rem;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; text-align: center;
  box-shadow: 0 12px 40px rgba(20, 73, 143, .12);
  transition: border-color .25s, box-shadow .25s;
}
.login-card[data-mode="admin"] { border-color: var(--blue-500); box-shadow: 0 12px 40px rgba(22, 119, 255, .2); }
.login-card.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.logo-slot { width: 84px; height: 84px; margin: 0 auto .6rem; border-radius: 50%; border: 2px dashed var(--line); background: #f5f9ff; display: grid; place-items: center; overflow: hidden; }
.logo-slot img { width: 100%; height: 100%; object-fit: contain; }
.card-title { font-size: 1.9rem; font-weight: 800; line-height: 1; color: var(--navy-900); }
.card-school { font-size: .62rem; font-weight: 700; color: var(--navy-900); }
.card-app { font-size: .78rem; font-weight: 600; color: var(--navy-900); }
.card-rule { display: block; height: 3px; width: 70%; margin: .35rem auto .3rem; border-radius: 2px; background: var(--blue-500); }
.card-tag { font-size: .62rem; color: var(--muted); }

/* Account type switch */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-top: 1.1rem; padding: 4px; background: var(--blue-100); border: 1px solid var(--line); border-radius: 10px; }
.seg-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); background: #fff; border-radius: 7px; box-shadow: 0 2px 8px rgba(20, 73, 143, .18); transition: transform .3s cubic-bezier(.3, .9, .3, 1); }
.login-card[data-mode="admin"] .seg-thumb { transform: translateX(100%); }
.seg button { position: relative; z-index: 1; border: 0; background: none; font: inherit; font-size: .78rem; font-weight: 600; color: var(--muted); padding: .55rem; border-radius: 7px; cursor: pointer; transition: color .2s; }
.seg button[aria-selected="true"] { color: var(--navy-900); }
.seg button:focus-visible { outline: 3px solid rgba(22, 119, 255, .4); }

.welcome { margin-top: 1rem; font-size: 1.5rem; font-weight: 700; }
.welcome-sub { margin: .3rem auto 1rem; font-size: .75rem; line-height: 1.45; color: var(--muted); max-width: 30ch; }

form { text-align: left; }
label { display: block; font-size: .72rem; font-weight: 600; margin-bottom: .3rem; }
.field { display: flex; align-items: center; gap: .6rem; height: 2.6rem; padding: 0 .8rem; background: var(--blue-100); border: 1px solid var(--line); border-radius: 8px; color: var(--navy-900); transition: border-color .15s, box-shadow .15s, background .15s; }
.field:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(22, 119, 255, .2); background: #fff; }
.field.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(217, 48, 37, .12); }
.field-icon { flex: none; width: 1.1rem; height: 1.1rem; }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: .78rem; color: var(--ink); }
.field input::placeholder { color: #8796ae; }
.ok-icon { display: none; flex: none; width: 1.1rem; height: 1.1rem; color: var(--ok); }
.field.valid .ok-icon { display: block; }

.toggle { border: 0; background: none; cursor: pointer; color: var(--navy-900); display: grid; place-items: center; padding: .2rem; border-radius: 4px; }
.toggle:focus-visible { outline: 2px solid var(--blue-500); }
.toggle svg { width: 1.15rem; height: 1.15rem; }
.toggle .eye-on { display: none; }
.toggle.showing .eye-on { display: block; }
.toggle.showing .eye-off { display: none; }

.error { min-height: 1rem; margin: .2rem 0 .35rem; font-size: .68rem; color: var(--danger); }
.caps { margin: -.2rem 0 .35rem; font-size: .68rem; color: #b26a00; }
.row { display: flex; align-items: center; justify-content: space-between; margin: .2rem 0 .9rem; }
.forgot { font-size: .72rem; font-weight: 600; color: var(--blue-500); text-decoration: none; }
.forgot:hover { text-decoration: underline; }

.check { position: relative; display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .72rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.check input { position: absolute; opacity: 0; }
.box { width: 1.05rem; height: 1.05rem; display: grid; place-items: center; border: 1.5px solid var(--navy-700); border-radius: 4px; transition: background .15s, border-color .15s; }
.check input:checked + .box { background: var(--blue-500); border-color: var(--blue-500); }
.check input:checked + .box::after { content: ""; width: .3rem; height: .55rem; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:focus-visible + .box { outline: 3px solid rgba(22, 119, 255, .4); outline-offset: 2px; }

.btn { width: 100%; height: 2.75rem; border-radius: 8px; cursor: pointer; font: inherit; font-size: 1rem; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: .5rem; transition: background .2s, border-color .2s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(22, 119, 255, .4); outline-offset: 2px; }
.btn-primary { background: var(--blue-500); color: #fff; border: 1px solid var(--blue-500); }
.btn-primary:hover { background: #0d63da; }
.btn-primary[disabled] { cursor: wait; }
.btn-primary.done { background: var(--ok); border-color: var(--ok); }
.spin { display: none; width: 1.1rem; height: 1.1rem; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary.loading .spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Forgot password dialog */
dialog { margin: auto; width: calc(100% - 2rem); max-width: 340px; padding: 1.5rem; border: 0; border-radius: 16px; font-family: var(--font); color: var(--ink); box-shadow: 0 20px 60px rgba(10, 42, 94, .35); }
dialog::backdrop { background: rgba(10, 42, 94, .45); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .2s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
dialog h3 { font-size: 1.1rem; margin-bottom: .4rem; }
dialog p { font-size: .8rem; line-height: 1.5; color: var(--muted); margin-bottom: 1.1rem; }

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Visual refinements ---------- */
body {
  background: #eaf3ff;
  background: linear-gradient(135deg, #f3f7ff 0%, #e8f1ff 52%, #e0ecff 100%);
}
.brand {
  isolation: isolate;
  background:
    radial-gradient(ellipse at 12% 8%, rgba(80, 153, 255, .28), transparent 34%),
    linear-gradient(155deg, #1555a1 0%, #103d7f 48%, #092755 100%);
}
.brand::before, .brand::after {
  position: absolute; z-index: -1; content: ""; border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%; pointer-events: none;
}
.brand::before { width: 24rem; height: 24rem; right: -13rem; top: 8%; }
.brand::after { width: 34rem; height: 34rem; right: -19rem; top: 0; }
.brand-title { letter-spacing: .035em; }
.brand-rule { background: linear-gradient(90deg, #6bb5ff, #2384ff); }
.feature-icon { border: 1px solid rgba(255,255,255,.12); }
.login-side {
  background:
    radial-gradient(circle at 100% 0, rgba(197, 221, 255, .82) 0 14rem, transparent 14.1rem),
    radial-gradient(circle at 100% 88%, rgba(205, 226, 255, .72) 0 11rem, transparent 11.1rem),
    linear-gradient(145deg, #f4f8ff 0%, #eaf3ff 100%);
}
.login-card {
  max-width: 420px; padding: 1.55rem 1.85rem 1.25rem; border-color: rgba(167, 189, 221, .72);
  border-radius: 20px; box-shadow: 0 24px 70px rgba(15, 58, 125, .13), 0 3px 12px rgba(15, 58, 125, .05);
}
.login-card[data-mode="admin"] {
  border-color: rgba(22, 119, 255, .65);
  box-shadow: 0 24px 70px rgba(22, 119, 255, .17), 0 3px 12px rgba(15, 58, 125, .05);
}
.logo-slot {
  width: 3.75rem; height: 3.75rem; margin-bottom: .5rem; border: 0;
  color: #1558a5; background: linear-gradient(145deg, #edf5ff, #dceaff);
  box-shadow: inset 0 0 0 1px rgba(22, 119, 255, .1), 0 5px 14px rgba(20, 73, 143, .08);
}
.logo-slot svg { width: 2.6rem; height: 2.6rem; }
.card-rule { width: 62%; height: 3px; background: linear-gradient(90deg, #66adff, var(--blue-500), #66adff); }
.seg { background: #f0f5ff; border-color: #d7e3f5; }
.seg button { min-height: 2.5rem; }
.seg button:hover { color: var(--navy-900); }
.welcome { letter-spacing: -.025em; }
.welcome-sub { max-width: 34ch; }
.field {
  height: 2.85rem; border-color: #d6e1f1; background: #f5f8fd; border-radius: 10px;
}
.field:hover:not(:focus-within) { border-color: #b7c9e2; }
.field input { font-size: .82rem; }
.toggle { padding: .35rem; }
.row { margin-top: .35rem; margin-bottom: 1rem; }
.btn-primary {
  background: linear-gradient(110deg, #1677ff 0%, #1766df 100%);
  border-color: #1766df; border-radius: 10px; box-shadow: 0 5px 14px rgba(22, 103, 223, .2);
}
.btn-primary:hover { background: linear-gradient(110deg, #0d6ce9, #1259c8); box-shadow: 0 7px 18px rgba(22, 103, 223, .25); }
.secure-note {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  margin: .85rem 0 0; color: #71819a; font-size: .64rem; line-height: 1.4;
}
.secure-note svg { flex: none; width: .95rem; height: .95rem; color: #278460; }
.field:focus-within { box-shadow: 0 0 0 3px rgba(22, 119, 255, .14); }
.forgot:focus-visible, .check:focus-within { outline: 3px solid rgba(22, 119, 255, .3); outline-offset: 3px; border-radius: 4px; }
dialog { border: 1px solid #d6e1f1; }

/* Glass surfaces keep the original navy and blue palette. */
.brand {
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .2);
}
.brand::before, .brand::after {
  background: linear-gradient(135deg, rgba(167, 211, 255, .12), rgba(255, 255, 255, .015) 65%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}
.feature-icon {
  background: linear-gradient(145deg, rgba(255, 255, 255, .21), rgba(255, 255, 255, .06));
  border-color: rgba(255, 255, 255, .25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 6px 16px rgba(3, 24, 60, .14);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.login-side {
  isolation: isolate;
  background:
    radial-gradient(ellipse at 80% 12%, rgba(119, 175, 255, .32), transparent 48%),
    radial-gradient(ellipse at 15% 78%, rgba(146, 199, 255, .28), transparent 45%),
    linear-gradient(145deg, #f4f8ff, #e4efff);
}
.login-side::before, .login-side::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, .5), rgba(126, 180, 255, .16));
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .8), 0 24px 65px rgba(57, 111, 185, .08);
}
.login-side::before { width: 28rem; height: 28rem; top: -9rem; right: -9rem; }
.login-side::after { width: 20rem; height: 20rem; bottom: -7rem; left: -6rem; }
.login-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .55));
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: 26px;
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  backdrop-filter: blur(24px) saturate(145%);
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(255, 255, 255, .55),
    0 28px 65px rgba(15, 58, 125, .15), 0 4px 12px rgba(15, 58, 125, .05);
}
.login-card[data-mode="admin"] {
  border-color: rgba(119, 179, 255, .85);
  box-shadow: inset 0 1px 0 #fff, 0 28px 65px rgba(22, 119, 255, .19), 0 0 0 3px rgba(22, 119, 255, .04);
}
.logo-slot {
  background: linear-gradient(145deg, rgba(255, 255, 255, .95), rgba(220, 234, 255, .65));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .95), 0 6px 18px rgba(20, 73, 143, .12);
}
.seg {
  background: rgba(203, 223, 249, .36);
  border-color: rgba(255, 255, 255, .85);
  border-radius: 14px;
  box-shadow: inset 0 1px 5px rgba(20, 73, 143, .07), 0 1px 0 rgba(255, 255, 255, .8);
}
.seg-thumb {
  background: linear-gradient(150deg, #fff, rgba(255, 255, 255, .72));
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 10px;
  box-shadow: 0 3px 9px rgba(20, 73, 143, .12), inset 0 1px 0 #fff;
}
.field {
  background: rgba(243, 248, 255, .65);
  border-color: rgba(166, 192, 225, .6);
  border-radius: 12px;
  box-shadow: inset 0 2px 4px rgba(20, 73, 143, .035), 0 1px 0 rgba(255, 255, 255, .85);
}
.field:focus-within { background: rgba(255, 255, 255, .88); }
.field input::placeholder { color: #677d99; }
.box { background: rgba(255, 255, 255, .6); }
.btn-primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, .2), transparent 55%), linear-gradient(110deg, #1677ff, #1766df);
  border-color: rgba(17, 94, 211, .65);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(7, 48, 115, .15), 0 6px 16px rgba(22, 103, 223, .24);
}
.btn-primary.done { background: var(--ok); border-color: var(--ok); }
dialog {
  background: linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(237, 245, 255, .86));
  border-color: rgba(255, 255, 255, .9);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: inset 0 1px 0 #fff, 0 24px 65px rgba(10, 42, 94, .25);
}
dialog::backdrop { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-card { background: rgba(248, 251, 255, .97); }
  dialog { background: #f5f9ff; }
}

@media (max-width: 900px) {
  .login-side { min-height: calc(100vh - 76px); min-height: calc(100svh - 76px); }
  .login-card { max-width: 430px; padding: 1.25rem 1.65rem 1rem; }
  .logo-slot { width: 3.45rem; height: 3.45rem; }
  .logo-slot svg { width: 2.4rem; height: 2.4rem; }
  .seg { margin-top: .8rem; }
  .welcome { margin-top: .7rem; }
  .welcome-sub { margin-bottom: .55rem; }
  .field { height: 2.65rem; }
  .error { min-height: .75rem; margin: .1rem 0 .2rem; }
  .row { margin-bottom: .75rem; }
  .secure-note { margin-top: .65rem; }
}
@media (max-width: 520px) {
  .brand { padding: .8rem 1rem; }
  .brand-title { font-size: 1.4rem; }
  .brand-school { font-size: .53rem; }
  .brand-app { font-size: .7rem; }
  .login-side { padding: 1rem .75rem; }
  .login-card { padding: 1.1rem 1rem .95rem; }
  .row { gap: .65rem; }
  .check, .forgot { font-size: .66rem; }
}
@media (max-height: 720px) and (min-width: 521px) {
  .login-side { padding-top: .65rem; padding-bottom: .65rem; }
  .login-card { padding-top: .85rem; padding-bottom: .75rem; }
  .logo-slot { width: 3rem; height: 3rem; margin-bottom: .3rem; }
  .logo-slot svg { width: 2.1rem; height: 2.1rem; }
  .seg { margin-top: .6rem; }
  .welcome { margin-top: .5rem; }
  .welcome-sub { margin-bottom: .35rem; }
  .field { height: 2.5rem; }
  .row { margin-bottom: .6rem; }
  .secure-note { margin-top: .45rem; }
}
