/* ===================== Tokens ===================== */
:root {
    --brand: #6366f1;
    --brand-dark: #4338ca;
    --brand-light: #eef2ff;
    --accent: #06b6d4;
    --ink: #1e1b2e;
    --ink-soft: #6b7280;
    --bg: #f3f4fb;
    --surface: #ffffff;
    --border: #e8e9f3;
    --success-bg: #dcfce7;
    --success-ink: #15803d;
    --error-bg: #fee2e2;
    --error-ink: #b91c1c;
    --info-bg: #e0f2fe;
    --info-ink: #0369a1;
    --gold-bg: #fef3c7;
    --gold-ink: #92400e;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(30, 27, 46, .06);
    --shadow-md: 0 6px 20px -4px rgba(76, 29, 149, .12);
    --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    font-family: "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
a { color: inherit; }

/* ===================== App Shell ===================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(195deg, #211f3d 0%, #14122a 100%);
    color: #cfd0e6;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 26px;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
}
.sidebar .brand .logo-dot {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
    font-size: 16px;
}

.nav-group { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    color: #b9bad4;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-link svg { flex-shrink: 0; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active {
    background: linear-gradient(135deg, var(--brand), #8b5cf6);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.lang-switch { display: flex; gap: 6px; padding: 4px 4px 12px; }
.lang-switch .lang-link {
    flex: 1;
    text-align: center;
    padding: 6px 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #9192b3;
    background: rgba(255,255,255,.05);
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.lang-switch .lang-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.lang-switch .lang-link.active { color: #fff; background: linear-gradient(135deg, var(--brand), #8b5cf6); }

.sidebar .spacer { flex: 1; }

.sidebar .user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255,255,255,.05);
    margin-bottom: 10px;
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--brand));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.user-card .u-name { font-size: 13px; color: #fff; font-weight: 600; line-height: 1.3; }
.user-card .u-role { font-size: 11px; color: #9192b3; }

.logout-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 10px;
    color: #cbccdf;
    text-decoration: none;
    transition: background .15s ease;
}
.logout-link:hover { background: rgba(255,80,80,.12); color: #ff8080; }

/* ===================== Content Area ===================== */
.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 34px;
    background: rgba(255,255,255,.7);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar .page-title { font-size: 20px; font-weight: 700; margin: 0; }
.topbar .page-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.container { max-width: 1180px; width: 100%; margin: 0 auto; padding: 28px 34px 60px; }

/* ===================== Cards ===================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 22px;
}
.card h2 { font-size: 16px; margin-top: 0; margin-bottom: 16px; }

/* ===================== Stat tiles ===================== */
.stats { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat {
    flex: 1;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat .stat-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-light);
    color: var(--brand-dark);
    flex-shrink: 0;
}
.stat .num { font-size: 24px; font-weight: 700; line-height: 1; }
.stat .lbl { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* ===================== Forms ===================== */
label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: #3f3d56; }
input[type=text], input[type=password], input[type=file], select {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: #fbfbff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-light);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--brand), #7c3aed);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 14px -4px rgba(99,102,241,.55);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: #6b7280; box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 14px -4px rgba(220,38,38,.5); }

/* ===================== Alerts ===================== */
.alert { padding: 13px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.alert.error { background: var(--error-bg); color: var(--error-ink); border-color: #fecaca; }
.alert.success { background: var(--success-bg); color: var(--success-ink); border-color: #bbf7d0; }
.alert.info { background: var(--info-bg); color: var(--info-ink); border-color: #bae6fd; }

/* ===================== Tables ===================== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; }
thead th {
    background: #f7f7fd;
    color: #55536e;
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s ease; }
tbody tr:hover { background: #faf9ff; }
tbody tr:last-child { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge.super { background: var(--gold-bg); color: var(--gold-ink); }
.badge.admin { background: var(--info-bg); color: var(--info-ink); }

/* ===================== Filters ===================== */
.filters { display: flex; gap: 14px; align-items: end; margin-bottom: 4px; flex-wrap: wrap; }
.filters > div { flex: 1; min-width: 160px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .emoji { font-size: 38px; margin-bottom: 10px; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    color: var(--ink-soft);
    border: 1px solid var(--border);
}
.pagination a.current { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }

/* ===================== Responsive ===================== */
@media (max-width: 880px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
    .sidebar .brand { padding: 4px 10px; }
    .nav-group { flex-direction: row; }
    .sidebar .spacer { display: none; }
    .sidebar .user-card, .logout-link { display: none; }
    .container, .topbar { padding-left: 18px; padding-right: 18px; }
}

/* ===================== Login Page ===================== */
body.login-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(139,92,246,.35), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(6,182,212,.3), transparent 45%),
        linear-gradient(160deg, #1c1a34 0%, #100f22 100%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: rgba(255,255,255,.97);
    border-radius: 22px;
    padding: 8px 34px 34px;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
    text-align: center;
    position: relative;
}

.login-lang-switch { position: absolute; top: 16px; right: 16px; display: flex; gap: 4px; }
.login-lang-switch a {
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-soft);
    background: #f1f1fa;
    text-decoration: none;
}
.login-lang-switch a.active { color: #fff; background: var(--brand); }

.captcha-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.captcha-row img { border-radius: 8px; border: 1px solid var(--border); }
.captcha-refresh {
    border: none;
    background: none;
    color: var(--brand);
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.login-card h1 { font-size: 21px; margin: 4px 0 2px; }
.login-card .sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 6px; }
.login-card form { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 12px; font-size: 15px; }

.mascot-stage {
    width: 168px;
    height: 178px;
    margin: -58px auto 0;
    overflow: hidden;
}
#mascot { width: 100%; height: 100%; overflow: visible; animation: mascot-float 3.2s ease-in-out infinite; }
@keyframes mascot-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.pupil { transition: transform .09s linear; }
.hand-left, .hand-right {
    transition: transform .38s cubic-bezier(.34,1.56,.64,1);
}
.hand-left { transform: translate(34px,155px) rotate(-12deg); }
.hand-right { transform: translate(166px,155px) rotate(12deg) scale(-1,1); }
#mascot.hands-up .hand-left { transform: translate(74px,97px) rotate(-6deg); }
#mascot.hands-up .hand-right { transform: translate(126px,97px) rotate(6deg) scale(-1,1); }
#mascot.hands-up .eyes { opacity: 0; transition: opacity .12s ease .12s; }
.eyes { transition: opacity .12s ease; }

.login-footnote {
    text-align: center;
    margin-top: 18px;
    font-size: 12px;
    color: rgba(255,255,255,.55);
}
