* { box-sizing: border-box; }

:root {
    --bg: #050414;
    --panel: rgba(19, 9, 43, 0.82);
    --panel-strong: rgba(15, 8, 35, 0.94);
    --purple: #9b5cff;
    --violet: #c55cff;
    --magenta: #f03cff;
    --pink: #ff2f75;
    --red: #ef233c;
    --text: #fff;
    --muted: #cec7df;
    --border: rgba(190, 110, 255, 0.38);
    --glow: 0 0 28px rgba(164, 73, 255, .20);
}

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

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 86% 26%, rgba(190, 80, 255, .22) 0 7%, rgba(105, 48, 190, .08) 16%, transparent 32%),
        radial-gradient(circle at 9% 82%, rgba(211, 54, 255, .18) 0 9%, rgba(103, 53, 180, .08) 19%, transparent 34%),
        radial-gradient(ellipse at 40% 42%, rgba(79, 45, 150, .16), transparent 43%),
        radial-gradient(ellipse at 58% 79%, rgba(135, 47, 187, .13), transparent 44%),
        linear-gradient(135deg, #050413 0%, #09051b 42%, #0c0725 68%, #050411 100%);
    background-attachment: fixed;
    isolation: isolate;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -2;
}

body::before {
    opacity: .58;
    background-image:
        radial-gradient(circle at 4% 12%, rgba(255,255,255,.8) 0 1px, transparent 1.4px),
        radial-gradient(circle at 14% 38%, rgba(218,179,255,.7) 0 1px, transparent 1.5px),
        radial-gradient(circle at 26% 18%, rgba(255,255,255,.65) 0 1px, transparent 1.5px),
        radial-gradient(circle at 37% 67%, rgba(188,132,255,.8) 0 1px, transparent 1.5px),
        radial-gradient(circle at 49% 28%, rgba(255,255,255,.85) 0 1px, transparent 1.5px),
        radial-gradient(circle at 61% 54%, rgba(222,190,255,.7) 0 1px, transparent 1.4px),
        radial-gradient(circle at 72% 15%, rgba(255,255,255,.65) 0 1px, transparent 1.5px),
        radial-gradient(circle at 84% 73%, rgba(220,155,255,.75) 0 1px, transparent 1.5px),
        radial-gradient(circle at 94% 32%, rgba(255,255,255,.75) 0 1px, transparent 1.4px);
    background-size: 290px 290px, 360px 360px, 420px 420px, 350px 350px, 500px 500px, 390px 390px, 460px 460px, 330px 330px, 510px 510px;
}

body::after {
    z-index: -1;
    opacity: .65;
    background:
        radial-gradient(circle at 88% 25%, rgba(245, 151, 255, .10), transparent 12%),
        radial-gradient(circle at 12% 83%, rgba(157, 71, 255, .11), transparent 14%),
        linear-gradient(rgba(3, 3, 12, .24), rgba(3, 3, 12, .38));
}

a { color: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 70px;
    padding: 10px 34px;
    border-bottom: 1px solid rgba(190, 88, 255, .28);
    background: rgba(4, 4, 17, .84);
    backdrop-filter: blur(18px);
    box-shadow: 0 8px 30px rgba(0,0,0,.16);
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    white-space: nowrap;
}

