:root {
    --bg: #f8f9fb;
    --bg-elev: rgba(255, 255, 255, 0.88);
    --panel: rgba(255, 255, 255, 0.78);
    --text: #0f1118;
    --muted: #636a7a;
    --border: rgba(20, 25, 38, 0.1);
    --accent-red: #ce3030;
    --accent-magenta: #a32121;
    --shadow: 0 20px 50px rgba(23, 13, 22, 0.12);
}

[data-theme='dark'] {
    --bg: #06070b;
    --bg-elev: rgba(15, 16, 24, 0.86);
    --panel: rgba(13, 14, 22, 0.72);
    --text: #f5f7ff;
    --muted: #9aa0b2;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 60px rgba(255, 23, 72, 0.18);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    font-family: 'Sora', 'Segoe UI', sans-serif;
    background: var(--portal-bg, radial-gradient(circle at 10% -10%, rgba(255, 15, 143, 0.24), transparent 35%), radial-gradient(circle at 85% 5%, rgba(255, 23, 72, 0.22), transparent 40%), var(--bg));
    min-height: 100vh;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

img, video, canvas, svg, iframe {
    max-width: 100%;
}

a { color: inherit; text-decoration: none; }

.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.sidebar {
    padding: 24px;
    border-right: 1px solid var(--border);
    background: var(--portal-panel, var(--panel));
    backdrop-filter: blur(14px);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.brand {
    margin-bottom: 24px;
    display: inline-flex;
    align-items: center;
}

.brand-logo {
    width: 170px;
    max-width: 100%;
    height: auto;
    display: block;
}

.brand span { color: var(--accent-magenta); }

.sidebar-close-btn {
    display: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--muted);
    margin-bottom: 8px;
    transition: 180ms ease;
}

.nav-icon {
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-red);
    animation: navIconFloat 2.8s ease-in-out infinite;
    transition: transform 180ms ease, color 180ms ease;
}

.nav-text { line-height: 1; }

.nav-link:hover,
.nav-link.active {
    color: #fff;
    background: var(--portal-btn, linear-gradient(120deg, var(--accent-red), var(--accent-magenta)));
    box-shadow: 0 10px 30px rgba(255, 23, 72, 0.34);
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    color: #fff;
    transform: translateY(-1px) scale(1.08) rotate(-6deg);
}

.content-wrap {
    padding: 24px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

.topbar-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.mobile-menu-btn {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 0;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(110deg, var(--accent-red), var(--accent-magenta));
}

.sidebar-backdrop {
    display: none;
}

.card {
    background: var(--portal-panel, var(--bg-elev));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    padding: 18px;
    min-width: 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    min-width: 0;
}

.grid > * { min-width: 0; }

.metric-value { font-size: 1.7rem; font-weight: 700; }
.metric-label { color: var(--muted); font-size: 0.84rem; }

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th, td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: 12px;
}

th { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; }

.input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
    border-radius: 10px;
    padding: 10px;
}

select, option, optgroup {
    color: var(--text);
    background-color: var(--bg-elev);
}

label {
    display: inline-block;
    margin-bottom: 6px;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: var(--portal-btn, linear-gradient(110deg, #ce3030, #a32121));
}

.btn-secondary {
    color: #fff;
    border: 0;
    background: var(--portal-btn, linear-gradient(110deg, #ce3030, #a32121));
}

.action-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.action-btn i {
    font-size: 0.95rem;
    animation: actionIconPulse 2.2s ease-in-out infinite;
}

.action-view i { color: #9ad6ff; }
.action-edit i { color: #ffe19a; }
.action-delete i { color: #ffd2d2; }

.action-btn:hover i {
    transform: scale(1.12) rotate(-8deg);
}

.top-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.top-action-alert {
    position: relative;
}

.top-action-alert-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ce3030;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.top-action i {
    animation: topIconPulse 2.2s ease-in-out infinite;
    transition: transform 180ms ease;
    font-size: 1.28rem;
    color: var(--accent-red);
}

.top-action:hover i {
    transform: scale(1.12) rotate(-8deg);
}

[data-theme='dark'] .top-action i {
    color: #f5f7ff;
}

.top-action-logout {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: #ce3030 !important;
}

.top-action-logout i {
    color: #fff !important;
}

@keyframes navIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes topIconPulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

@keyframes actionIconPulse {
    0%, 100% { opacity: 0.86; }
    50% { opacity: 1; }
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.flash {
    margin-bottom: 16px;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(20, 180, 120, 0.14);
    border: 1px solid rgba(20, 180, 120, 0.4);
}

.pagination-wrap {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.pagination-list {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-item {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1;
}

.pagination-item.is-active {
    color: #fff;
    border-color: transparent;
    background: var(--portal-btn, linear-gradient(110deg, #ce3030, #a32121));
}

.pagination-item.is-disabled {
    opacity: 0.45;
    cursor: default;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    width: min(460px, 95%);
}

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 1024px) {
    .shell { grid-template-columns: 1fr; }

    body.menu-open {
        overflow: hidden;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        border-right: 1px solid var(--border);
        border-bottom: 0;
        padding: 14px;
        width: min(320px, 86vw);
        max-height: none;
        overflow: auto;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 80;
        transform: translateX(-105%);
        transition: transform 220ms ease;
    }

    .shell.menu-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 70;
        border: 0;
        padding: 0;
        margin: 0;
        cursor: pointer;
        background: rgba(1, 5, 14, 0.6);
    }

    .shell.menu-open .sidebar-backdrop {
        display: block;
    }

    .sidebar-close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .brand {
        margin-bottom: 10px;
    }

    .brand-logo {
        width: 138px;
    }

    .nav-link {
        padding: 9px 10px;
        margin-bottom: 6px;
    }

    .content-wrap {
        padding: 16px;
    }

    .topbar { flex-wrap: wrap; align-items: flex-start; }
    .topbar-left { width: 100%; }
    .topbar-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

    .card {
        padding: 14px;
    }

    table {
        min-width: 620px;
    }
}

@media (max-width: 640px) {
    .content-wrap {
        padding: 12px;
    }

    .sidebar {
        padding: 12px;
        width: min(300px, 88vw);
    }

    .brand-logo {
        width: 122px;
    }

    .nav-link {
        padding: 8px 9px;
        border-radius: 10px;
        font-size: 0.92rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .row {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 9px 12px;
    }

    .top-action {
        width: 42px;
        height: 42px;
    }

    .top-action i {
        font-size: 1.12rem;
    }

    .top-action-logout {
        width: 42px;
        height: 42px;
    }

    .action-btn {
        width: 34px;
        height: 34px;
    }

    table {
        min-width: 560px;
    }
}
