:root {
    --ae-primary: #2563eb;
    --ae-primary-dark: #1d4ed8;
    --ae-accent: #0f172a;
    --ae-text: #0f172a;
    --ae-muted: #64748b;
    --ae-border: rgba(226, 232, 240, 0.95);
    --ae-panel: rgba(255, 255, 255, 0.94);
    --ae-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
    --ae-width: min(1200px, calc(100% - 32px));
    --ae-wide-width: min(1380px, calc(100% - 32px));
    --ae-sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--ae-text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 28%),
        radial-gradient(circle at 85% 16%, rgba(14, 165, 233, 0.10), transparent 24%),
        linear-gradient(180deg, #f8fafc 0%, #eef4ff 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.38), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 0;
}

a { color: inherit; }

.page-shell,
.admin-shell {
    position: relative;
    z-index: 1;
}

.site-header {
    position: relative;
    z-index: 1200;
    padding: 18px 0 0;
}

.site-nav {
    width: var(--ae-width);
    margin: 0 auto;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--ae-border);
    border-radius: 24px;
    background: rgba(255,255,255,0.92);
    box-shadow: var(--ae-shadow);
    backdrop-filter: blur(14px);
    position: relative;
    overflow: visible;
    z-index: 1201;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--ae-text);
}

.site-brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.site-brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-brand-copy strong {
    font-size: 1rem;
    font-weight: 700;
}

.site-brand-copy span {
    font-size: 0.86rem;
    color: var(--ae-muted);
}

.site-nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.site-nav-link {
    padding: 10px 16px;
    border-radius: 999px;
    text-decoration: none;
    color: #334155;
    font-weight: 600;
    transition: all 0.2s ease;
}

.site-nav-link:hover,
.site-nav-link.active {
    color: var(--ae-primary-dark);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(14, 165, 233, 0.08));
}

.site-nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-announcement-entry {
    position: relative;
    z-index: 1203;
}

.announcement-trigger {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(191, 219, 254, 0.95);
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.95), rgba(255,255,255,0.96));
    color: var(--ae-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
    transition: all 0.2s ease;
    position: relative;
    font-size: 1.15rem;
}

.announcement-trigger:hover {
    border-color: rgba(147, 197, 253, 0.95);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.14);
    color: var(--ae-primary-dark);
}

.announcement-trigger.is-open {
    background: linear-gradient(135deg, rgba(219, 234, 254, 0.95), rgba(239, 246, 255, 0.96));
}

.announcement-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    border-radius: 14px;
    border: 1px solid var(--ae-border);
    background: #fff;
    box-shadow: 0 16px 40px rgba(0,0,0,0.12);
    overflow: hidden;
    animation: ae-dropdown-in 0.18s ease;
}

.announcement-dropdown.hidden { display: none; }

@keyframes ae-dropdown-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.announcement-dropdown-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ae-primary-dark);
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.8), rgba(255,255,255,0.9));
    border-bottom: 1px solid var(--ae-border);
}

.announcement-dropdown-body {
    padding: 14px 16px;
    font-size: 0.9rem;
    color: var(--ae-text);
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.site-account-entry {
    position: relative;
    min-width: 140px;
    z-index: 1202;
}

.account-trigger {
    padding: 10px 14px;
    border-radius: 18px;
    border: 1px solid rgba(191, 219, 254, 0.95);
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.95), rgba(255,255,255,0.96));
    color: var(--ae-text);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
    transition: all 0.2s ease;
    user-select: none;
}

.account-trigger:hover {
    border-color: rgba(147, 197, 253, 0.95);
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.14);
}

.account-trigger.is-open .account-arrow {
    transform: rotate(180deg);
}