.brand-logo span {
    font-weight: 950;
    font-style: italic;
    letter-spacing: .05em;
    font-size: clamp(1.35rem, 3vw, 2.15rem);
    line-height: 1;
    background: linear-gradient(180deg, #ffffff 0%, #db8cff 18%, #ff36d8 42%, #884cff 65%, #2db7ff 84%, #d6f6ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow:
        0 0 6px rgba(255, 74, 220, .35),
        0 0 18px rgba(92, 121, 255, .24);
}

.nav-sub { margin-left: 10px; color: var(--muted); font-size: .88rem; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-chip { padding: 9px 13px; border-radius: 999px; background: rgba(255,255,255,.08); color: #e4dff0; border: 1px solid rgba(255,255,255,.08); }

.container, .admin-shell {
    width: min(1180px, calc(100% - 30px));
    margin: 0 auto;
    padding: 54px 0 74px;
}

.portal-container { width: min(1200px, calc(100% - 28px)); }

.hero-card, .panel, .auth-card, .admin-card {
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: 0 22px 70px rgba(0,0,0,.30), var(--glow);
    backdrop-filter: blur(14px);
}

.hero-card {
    width: min(1000px, 100%);
    margin: 0 auto;
    padding: clamp(24px, 4vw, 40px);
    border-radius: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 0%, rgba(220, 92, 255, .12), transparent 35%);
}

.portal-title {
    position: relative;
    margin: 0 0 22px;
    font-size: clamp(2rem, 5vw, 3.55rem);
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -.035em;
    background: linear-gradient(180deg, #fff 0%, #eec8ff 34%, #b862ff 75%, #f0a1ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 28px rgba(196, 75, 255, .16);
}

h1 { margin: 0 0 12px; font-size: clamp(2rem, 5vw, 3rem); }
h2 { margin-top: 0; }
.muted { color: var(--muted); }

.search-form { position: relative; margin-top: 8px; }
.search-label {
    display: block;
    margin-bottom: 12px;
    text-align: center;
    font-size: clamp(1rem, 2vw, 1.12rem);
    font-weight: 800;
    color: #f0dcff;
}

.search-row {
    width: min(820px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: stretch;
    gap: 12px;
}

input, select {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid rgba(191, 103, 255, .55);
    border-radius: 12px;
    outline: 0;
    background: rgba(13, 11, 32, .68);
    color: #fff;
    font-size: 1rem;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input::placeholder { color: #aca5be; }

input:focus, select:focus {
    border-color: #c76cff;
    box-shadow: 0 0 0 3px rgba(181, 85, 255, .18), 0 0 24px rgba(157, 70, 255, .12);
    background: rgba(15, 12, 37, .88);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn.primary {
    background: linear-gradient(180deg, #ff375f 0%, #eb1439 100%);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 8px 25px rgba(235, 20, 57, .24), inset 0 1px rgba(255,255,255,.25);
}
.btn.primary:hover { box-shadow: 0 10px 32px rgba(235, 20, 57, .34), 0 0 18px rgba(255, 48, 112, .20); }
.btn.ghost { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.055); color: #fff; }
.btn.ghost:hover { border-color: rgba(194, 100, 255, .45); background: rgba(150, 73, 255, .10); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.btn.danger { background: #7f1d1d; color: #fff; }
.btn.full { width: 100%; }
.search-btn { min-width: 132px; }

.steps-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 34px;
}

.step-card {
    min-height: 205px;
    padding: 20px 16px;
    border: 1px solid rgba(184, 93, 255, .48);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(73, 31, 117, .22), rgba(13, 10, 31, .38));
    box-shadow: inset 0 1px rgba(255,255,255,.04), 0 14px 40px rgba(0,0,0,.12);
}

.step-icon,
.note-icon,
.lock-badge {
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    border: 1px solid rgba(209, 129, 255, .65);
    background: rgba(121, 48, 201, .18);
    box-shadow: 0 0 22px rgba(181, 80, 255, .25), inset 0 0 18px rgba(194, 100, 255, .08);
}

.step-icon { width: 58px; height: 58px; margin: 0 auto 12px; font-size: 1.6rem; }
.step-card h2 { margin: 0 0 8px; font-size: 1.25rem; color: #f4e7ff; }
.step-card p { margin: 0; color: #d8d0e4; line-height: 1.45; font-size: .94rem; }

.note-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 18px;
    padding: 18px 22px;
    text-align: left;
    border: 1px solid rgba(195, 95, 255, .5);
    border-radius: 18px;
    background: linear-gradient(90deg, rgba(95, 37, 148, .30), rgba(32, 18, 61, .30));
}

.note-icon { flex: 0 0 auto; width: 56px; height: 56px; font-size: 1.8rem; font-weight: 900; }
.note-card strong { display: block; margin-bottom: 3px; color: #e882ff; font-size: 1.25rem; }
.note-card p { margin: 0; color: #e0d8ea; }

.loading { display: none; margin: 22px 0 0; color: #d897ff; font-weight: 800; }

.alert { margin: 18px 0; padding: 13px 15px; border-radius: 12px; }
.alert.error { background: rgba(127,29,29,.48); color: #fecaca; border: 1px solid rgba(248,113,113,.26); }
.alert.success { background: rgba(20,83,45,.48); color: #bbf7d0; }
.alert.info { background: rgba(62, 31, 108, .52); color: #e9d5ff; border: 1px solid rgba(183, 124, 255, .24); }

.email-count { margin-top: 24px; color: #d29cff; font-weight: 800; }
.table-wrap { width: 100%; overflow-x: auto; border-radius: 14px; }

table {
    width: 100%;
    margin-top: 16px;
    border-collapse: collapse;
    background: rgba(7, 6, 18, .55);
}

th, td {
    padding: 12px;
    border: 1px solid rgba(190, 116, 255, .16);
    text-align: left;
    vertical-align: middle;
}

th { background: rgba(122, 58, 182, .18); color: #f5eaff; }

.link-button {
    border: 0;
    background: transparent;
    color: #e58cff;
    font-weight: 800;
    cursor: pointer;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 20px;
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: min(960px, 96vw);
    height: min(86vh, 900px);
    margin: 3vh auto;
    padding: 22px;
    border: 1px solid rgba(189, 96, 255, .36);
    border-radius: 18px;
    background: #10101a;
    box-shadow: 0 24px 80px rgba(0,0,0,.42), 0 0 28px rgba(150, 60, 255, .14);
}

.modal-content h2 {
    margin-right: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 34px;
    cursor: pointer;
}

#emailFrame {
    width: 100%;
    height: calc(100% - 50px);
    border: 0;
    border-radius: 10px;
    background: white;
}

/* LOGIN */
.auth-page {
    min-height: 100vh;
    padding: 0;
    display: block;
}

.auth-topbar { position: relative; }
.auth-shell {
    min-height: calc(100vh - 70px);
    display: grid;
    place-items: center;
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 40px 20px 64px;
}

.auth-card {
    width: min(560px, 100%);
    padding: 34px;
    border-radius: 22px;
}

.neon-auth-card {
    text-align: center;
    background: linear-gradient(180deg, rgba(39, 16, 77, .84), rgba(16, 9, 35, .88));
    border-color: rgba(192, 96, 255, .5);
}

.neon-auth-card h1 {
    margin: 10px 0 8px;
    font-size: clamp(2.1rem, 5vw, 3.2rem);
    font-weight: 900;
    background: linear-gradient(180deg, #fff, #dc9cff 60%, #b75aff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-subtitle { margin-bottom: 8px; }
.lock-badge { width: 78px; height: 78px; margin: 0 auto 8px; font-size: 2rem; }

.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.input-shell { position: relative; }
.input-shell input {
    min-height: 58px;
    padding-left: 50px;
    border-radius: 14px;
}
.input-icon {
    position: absolute;
    left: 17px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    color: #cf8cff;
    font-size: 1.35rem;
}
.auth-submit { min-height: 58px; width: 100%; font-size: 1.12rem; }
.authorized-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    color: #bfb7ce;
    font-size: .92rem;
}
.authorized-line::before,
.authorized-line::after {
    content: "";
    height: 1px;
    flex: 1;
    background: linear-gradient(90deg, transparent, rgba(198, 111, 255, .55));
}
.authorized-line::after { background: linear-gradient(90deg, rgba(198, 111, 255, .55), transparent); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ADMIN */
.wide-auth { width: min(560px, 100%); }
.stack-form label, .grid-form label { display: grid; gap: 7px; font-weight: 700; }

.admin-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.admin-card {
    min-height: 210px;
    padding: 26px;
    border-radius: 16px;
    text-decoration: none;
}

.metric { display: block; margin-bottom: 18px; color: #d070ff; font-size: 2.6rem; font-weight: 800; }
.admin-card p { color: var(--muted); }
.panel { margin-bottom: 20px; padding: 24px; border-radius: 16px; }

.grid-form {
    display: grid;
    grid-template-columns: 1.3fr 1.3fr 1fr auto;
    gap: 12px;
    align-items: end;
    margin-top: 20px;
}

.grid-form .wide { grid-column: span 2; }
.inline-form, .actions-cell { display: flex; align-items: center; gap: 8px; }
.inline-form input { min-width: 170px; min-height: 36px; }
.actions-cell form { display: inline-block; }

@media (max-width: 920px) {
    .steps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .admin-grid, .grid-form { grid-template-columns: 1fr; }
    .grid-form .wide { grid-column: auto; }
    .search-row { flex-direction: column; }
    .search-btn { width: 100%; }
    .topbar { align-items: center; padding: 12px 16px; }
    .nav-sub { display: none; }
    .user-chip { display: none; }
}

@media (max-width: 620px) {
    .topbar { gap: 12px; }
    .brand-logo span { font-size: 1.12rem; }
    .top-actions { gap: 6px; }
    .top-actions .btn { padding: 8px 10px; font-size: .88rem; }
    .container { padding-top: 26px; }
    .hero-card { padding: 24px 16px; border-radius: 18px; }
    .steps-grid { grid-template-columns: 1fr; }
    .step-card { min-height: auto; }
    .note-card { align-items: flex-start; }
    .auth-card { padding: 28px 20px; }
}
