:root {
    --bg-primary: #0f1014;
    /* Deep matte black */
    --bg-secondary: #18191d;
    --bg-glass: rgba(30, 32, 38, 0.7);
    --border-light: rgba(255, 255, 255, 0.08);

    --accent-color: #5865F2;
    /* Discord Blurple-ish but vibrant */
    --accent-hover: #4752C4;
    --accent-glow: rgba(88, 101, 242, 0.3);

    --text-primary: #ffffff;
    --text-secondary: #a3a6aa;
    --text-tertiary: #72767d;

    --success: #2ecc71;
    --danger: #ed4245;
    --warning: #faa61a;

    --sidebar-width: 260px;
    --header-height: 70px;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --glass-blur: blur(16px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Layout Grid */
#app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.brand-icon {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    padding-left: 0.75rem;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item i {
    font-size: 1.1rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* User Profile in Sidebar */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-top: auto;
}

.user-avatar img,
.avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-info .username {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.user-info .logout-link {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-decoration: none;
}

.user-info .logout-link:hover {
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    background: var(--bg-primary);
}

.top-bar {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
}

.content-wrapper {
    padding: 1rem 2rem 4rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* Glassmorphism Cards */
.card-glass,
.guild-header,
.feature-card,
.modal-content,
.card-panel {
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Guild Header */
.guild-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 2.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, rgba(30, 32, 38, 0.9) 0%, rgba(20, 20, 25, 0.95) 100%);
    overflow: hidden;
}

.guild-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--module-color, var(--accent-color));
    opacity: 0.9;
}

.guild-icon {
    width: 90px;
    height: 90px;
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 3px var(--accent-glow);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 3px color-mix(in srgb, var(--module-color, var(--accent-color)) 35%, transparent);
    flex-shrink: 0;
}

.guild-info h2 {
    font-size: 2.25rem;
    margin-bottom: 0.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.guild-info p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 60ch;
}

/* Module Toolbar (back nav + breadcrumb, injected on every module detail page) */
.module-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1.25rem;
}

.module-toolbar .back-btn {
    margin-bottom: 0;
    padding: 0.4rem 0.9rem 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
}

.module-toolbar .back-btn:hover {
    border-color: var(--module-color, var(--accent-color));
    color: var(--text-primary);
}

.module-crumbs {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.crumb-sep {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.module-icon-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.08);
    background: color-mix(in srgb, var(--module-color, var(--accent-color)) 22%, transparent);
    box-shadow: inset 0 0 0 1px var(--border-light);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--module-color, var(--accent-color)) 40%, transparent);
}

.module-crumb-name {
    color: var(--text-primary);
    font-weight: 600;
}

@media (max-width: 640px) {
    .guild-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding: 1.75rem;
        gap: 1.25rem;
    }

    .guild-icon {
        width: 64px;
        height: 64px;
    }

    .guild-info h2 {
        font-size: 1.75rem;
    }
}

/* Buttons */
.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-family: var(--font-body);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

/* Feature Card Buttons */
.feature-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
}

.edit-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.edit-btn.primary {
    background: var(--accent-color);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.2);
}

.edit-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-light);
}

.edit-btn:hover {
    transform: translateY(-2px);
}

.edit-btn.primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(88, 101, 242, 0.3);
    color: white;
    border-color: transparent;
}

.edit-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--feature-color, var(--text-tertiary));
    color: var(--text-primary);
}

.feature-actions .edit-btn.primary {
    background: var(--feature-color, var(--accent-color));
    box-shadow: 0 4px 12px color-mix(in srgb, var(--feature-color, var(--accent-color)) 30%, transparent);
}

.feature-actions .edit-btn.primary:hover {
    background: color-mix(in srgb, var(--feature-color, var(--accent-color)) 85%, black);
    box-shadow: 0 6px 16px color-mix(in srgb, var(--feature-color, var(--accent-color)) 45%, transparent);
}

.edit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(88, 101, 242, 0.2);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(-4px);
}

/* Feature Cards Grid (Updated) */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    --fc: var(--feature-color, var(--accent-color));
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    cursor: pointer;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    position: relative;
}

.feature-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--fc);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.feature-card::after {
    content: "";
    position: absolute;
    top: -60px;
    right: -60px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--fc) 25%, transparent);
    filter: blur(40px);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.feature-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.feature-card:hover::before {
    opacity: 1;
}

.feature-card:hover::after {
    opacity: 1;
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--fc) 14%, transparent);
}

.feature-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
    transition: color 0.2s ease;
}

.feature-card:hover .feature-content h3 {
    color: var(--fc);
}

.feature-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Module Management: enable/disable toggle switch */
.feature-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.module-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.module-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.module-switch .slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    transition: background 0.2s ease;
}

.module-switch .slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    top: 2px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.module-switch input:checked+.slider {
    background: var(--feature-color, var(--accent-color));
    border-color: transparent;
}

.module-switch input:checked+.slider::before {
    transform: translateX(18px);
}

.module-switch input:disabled+.slider {
    opacity: 0.4;
    cursor: not-allowed;
}

