/* ============================================
   INSITE — Auth System (premium, not generic)
   Used by login, forgot_password, reset_password,
   linkage_register. Shares tokens with style.css.
   ============================================ */

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: hsl(var(--background));
}

/* ── Promo panel (left) ───────────────────── */
.auth-promo {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 36px 40px 32px;
    color: hsl(0 0% 100%);
    isolation: isolate;
}

.auth-promo-bg {
    position: absolute;
    inset: 0;
    z-index: -2;
}
.auth-promo-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 35%;
    filter: saturate(1.05) contrast(1.02);
}
.auth-promo-scrim {
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, hsl(232 48% 10% / .18) 0%, hsl(232 50% 8% / .02) 22%, transparent 40%),
        linear-gradient(165deg, hsl(239 84% 26% / .86) 0%, hsl(232 48% 11% / .88) 55%, hsl(231 45% 7% / .94) 100%);
}
.auth-promo-grain {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: .08;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
}

.auth-promo-top,
.auth-promo-bottom {
    position: relative;
    z-index: 1;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.auth-brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: hsl(0 0% 100% / .94);
    padding: 3px;
    box-shadow: 0 8px 22px rgba(0,0,0,.28), inset 0 1px 0 hsl(0 0% 100% / .9);
    object-fit: contain;
    flex-shrink: 0;
}
.auth-brand-text strong {
    display: block;
    font-size: .98rem;
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1;
}
.auth-brand-text span {
    display: block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .82;
    margin-top: 3px;
}
.auth-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: hsl(0 0% 100% / .78);
}
.auth-eyebrow::before {
    content: '';
    width: 18px;
    height: 2px;
    border-radius: 99px;
    background: hsl(213 94% 72% / .95);
    box-shadow: 0 0 12px hsl(213 94% 68% / .6);
}
.auth-headline {
    margin-top: 14px;
    font-size: clamp(1.9rem, 3.2vw, 2.45rem);
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: .98;
    max-width: 16ch;
    text-wrap: balance;
}
.auth-headline em {
    font-style: normal;
    font-weight: 800;
    background: linear-gradient(120deg, hsl(213 94% 76%), hsl(239 84% 76%));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.auth-lede {
    margin-top: 14px;
    max-width: 36ch;
    font-size: .92rem;
    line-height: 1.6;
    color: hsl(0 0% 100% / .78);
    font-weight: 450;
}
.auth-feature-row {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}
.auth-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: -.01em;
    color: hsl(0 0% 100% / .92);
    background: hsl(0 0% 100% / .10);
    border: 1px solid hsl(0 0% 100% / .16);
    backdrop-filter: blur(8px);
}
.auth-chip svg { opacity: .9; flex-shrink: 0; }

.auth-promo-bottom {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.auth-quote {
    max-width: 38ch;
    padding: 14px 16px;
    border-radius: 14px;
    background: hsl(0 0% 100% / .08);
    border: 1px solid hsl(0 0% 100% / .14);
    backdrop-filter: blur(10px);
}
.auth-quote p {
    font-size: .82rem;
    line-height: 1.55;
    color: hsl(0 0% 100% / .88);
    font-style: italic;
}
.auth-quote cite {
    display: block;
    margin-top: 8px;
    font-size: .72rem;
    font-style: normal;
    font-weight: 600;
    letter-spacing: .03em;
    color: hsl(0 0% 100% / .68);
}
.auth-promo-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: .72rem;
    color: hsl(0 0% 100% / .66);
    border-top: 1px solid hsl(0 0% 100% / .14);
    padding-top: 14px;
}
.auth-promo-foot a { color: hsl(0 0% 100% / .9); text-decoration: none; border-bottom: 1px solid hsl(0 0% 100% / .28); }
.auth-promo-foot a:hover { border-bottom-color: hsl(0 0% 100% / .7); }