.account-trigger > .bi-person-circle {
    font-size: 1.3rem;
    color: var(--ae-primary);
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.account-info strong { font-size: 0.9rem; }

.account-info span {
    font-size: 0.78rem;
    color: var(--ae-muted);
}

.account-arrow {
    font-size: 0.7rem;
    color: var(--ae-muted);
    margin-left: auto;
    transition: transform 0.2s ease;
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    padding: 8px;
    border-radius: 16px;
    background: rgba(255,255,255,0.98);
    border: 1px solid var(--ae-border);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    z-index: 1300;
}

.dropdown-user-info {
    padding: 12px 14px;
}

.dropdown-username {
    font-weight: 700;
    font-size: 0.95rem;
}

.dropdown-role {
    font-size: 0.82rem;
    color: var(--ae-muted);
    margin-top: 2px;
}

.account-dropdown .dropdown-divider {
    height: 1px;
    background: var(--ae-border);
    margin: 4px 0;
}

.account-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ae-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.account-dropdown .dropdown-item:hover {
    background: rgba(37, 99, 235, 0.06);
    color: var(--ae-primary);
}

.page-shell {
    width: var(--ae-width);
    margin: 0 auto;
    padding: 24px 0 56px;
}

.page-shell-wide { width: var(--ae-wide-width); }

.surface-panel,
.card,
.stat-card {
    border: 1px solid var(--ae-border);
    border-radius: 24px;
    background: var(--ae-panel);
    box-shadow: var(--ae-shadow);
    backdrop-filter: blur(14px);
}

.surface-panel { padding: 28px; }

.section-kicker {
    color: var(--ae-primary-dark);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-title {
    margin-top: 8px;
    font-size: 1.5rem;
    font-weight: 700;
}

.section-subtitle,
.content-muted,
.text-muted {
    color: var(--ae-muted) !important;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.btn-primary {
    background: var(--ae-primary);
    border-color: var(--ae-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--ae-primary-dark);
    border-color: var(--ae-primary-dark);
}

.card {
    border: 1px solid var(--ae-border);
    overflow: hidden;
}

.card-header {
    background: rgba(248, 250, 252, 0.9);
    border-bottom: 1px solid var(--ae-border);
    font-weight: 600;
    padding: 16px 20px;
}

.stat-card {
    padding: 24px;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 58%, #38bdf8 100%);
    color: white;
}

.stat-card.green { background: linear-gradient(135deg, #059669, #10b981); }
.stat-card.orange { background: linear-gradient(135deg, #d97706, #f59e0b); }
.stat-card.red { background: linear-gradient(135deg, #dc2626, #ef4444); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    opacity: 0.92;
    font-size: 0.92rem;
}

.badge-status {
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
}

.badge-activated { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-disabled { background: #fee2e2; color: #991b1b; }
.badge-expired { background: #e2e8f0; color: #475569; }

.empty-panel {
    padding: 24px;
    text-align: center;
    border-radius: 18px;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    color: #64748b;
}

.hidden { display: none !important; }

.announcement-box {
    display: none;
    white-space: pre-wrap;
}

#appToastRegion {
    z-index: 1080;
}

.rotate-180 {
    transform: rotate(180deg);
    transition: transform 0.2s ease;
}

.admin-dialog-message {
    white-space: pre-line;
}

.admin-shell {
    width: var(--ae-wide-width);
    margin: 24px auto 56px;
    display: grid;
    grid-template-columns: var(--ae-sidebar-width) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.admin-sidebar {
    position: sticky;
    top: 18px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(15,23,42,0.96), rgba(30,41,59,0.96));
    color: white;
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.22);
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-weight: 700;
}

.admin-sidebar-brand img {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.admin-sidebar .nav { gap: 6px; }

.admin-sidebar .nav-link {
    color: rgba(255,255,255,0.76);
    border-radius: 16px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.10);
}

.admin-sidebar-footer {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-main { min-width: 0; }

@media (max-width: 992px) {
    .site-nav {
        width: calc(100% - 24px);
        padding: 16px;
        flex-wrap: wrap;
    }

    .site-nav-links {
        justify-content: flex-start;
        width: 100%;
        order: 3;
    }

    .site-nav-right { margin-left: auto; }

    .site-account-entry { margin-left: 0; }

    .page-shell,
    .page-shell-wide,
    .admin-shell {
        width: calc(100% - 24px);
    }

    .admin-shell { grid-template-columns: 1fr; }

    .admin-sidebar { position: static; }
}

@media (max-width: 768px) {
    .site-nav { gap: 14px; }

    .site-brand { width: 100%; }

    .site-nav-right {
        width: 100%;
        margin-left: 0;
    }

    .site-account-entry {
        flex: 1;
        margin-left: 0;
    }

    .announcement-dropdown {
        width: 280px;
    }

    .page-shell,
    .page-shell-wide {
        padding-top: 20px;
    }

    .surface-panel { padding: 22px; }
}