.module-switch.core-locked {
    opacity: 0.6;
}

.feature-card.module-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.feature-card.module-disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-light);
}

.feature-card.module-disabled .feature-actions .edit-btn {
    pointer-events: none;
    opacity: 0.5;
}

.module-badge {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.module-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

/* Forms */
.form-group label {
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Modals */
.modal-content {
    background: #1e2026;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-secondary);
    --bs-table-border-color: var(--border-light);
}

.table th {
    font-weight: 600;
    color: var(--text-primary);
    border-bottom-width: 1px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding: 1rem;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
}

/* UI Elements */
.badge {
    padding: 0.5em 0.8em;
    border-radius: 6px;
    font-weight: 600;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    width: 350px;
    backdrop-filter: blur(10px);
}

.toast-body {
    font-size: 0.95rem;
    padding: 1rem;
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.features-grid,
.guild-header,
.module-toolbar,
.card-panel {
    animation: fadeIn 0.45s ease-out both;
}

.card-panel:nth-of-type(2) {
    animation-delay: 0.06s;
}

.card-panel:nth-of-type(3) {
    animation-delay: 0.12s;
}

.card-panel:nth-of-type(4) {
    animation-delay: 0.18s;
}

/* Dashboard Hero (server-select page) */
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
}

.dashboard-hero-text h2 {
    font-size: 2rem;
    margin-bottom: 0.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-hero-text p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.dashboard-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 0.6rem 1.1rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    backdrop-filter: var(--glass-blur);
}

.stat-pill .stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-pill .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
}

.stat-pill-success .stat-value {
    color: var(--success);
}

.stat-pill-warning .stat-value {
    color: var(--warning);
}

.dashboard-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    max-width: 320px;
    padding: 0.65rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-tertiary);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--accent-color);
    background: rgba(0, 0, 0, 0.35);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 4rem 1rem;
    color: var(--text-tertiary);
    text-align: center;
}

.dashboard-empty i {
    font-size: 2.5rem;
    opacity: 0.6;
}

/* Guild Selection Grid */
.guilds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0.25rem 0 1rem;
}

.guild-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.35s ease-out both;
}

.guild-card:hover {
    transform: translateY(-8px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.guild-card img {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.guild-card:hover img {
    transform: scale(1.1);
}

.guild-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    word-break: break-word;
}

.guild-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    min-height: 1.5rem;
}

.guild-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.guild-badge-owner {
    background: rgba(250, 166, 26, 0.15);
    color: var(--warning);
}

.guild-badge-active {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.guild-badge-setup {
    background: rgba(250, 166, 26, 0.15);
    color: var(--warning);
}

.guild-cta {
    margin-top: auto;
    padding-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-color);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.guild-cta-invite {
    color: var(--warning);
}

.guild-cta-disabled {
    color: var(--text-tertiary);
    font-weight: 500;
}

.guild-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.guild-card.disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Skeleton loading state for guild cards */
.guild-card.skeleton {
    cursor: default;
    animation: none;
}

.guild-card.skeleton:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-light);
}

.skeleton-icon,
.skeleton-line {
    border-radius: 8px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.12) 37%,
            rgba(255, 255, 255, 0.05) 63%);
    background-size: 400% 100%;
    animation: skeletonShimmer 1.4s ease infinite;
}

.skeleton-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin-bottom: 1rem;
}

.skeleton-line {
    height: 10px;
    width: 60%;
    margin-bottom: 0.6rem;
}

.skeleton-line-badge {
    width: 40%;
    height: 18px;
    border-radius: 999px;
}

.skeleton-line-title {
    width: 70%;
    height: 14px;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

@media (max-width: 640px) {
    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-toolbar {
        justify-content: stretch;
    }

    .search-box {
        max-width: none;
    }
}



/* Custom Modal (for templates using .modal.active pattern) */
.modal.custom-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1050;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.custom-modal.active {
    display: flex;
}

.modal.custom-modal .modal-content {
    max-width: 500px;
    width: 90%;
    margin: auto;
    padding: 2rem;
}

.modal.custom-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.modal.custom-modal .modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal.custom-modal .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal.custom-modal .close-btn:hover {
    color: var(--text-primary);
}

/* Card Panel (for feature pages) */
.card-panel {
    padding: 2rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.card-panel:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

.card-panel h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-panel > h3:first-child,
.card-panel > .card-panel-header {
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

/* Form Controls (Bootstrap overrides for dark theme) */
.form-control,
.form-select {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background-color: rgba(0, 0, 0, 0.4);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-label {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-text {
    color: var(--text-tertiary);
}

/* Multi-Select (for role selection and similar) */
.multi-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.multi-select-item {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.multi-select-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-tertiary);
}

.multi-select-item.selected {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Advanced Editor */
.advanced-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.advanced-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#advancedEditor {
    width: 100%;
    min-height: 400px;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 1rem;
    resize: vertical;
}

#advancedEditor:focus {
    outline: none;
    border-color: var(--accent-color);
}

.advanced-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.advanced-footer code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.advanced-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #36393f;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .slider {
    background-color: var(--success);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(24px);
}