/* ── Form panel (right) ───────────────────── */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 28px;
    background:
        radial-gradient(1200px 500px at 85% -10%, hsl(var(--primary) / .08), transparent 60%),
        linear-gradient(to bottom, hsl(var(--card)), hsl(var(--card)));
    overflow-y: auto;
}
.auth-card {
    width: 100%;
    max-width: 410px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 18px;
    box-shadow: 0 16px 40px -16px rgba(15,23,42,.18), 0 4px 12px -4px rgba(15,23,42,.08);
    padding: 28px 28px 24px;
    position: relative;
}
.auth-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 1px 0 hsl(0 0% 100% / .8);
    opacity: .7;
}
.dark .auth-card::before { box-shadow: inset 0 1px 0 hsl(0 0% 100% / .06); opacity: 1; }

.auth-card-head {
    margin-bottom: 22px;
}
.auth-kicker {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
    margin-bottom: 8px;
}
.auth-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.15;
    color: hsl(var(--foreground));
}
.auth-subtitle {
    margin-top: 7px;
    font-size: .84rem;
    line-height: 1.5;
    color: hsl(var(--muted-foreground));
}

.auth-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: .82rem;
    font-weight: 500;
    line-height: 1.45;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.auth-alert svg { flex-shrink: 0; margin-top: 1px; }
.auth-alert--error {
    background: hsl(var(--destructive) / .08);
    color: hsl(0 72% 36%);
    border-color: hsl(var(--destructive) / .18);
    border-left: 3px solid hsl(var(--destructive));
}
.auth-alert--success {
    background: hsl(var(--success) / .10);
    color: hsl(142 72% 28%);
    border-color: hsl(var(--success) / .22);
    border-left: 3px solid hsl(var(--success));
}
.dark .auth-alert--error { color: hsl(0 90% 74%); background: hsl(0 62% 50% / .12); }
.dark .auth-alert--success { color: hsl(142 71% 72%); background: hsl(142 71% 45% / .12); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: hsl(var(--foreground));
    margin-bottom: 6px;
}
.auth-field label span.opt { font-weight: 400; color: hsl(var(--muted-foreground)); font-size: .72rem; }

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.auth-input-wrap svg.auth-input-icon {
    position: absolute;
    left: 12px;
    pointer-events: none;
    color: hsl(var(--muted-foreground) / .9);
    flex-shrink: 0;
}
.auth-input {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 38px;
    border: 1.5px solid hsl(var(--input));
    border-radius: 11px;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: .88rem;
    font-family: inherit;
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.auth-input::placeholder { color: hsl(var(--muted-foreground) / .7); }
.auth-input:hover { border-color: hsl(var(--border)); }
.auth-input:focus {
    border-color: hsl(var(--ring));
    background: hsl(var(--card));
    box-shadow: 0 0 0 4px hsl(var(--ring) / .12);
}
.auth-input--with-toggle { padding-right: 44px; }

.auth-toggle {
    position: absolute;
    right: 2px;
    top: 2px;
    bottom: 2px;
    width: 40px;
    border: none;
    background: transparent;
    border-radius: 9px;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.auth-toggle:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.auth-toggle:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 1px; }

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: -2px;
}
.auth-link {
    font-size: .78rem;
    font-weight: 600;
    color: hsl(var(--primary));
    text-decoration: none;
}
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-link--muted { color: hsl(var(--muted-foreground)); font-weight: 500; }

.auth-submit {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 11px;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    font-size: .92rem;
    font-weight: 650;
    letter-spacing: -.01em;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 18px hsl(var(--primary) / .28);
    transition: transform .12s var(--ease-spring), box-shadow .18s, background .15s, opacity .15s;
}
.auth-submit:hover { background: hsl(var(--primary) / .92); transform: translateY(-1px); box-shadow: 0 10px 24px hsl(var(--primary) / .32); }
.auth-submit:active { transform: translateY(0); opacity: .96; }
.auth-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground) / .9);
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: hsl(var(--border));
}

.auth-foot {
    margin-top: 14px;
    text-align: center;
    font-size: .78rem;
    line-height: 1.5;
    color: hsl(var(--muted-foreground));
}
.auth-foot a { color: hsl(var(--primary)); font-weight: 650; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; text-underline-offset: 2px; }

