:root {
    --purple-950: #1f0d1e;
    --purple-900: #341133;
    --purple-800: #3e1b3d;
    --purple-700: #5c215a;
    --purple-500: #a83fa4;
    --purple-300: #d4a0d2;
    --purple-100: #f3e8f3;
    --green-100: #dcfce7;
    --green-700: #15803d;
    --red-100: #fee2e2;
    --red-700: #b91c1c;
    --surface: #f4f1f5;
    --surface-elevated: #ffffff;
    --text: #2a1529;
    --text-muted: #6b556a;
    --border: rgba(92, 33, 90, 0.12);
    --shadow-sm: 0 1px 3px rgba(31, 13, 30, 0.06);
    --shadow-md: 0 8px 24px rgba(92, 33, 90, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
    --font-display: var(--font-sans);
    --font-heading: "Anton", sans-serif;
    --transition: 0.2s ease;
    --btn-primary-gradient: linear-gradient(135deg, #1a1a1a 0%, #5c215a 55%, #7a3a78 100%);
    --btn-primary-gradient-hover: linear-gradient(135deg, #000000 0%, #5c215a 50%, #a83fa4 100%);
}

html { -webkit-text-size-adjust: 100%; }

body.layout-app {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
}

body.layout-minimal {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    min-height: 100vh;
}

body.layout-app a,
body.layout-minimal a { color: inherit; text-decoration: none; }

body.layout-app button,
body.layout-minimal button { font: inherit; cursor: pointer; border: none; background: none; }

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

.sidebar {
    display: none;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--purple-900);
    color: #fff;
    padding: 1.25rem 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1rem 1.25rem 1.25rem;
    margin: 0 0 1rem;
    background: var(--btn-primary-gradient);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

.sidebar-brand strong {
    display: block;
    font-size: 0.85rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sidebar-brand span {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: background var(--transition), color var(--transition);
    overflow: visible;
}

.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.sidebar-nav a.active {
    background: rgba(168, 63, 164, 0.25);
    color: #fff;
    border-right: 3px solid var(--purple-500);
}

.sidebar-nav a i { width: 1.1rem; text-align: center; }

.sidebar-nav a .nav-notice {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-left: auto;
}

.sidebar-nav a .nav-notice-dot {
    position: relative;
    display: block;
    width: 1.25rem;
    height: 1.25rem;
}

.sidebar-nav a .nav-notice-dot::before,
.sidebar-nav a .nav-notice-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    box-sizing: border-box;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.sidebar-nav a .nav-notice-dot::before {
    width: 0.5rem;
    height: 0.5rem;
    background: #f0d4ee;
    border: 2px solid #e8c4e6;
    box-shadow: 0 0 8px rgba(232, 196, 230, 0.55);
    z-index: 2;
}

.sidebar-nav a .nav-notice-dot::after {
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid rgba(212, 160, 210, 0.9);
    background: transparent;
    z-index: 1;
    animation: nav-notice-ring 1.75s ease-out infinite;
}

@keyframes nav-notice-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.6);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-nav a .nav-notice-dot::after {
        animation: none;
        opacity: 0;
    }
}

.sidebar-nav .nav-divider {
    height: 1px;
    margin: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.1);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--topbar-h);
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.menu-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--purple-700);
    flex-shrink: 0;
}

.menu-btn i {
    font-size: 1.25rem;
    line-height: 1;
}

.awareness-btn {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--purple-700);
}

.awareness-btn i {
    font-size: 1.55rem;
    line-height: 1;
}

.menu-btn:hover,
.awareness-btn:hover { background: var(--purple-100); }

.page-title-block h1 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--purple-700);
}

.breadcrumb {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.breadcrumb a:hover { color: var(--purple-500); }

.breadcrumb-current {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--purple-700);
    background: var(--purple-100);
    border-radius: var(--radius-full);
}

.role-chip i {
    font-size: 1.2rem;
    line-height: 1;
}

.app .content {
    flex: 1;
    padding: 1rem;
    width: 100%;
    min-height: 200px;
}

/* ——— Minimal layout ——— */
.minimal-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.minimal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    background: var(--surface-elevated);
    border-bottom: 1px solid var(--border);
}

.minimal-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.minimal-brand img { width: 40px; height: 40px; object-fit: contain; }
.minimal-brand strong { font-size: 0.95rem; color: var(--purple-700); }

.minimal-nav {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.minimal-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--purple-700);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.minimal-nav a:hover { background: var(--purple-100); border-color: transparent; }

.minimal-nav a i {
    font-size: 0.9rem;
    line-height: 1;
}

