:root {
  --navy: #071b55;
  --muted: #526896;
  --line: rgba(17, 66, 133, 0.12);
  --sans: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --accent: #0b67ef;
  --accent-2: #3d8bff;
  --accent-soft: #e3efff;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--navy);
  background:
    radial-gradient(60rem 40rem at 0% 0%, #e7f0ff 0%, transparent 60%),
    radial-gradient(50rem 36rem at 100% 0%, #fff1e3 0%, transparent 55%),
    #f7fbff;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.portal-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: clamp(0.75rem, 3vw, 2.5rem); }
.portal-page[data-role="student"] { --accent: #0b67ef; --accent-2: #3d8bff; --accent-soft: #e3efff; }
.portal-page[data-role="teacher"] { --accent: #f16100; --accent-2: #ff8a2b; --accent-soft: #fff0df; }
.portal-page[data-role="parent"] { --accent: #05a35c; --accent-2: #20c477; --accent-soft: #dff6ea; }
.portal-page[data-role="admin"] { --accent: #6a2be8; --accent-2: #8f57ff; --accent-soft: #efe6ff; }

.portal-panel {
  position: relative;
  width: min(100%, 1040px);
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 3.5vw, 2.5rem) clamp(1.5rem, 4vw, 2.75rem);
  border: 1px solid var(--line);
  border-radius: 1.75rem;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 2rem 4rem rgba(16, 52, 120, 0.12);
  backdrop-filter: blur(10px);
}
.portal-page[data-role]:not([data-role=""]) .portal-panel {
  width: min(100%, 480px);
  background: linear-gradient(180deg, var(--accent-soft) 0%, rgba(255, 255, 255, 0.94) 38%);
}
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; color: var(--navy); font-weight: 600; font-size: 0.95rem; text-decoration: none; border-radius: 0.6rem; }
.back-link svg, .close-link svg, .field svg, .toggle-password svg, .role-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back-link svg { width: 20px; height: 20px; }
.back-link:hover { color: var(--accent); }
.portal-page[data-role]:not([data-role=""]) .panel-top .back-link[data-back] { visibility: hidden; }
.close-link { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--navy); background: #fff; box-shadow: 0 0.5rem 1.2rem rgba(16, 52, 120, 0.12); }
.close-link svg { width: 18px; height: 18px; }
.language-control { display: flex; gap: 0.15rem; padding: 0.2rem; border-radius: 999px; background: #e8edf7; margin-left: auto; }
.language-control button { min-width: 44px; min-height: 36px; border: 0; border-radius: 999px; background: transparent; color: var(--navy); font: 700 0.85rem var(--sans); cursor: pointer; }
.language-control button[aria-pressed="true"] { color: #fff; background: #05aa61; }

.view { text-align: center; }
.portal-logo { display: block; width: 96px; height: auto; margin: 0.25rem auto 0.75rem; }
.portal-logo.small { width: 72px; margin-top: 0.5rem; }
h1 { margin: 0; font-size: clamp(1.8rem, 4.6vw, 3rem); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; }
.login-title { font-size: clamp(1.6rem, 5vw, 2rem); outline: none; }
.portal-sub { margin: 0.6rem auto 1.6rem; max-width: 34rem; color: var(--muted); font-size: 1.02rem; line-height: 1.5; }

.role-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.role-card {
  --c: #0b67ef; --c-soft: #e3efff;
  display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
  padding: 1.5rem 1rem 1.25rem; border: 1px solid var(--line); border-radius: 1.25rem;
  background: linear-gradient(180deg, var(--c-soft) 0%, #fff 55%);
  color: var(--navy); text-decoration: none;
  box-shadow: 0 0.9rem 2rem rgba(16, 52, 120, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.role-card:hover { transform: translateY(-3px); box-shadow: 0 1.2rem 2.4rem rgba(16, 52, 120, 0.14); }
.role-card:focus-visible, .sign-in:focus-visible, .back-link:focus-visible, .close-link:focus-visible, .forgot:focus-visible,
.toggle-password:focus-visible, .language-control button:focus-visible, .notice-link:focus-visible { outline: 3px solid #ffb100; outline-offset: 3px; }
.role-student { --c: #0b67ef; --c-soft: #e3efff; }
.role-teacher { --c: #f16100; --c-soft: #fff0df; }
.role-parent { --c: #05a35c; --c-soft: #dff6ea; }
.role-admin { --c: #6a2be8; --c-soft: #efe6ff; }
.role-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; color: var(--c); background: var(--c-soft); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8); }
.role-icon svg { width: 36px; height: 36px; }
.role-card strong { font-size: 1.2rem; }
.role-desc { min-height: 3.6em; color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.role-go { display: grid; place-items: center; width: 48px; height: 48px; margin-top: auto; border-radius: 50%; color: #fff; font-size: 1.3rem; background: var(--c); box-shadow: 0 0.6rem 1.2rem color-mix(in srgb, var(--c) 35%, transparent); }

.back-portal { display: flex; width: max-content; margin: 0 auto 0.25rem 0; }
.login-form { display: grid; gap: 0.85rem; text-align: left; }
.field { position: relative; display: flex; align-items: center; min-height: 52px; border: 1px solid #d8e1ef; border-radius: 0.8rem; background: #fff; }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field > svg { width: 20px; height: 20px; margin: 0 0.75rem 0 0.9rem; color: #6a7b9f; flex: 0 0 20px; }
.field input { flex: 1; min-width: 0; height: 50px; border: 0; border-left: 1px solid #e6ecf5; padding: 0 0.85rem; background: transparent; color: var(--navy); font: 1rem var(--sans); outline: none; }
.toggle-password { display: grid; place-items: center; width: 44px; height: 44px; margin-right: 0.25rem; border: 0; border-radius: 0.6rem; background: transparent; color: #6a7b9f; cursor: pointer; }
.toggle-password[aria-pressed="true"] { color: var(--accent); }
.toggle-password svg { width: 22px; height: 22px; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; font-size: 0.95rem; }
.remember { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; cursor: pointer; }
.remember input { width: 18px; height: 18px; accent-color: var(--accent); }
.forgot { color: var(--accent); font-weight: 700; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.sign-in { min-height: 54px; border: 0; border-radius: 0.85rem; color: #fff; font: 700 1.08rem var(--sans); cursor: pointer; background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0.8rem 1.6rem color-mix(in srgb, var(--accent) 30%, transparent); }
.sign-in:hover { filter: brightness(1.05); }
.notice { padding: 0.9rem 1rem; border-radius: 0.8rem; background: #fff8e6; border: 1px solid #ffe2a3; color: #5a4300; font-size: 0.93rem; line-height: 1.5; }
.notice p { margin: 0 0 0.5rem; }
.notice-link { color: var(--accent); font-weight: 700; }

@media (max-width: 900px) {
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .portal-panel { border-radius: 1.25rem; }
  .role-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .role-card { display: grid; grid-template-columns: 56px 1fr 44px; grid-template-rows: auto auto; align-items: center; text-align: left; gap: 0.15rem 0.85rem; padding: 0.9rem; }
  .role-icon { grid-row: 1 / span 2; width: 56px; height: 56px; }
  .role-icon svg { width: 28px; height: 28px; }
  .role-desc { min-height: 0; font-size: 0.86rem; grid-column: 2; }
  .role-go { grid-column: 3; grid-row: 1 / span 2; width: 44px; height: 44px; margin: 0; }
  .portal-logo { width: 76px; }
}
@media (prefers-reduced-motion: reduce) { .role-card, .role-card:hover { transition: none; transform: none; } }