.auth-meta {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: .72rem;
    color: hsl(var(--muted-foreground));
}
.auth-meta a { color: hsl(var(--muted-foreground)); text-decoration: none; font-weight: 600; }
.auth-meta a:hover { color: hsl(var(--foreground)); }

/* Inline form grid used by linkage_register */
.auth-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
}
.auth-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.auth-col-span-2 { grid-column: span 2; }

.auth-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid hsl(var(--border));
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}
.auth-section-label:first-of-type { margin-top: 6px; }
.auth-section-label svg { color: hsl(var(--muted-foreground) / .85); flex-shrink: 0; }

/* Textarea variant */
.auth-input--area {
    height: auto;
    min-height: 74px;
    padding-top: 10px;
    padding-bottom: 10px;
    resize: vertical;
    line-height: 1.5;
}

/* Checkbox group pills */
.auth-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 6px 0;
}
.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    font-weight: 550;
    color: hsl(var(--foreground));
    cursor: pointer;
}
.auth-check input { accent-color: hsl(var(--primary)); width: 15px; height: 15px; }

/* File input polish */
.auth-input[type="file"] {
    padding: 7px 10px;
    font-size: .78rem;
    color: hsl(var(--muted-foreground));
}

/* Wide auth card (linkage register) */
.auth-card--wide {
    max-width: 760px;
}

/* Responsive */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-promo { min-height: 320px; padding: 28px 24px 22px; }
    .auth-headline { font-size: 1.9rem; max-width: 18ch; }
    .auth-panel { padding: 24px 18px 28px; align-items: flex-start; }
    .auth-card { max-width: 520px; }
    .auth-grid,
    .auth-grid--3 { grid-template-columns: 1fr; }
    .auth-col-span-2 { grid-column: span 1; }
}
@media (max-width: 560px) {
    .auth-promo { min-height: 280px; padding: 22px 18px 18px; }
    .auth-brand-mark { width: 40px; height: 40px; }
    .auth-headline { font-size: 1.65rem; }
    .auth-panel { padding: 18px 16px 24px; }
    .auth-card { padding: 22px 18px 18px; border-radius: 16px; }
    .auth-feature-row { gap: 8px; }
    .auth-chip { font-size: .7rem; padding: 6px 9px; }
}

/* Focus + motion */
.auth-card:focus-within { border-color: hsl(var(--ring) / .35); }

/* Student app modal — tied to auth system tokens */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    padding: 16px;
    background: hsl(232 48% 10% / .58);
    backdrop-filter: blur(4px);
}
.auth-modal-overlay.is-open { display: grid; place-items: center; }
.auth-modal {
    width: min(420px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(15,23,42,.32);
    padding: 20px;
    position: relative;
}
.auth-modal-close {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}
.auth-qr {
    display: block;
    width: 180px;
    height: 180px;
    margin: 12px auto 10px;
    border-radius: 12px;
    border: 1px solid hsl(var(--border));
    background: #fff;
    object-fit: cover;
}

/* Quick login — align to new palette */
.ql-header { background: hsl(var(--primary)) !important; }

/* Public auth pages remain on light theme per spec — no navy overrides.
   The global navy tokens in style.css would otherwise leak into these
   public pages via CSS variables; this block restores the original light
   design for .auth-shell and its children. */
.auth-shell {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 239 84% 67%;
    --primary-foreground: 0 0% 100%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 239 84% 67%;
    --background-color: hsl(0 0% 100%);
    --card-background: hsl(0 0% 100%);
    --text-primary: hsl(240 10% 3.9%);
    --text-secondary: hsl(240 3.8% 46.1%);
    --border-color: hsl(240 5.9% 90%);
}
.auth-shell .auth-panel {
    background: hsl(var(--background)) !important;
}
.auth-shell .auth-card {
    background: hsl(var(--card)) !important;
    border-color: hsl(var(--border)) !important;
    box-shadow: 0 16px 40px -16px rgba(15,23,42,.18), 0 4px 12px -4px rgba(15,23,42,.08) !important;
}