@media (max-width: 639px) {
    .minimal-topbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .minimal-brand {
        min-width: 0;
    }

    .minimal-brand strong {
        font-size: 0.8rem;
        line-height: 1.2;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .minimal-nav a {
        width: 40px;
        height: 40px;
        padding: 0;
        flex-shrink: 0;
    }

    .minimal-nav-label {
        display: none;
    }

    .minimal-nav a i {
        font-size: 1rem;
    }
}

.minimal-content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.minimal-card {
    width: 100%;
    max-width: 520px;
    padding: 1.5rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.minimal-card h2 {
    margin: 0 0 1.25rem;
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--purple-700);
}

.minimal-card--wide {
    max-width: 680px;
}

/* ——— Panel / toolbar (admin pages) ——— */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    padding: 1rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.stat-card .label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .value {
    margin-top: 0.25rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--purple-700);
}

.panel {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.tabs {
    display: inline-flex;
    padding: 0.25rem;
    background: var(--surface);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

        .tabs a,
        .tabs button {
            padding: 0.5rem 1rem;
            font-size: 0.8125rem;
            font-weight: 600;
            color: var(--text-muted);
            border-radius: var(--radius-full);
            text-decoration: none;
            transition: background var(--transition), color var(--transition), box-shadow var(--transition);
        }

.tabs a.active,
.tabs button.active {
    color: var(--purple-700);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-sm);
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .ok { color: var(--green-700); }
.legend .blocked { color: var(--red-700); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table-wrap .dataTables_wrapper,
.table-wrap .dt-container {
    min-width: 100%;
}

/* ——— Site footer (app shell) ——— */
.site-footer {
    padding: 1.25rem 1.5rem;
    background: var(--purple-950);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.8rem;
}

.site-footer p { margin: 0 0 0.35rem; }

/* ——— Drawers ——— */
.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(31, 13, 30, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 151;
    width: min(280px, 85vw);
    height: 100%;
    background: var(--purple-900);
    color: #fff;
    padding: 1.25rem 0;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.drawer-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.drawer-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.8);
}

.drawer-close:hover { background: rgba(255, 255, 255, 0.1); }

.drawer .sidebar-brand {
    border-bottom: none;
    margin-bottom: 0.5rem;
    padding: 1rem 1.25rem;
}
.drawer .sidebar-nav a { color: rgba(255, 255, 255, 0.8); }

.awareness-drawer .sidebar-nav a {
    font-size: 0.8125rem;
    padding: 0.65rem 1.25rem;
}

/* ——— Settings cards ——— */
.settings-grid {
    display: grid;
    gap: 0.75rem;
    max-width: 480px;
}

.settings-grid a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.settings-grid a:hover {
    border-color: rgba(168, 63, 164, 0.3);
    box-shadow: var(--shadow-sm);
}

.settings-grid a i {
    width: 1.25rem;
    text-align: center;
    color: var(--purple-500);
}

.settings-grid a.sign-out {
    color: var(--red-700);
    margin-top: 0.5rem;
}

.settings-grid a.sign-out i { color: var(--red-700); }

@media (min-width: 640px) {
    .stats { grid-template-columns: repeat(4, 1fr); }
    .app .content { padding: 1.5rem; }
}

@media (max-width: 899px) {
    .menu-btn {
        width: 50px;
        height: 50px;
    }

    .menu-btn i {
        font-size: 1.65rem;
    }
}

@media (min-width: 900px) {
    .sidebar { display: flex; }
    .menu-btn { display: none; }
}

@media (max-width: 599px) {
    .role-chip span.chip-label { display: none; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { width: 100%; justify-content: flex-end; }
}

/* Back to top */
body.layout-app .back-to-top,
body.layout-minimal .back-to-top {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 120;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    color: #fff;
    background: var(--btn-primary-gradient);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0.5rem);
    transition: opacity var(--transition), visibility var(--transition), transform var(--transition), background var(--transition);
}

body.layout-app .back-to-top.is-visible,
body.layout-minimal .back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

body.layout-app .back-to-top:hover,
body.layout-minimal .back-to-top:hover {
    background: var(--btn-primary-gradient-hover);
}

body.layout-app .back-to-top:focus-visible,
body.layout-minimal .back-to-top:focus-visible {
    outline: 2px solid var(--purple-500);
    outline-offset: 2px;
}

.back-to-top i {
    font-size: 1rem;
    line-height: 1;
}

body.d-modal-pdf-open .back-to-top {
    display: none;
}

@media (max-width: 599px) {
    body.layout-app .back-to-top,
    body.layout-minimal .back-to-top {
        right: 1rem;
        bottom: 1rem;
        width: 2.5rem;
        height: 2.5rem;
    }

    .back-to-top i {
        font-size: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.layout-app .back-to-top,
    body.layout-minimal .back-to-top {
        transition: opacity var(--transition), visibility var(--transition), background var(--transition);
        transform: none;
    }

    body.layout-app .back-to-top.is-visible,
    body.layout-minimal .back-to-top.is-visible {
        transform: none;
    }
}
